Skip to content

Commit

Permalink
Handle deadlock on startup (#1435)
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-rieke authored Jan 17, 2025
1 parent c66d972 commit 8eb22c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
29 changes: 13 additions & 16 deletions atrium/vestibulum/trcsh/deployutil/deployutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func LoadPluginDeploymentScript(trcshDriverConfig *capauth.TrcshDriverConfig, tr
deployScriptPath := fmt.Sprintf("./trc_templates/%s/deploy/deploy.trc.tmpl", trcProjectService.(string))
subErr := SubDeployScript(trcshDriverConfig,
deployScriptPath,
trcProjectService.(string),
configRoleSlice)
if subErr != nil {
eUtils.LogErrorObject(trcshDriverConfig.DriverConfig.CoreConfig, subErr, false)
Expand All @@ -137,30 +138,26 @@ func LoadPluginDeploymentScript(trcshDriverConfig *capauth.TrcshDriverConfig, tr
func SubDeployScript(
trcshDriverConfig *capauth.TrcshDriverConfig,
trcPath string,
projectService string,
configRoleSlice []string) error {

if !strings.Contains(trcPath, "/deploy/") {
fmt.Println("Trcsh - Failed to fetch template using projectServicePtr. Path is missing /deploy/")
return errors.New("trcsh - Failed to fetch template using projectServicePtr. path is missing /deploy/")
}
if projectService, ok := trcshDriverConfig.DriverConfig.DeploymentConfig["trcprojectservice"]; ok && strings.Contains(projectService.(string), "/") {
mergedEnvBasis := trcshDriverConfig.DriverConfig.CoreConfig.EnvBasis
tokenName := "config_token_" + trcshDriverConfig.DriverConfig.CoreConfig.EnvBasis
mergedVaultAddressPtr := trcshDriverConfig.DriverConfig.CoreConfig.VaultAddressPtr

deployTrcPath := trcPath[strings.LastIndex(trcPath, "/deploy/"):]
if trcIndex := strings.Index(deployTrcPath, ".trc"); trcIndex > 0 {
deployTrcPath = deployTrcPath[0:trcIndex] // get rid of trailing .trc
}
templatePathsPtr := projectService.(string) + deployTrcPath
trcshDriverConfig.DriverConfig.EndDir = "./trc_templates"
mergedEnvBasis := trcshDriverConfig.DriverConfig.CoreConfig.EnvBasis
tokenName := "config_token_" + trcshDriverConfig.DriverConfig.CoreConfig.EnvBasis
mergedVaultAddressPtr := trcshDriverConfig.DriverConfig.CoreConfig.VaultAddressPtr

return trcsubbase.CommonMain(&trcshDriverConfig.DriverConfig.CoreConfig.EnvBasis, mergedVaultAddressPtr,
&mergedEnvBasis, &configRoleSlice[1], &configRoleSlice[0], &tokenName, nil, []string{"trcsh", "-templatePaths=" + templatePathsPtr}, trcshDriverConfig.DriverConfig)
} else {
fmt.Println("Project not configured and ready for deployment. Missing projectservice")
return errors.New("project not configured and ready for deployment. missing projectservice")
deployTrcPath := trcPath[strings.LastIndex(trcPath, "/deploy/"):]
if trcIndex := strings.Index(deployTrcPath, ".trc"); trcIndex > 0 {
deployTrcPath = deployTrcPath[0:trcIndex] // get rid of trailing .trc
}
templatePathsPtr := projectService + deployTrcPath
trcshDriverConfig.DriverConfig.EndDir = "./trc_templates"

return trcsubbase.CommonMain(&trcshDriverConfig.DriverConfig.CoreConfig.EnvBasis, mergedVaultAddressPtr,
&mergedEnvBasis, &configRoleSlice[1], &configRoleSlice[0], &tokenName, nil, []string{"trcsh", "-templatePaths=" + templatePathsPtr}, trcshDriverConfig.DriverConfig)
}

// Gets list of supported deployers for current environment.
Expand Down
2 changes: 1 addition & 1 deletion atrium/vestibulum/trcsh/trcshmemfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ summitatem:
p, filestack = filestack[len(filestack)-1], filestack[:len(filestack)-1]

if fileset, err := (*t.BillyFs).ReadDir(p); err == nil {
if path != "." {
if path != "." && len(fileset) > 0 {
filestack = append(filestack, p)
}
for _, file := range fileset {
Expand Down
12 changes: 6 additions & 6 deletions atrium/vestibulum/trcshbase/trcsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ func ProcessDeploy(featherCtx *cap.FeatherContext,
trcshDriverConfig *capauth.TrcshDriverConfig,
deployment string,
trcPath string,
projectServicePtr string,
projectService string,
secretId *string,
approleId *string,
dronePtr *bool) {
Expand Down Expand Up @@ -1338,7 +1338,7 @@ func ProcessDeploy(featherCtx *cap.FeatherContext,
return
}
if pjService, ok := certifyMap["trcprojectservice"]; ok {
projectServicePtr = pjService.(string)
projectService = pjService.(string)
} else {
fmt.Printf("Kernel Missing plugin component project service: %s.\n", deployment)
return
Expand All @@ -1360,15 +1360,15 @@ func ProcessDeploy(featherCtx *cap.FeatherContext,
trcshDriverConfig.DriverConfig.CoreConfig.Log.Printf("Couldn't config auth required resource.\n")
os.Exit(124)
}
if projectServicePtr != "" {
fmt.Println("Trcsh - Attempting to fetch templates from provided projectServicePtr: " + projectServicePtr)
err := deployutil.SubDeployScript(trcshDriverConfig, trcPath, configRoleSlice)
if projectService != "" {
fmt.Println("Trcsh - Attempting to fetch templates from provided projectServicePtr: " + projectService)
err := deployutil.SubDeployScript(trcshDriverConfig, trcPath, projectService, configRoleSlice)

if err != nil {
fmt.Println("Trcsh - Failed to fetch template using projectServicePtr. " + err.Error())
return
}
trcshDriverConfig.DriverConfig.ServicesWanted = strings.Split(projectServicePtr, ",")
trcshDriverConfig.DriverConfig.ServicesWanted = strings.Split(projectService, ",")
}

trcshDriverConfig.DriverConfig.OutputMemCache = true
Expand Down

0 comments on commit 8eb22c7

Please sign in to comment.