Skip to content

Commit

Permalink
Improve pipeline handling on drone (#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-rieke authored Jan 17, 2025
1 parent 8eb22c7 commit 4cce76e
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions atrium/vestibulum/trcshbase/trcsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func EnableDeployer(driverConfigPtr *config.DriverConfig,
// Set the name of the plugin to deploy in "trcplugin"
// Used later by codedeploy
trcshDriverConfig.DriverConfig.DeploymentConfig = map[string]interface{}{"trcplugin": deployment}
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan = make(chan string, 5)
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan = make(chan string, 20)
fmt.Printf("Starting deployer: %s\n", deployment)
trcshDriverConfig.DriverConfig.CoreConfig.Log.Printf("Starting deployer: %s\n", deployment)
}
Expand Down Expand Up @@ -1545,6 +1545,7 @@ collaboratorReRun:
if len(trcshDriverConfig.DriverConfig.CoreConfig.Regions) > 0 {
region = trcshDriverConfig.DriverConfig.CoreConfig.Regions[0]
}
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan <- deployLine
err := processDroneCmds(
trcKubeDeploymentConfig,
&onceKubeInit,
Expand All @@ -1565,16 +1566,11 @@ collaboratorReRun:
deliverableMsg := fmt.Sprintf("%s encountered errors - %s\n", deployLine, errMessageFiltered)
go func(dMesg string) {
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan <- dMesg
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan <- cap.CTL_COMPLETE
closeCleanupMessaging(trcshDriverConfig)
}(deliverableMsg)

atomic.StoreInt64(&trcshDriverConfig.FeatherCtx.RunState, cap.RUN_STARTED)
content = nil
goto collaboratorReRun
} else {
go func(dl string) {
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan <- dl
}(deployLine)
}
} else {
trcshDriverConfig.DriverConfig.CoreConfig.Log.Println(deployLine)
Expand All @@ -1599,13 +1595,11 @@ collaboratorReRun:
}
}
if *dronePtr {
completeOnce := false
for {
completeOnce := false
if atomic.LoadInt64(&featherCtx.RunState) == cap.RUNNING {
if !completeOnce {
go func() {
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan <- cap.CTL_COMPLETE
}()
closeCleanupMessaging(trcshDriverConfig)
completeOnce = true
}
time.Sleep(time.Second)
Expand All @@ -1619,3 +1613,37 @@ collaboratorReRun:
//Make the arguments in the script -> os.args.

}

func closeCleanupMessaging(trcshDriverConfig *capauth.TrcshDriverConfig) {
lastCtlChanLen := 0
waitCtr := 0
for {
ctlChanLen := len(trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan)
if ctlChanLen > 0 && waitCtr < 10 {
if lastCtlChanLen != ctlChanLen {
waitCtr = 0
} else {
waitCtr++
}
lastCtlChanLen = ctlChanLen
time.Sleep(1 * time.Second)
} else {
if waitCtr == 10 {
for {
if len(trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan) > 0 {
select {
case <-trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan:
default:
break
}
}
}
} else {
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan <- "..."
}
trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan <- cap.CTL_COMPLETE
atomic.StoreInt64(&trcshDriverConfig.FeatherCtx.RunState, cap.RUN_STARTED)
break
}
}
}

0 comments on commit 4cce76e

Please sign in to comment.