mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 17:05:43 +03:00
rework where time gets set
This commit is contained in:
committed by
Preetha Appan
parent
1050b89ac3
commit
2d6264e75d
@@ -50,7 +50,8 @@ type AllocRunner struct {
|
||||
alloc *structs.Allocation
|
||||
allocClientStatus string // Explicit status of allocation. Set when there are failures
|
||||
allocClientDescription string
|
||||
allocHealth *bool // Whether the allocation is healthy
|
||||
allocHealth *bool // Whether the allocation is healthy
|
||||
allocHealthTime time.Time // Time at which allocation health has been set
|
||||
allocBroadcast *cstructs.AllocBroadcaster
|
||||
allocLock sync.Mutex
|
||||
|
||||
@@ -577,11 +578,10 @@ func (r *AllocRunner) Alloc() *structs.Allocation {
|
||||
// The health has been set
|
||||
if r.allocHealth != nil {
|
||||
if alloc.DeploymentStatus == nil {
|
||||
alloc.DeploymentStatus = &structs.AllocDeploymentStatus{
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
alloc.DeploymentStatus = &structs.AllocDeploymentStatus{}
|
||||
}
|
||||
alloc.DeploymentStatus.Healthy = helper.BoolToPtr(*r.allocHealth)
|
||||
alloc.DeploymentStatus.Timestamp = r.allocHealthTime
|
||||
}
|
||||
r.allocLock.Unlock()
|
||||
|
||||
@@ -945,6 +945,7 @@ OUTER:
|
||||
// If the deployment ids have changed clear the health
|
||||
if r.alloc.DeploymentID != update.DeploymentID {
|
||||
r.allocHealth = nil
|
||||
r.allocHealthTime = time.Time{}
|
||||
}
|
||||
|
||||
r.alloc = update
|
||||
|
||||
@@ -112,6 +112,7 @@ func (r *AllocRunner) watchHealth(ctx context.Context) {
|
||||
|
||||
r.allocLock.Lock()
|
||||
r.allocHealth = helper.BoolToPtr(allocHealthy)
|
||||
r.allocHealthTime = time.Now()
|
||||
r.allocLock.Unlock()
|
||||
|
||||
// If deployment is unhealthy emit task events explaining why
|
||||
|
||||
Reference in New Issue
Block a user