Save deployment status

This commit is contained in:
Alex Dadgar
2017-07-18 12:31:05 -07:00
parent 386557da73
commit 459ddf63ec
2 changed files with 5 additions and 5 deletions

View File

@@ -143,6 +143,7 @@ type allocRunnerMutableState struct {
AllocClientStatus string
AllocClientDescription string
TaskStates map[string]*structs.TaskState
DeploymentStatus *structs.AllocDeploymentStatus
}
// NewAllocRunner is used to create a new allocation context
@@ -255,6 +256,7 @@ func (r *AllocRunner) RestoreState() error {
r.allocClientDescription = mutable.AllocClientDescription
r.taskStates = mutable.TaskStates
r.alloc.ClientStatus = getClientStatus(r.taskStates)
r.alloc.DeploymentStatus = mutable.DeploymentStatus
return nil
})
@@ -422,6 +424,7 @@ func (r *AllocRunner) saveAllocRunnerState() error {
AllocClientStatus: allocClientStatus,
AllocClientDescription: allocClientDescription,
TaskStates: alloc.TaskStates,
DeploymentStatus: alloc.DeploymentStatus,
}
if err := putObject(allocBkt, allocRunnerStateMutableKey, &mutable); err != nil {
@@ -583,7 +586,7 @@ func (r *AllocRunner) syncStatus() error {
time.Sleep(500 * time.Millisecond)
}
if !sent {
r.logger.Printf("[WARN] client: failed to broadcase update to allocation %q", r.allocID)
r.logger.Printf("[WARN] client: failed to broadcast update to allocation %q", r.allocID)
}
return r.saveAllocRunnerState()

View File

@@ -24,10 +24,7 @@ func (r *AllocRunner) watchHealth(ctx context.Context) {
if alloc.DeploymentID == "" {
r.logger.Printf("[TRACE] client.alloc_watcher: exiting because alloc isn't part of a deployment")
return
}
// TODO Add to persisted state
if alloc.DeploymentStatus.IsHealthy() || alloc.DeploymentStatus.IsUnhealthy() {
} else if alloc.DeploymentStatus.IsHealthy() || alloc.DeploymentStatus.IsUnhealthy() {
r.logger.Printf("[TRACE] client.alloc_watcher: exiting because alloc deployment health already determined")
return
}