client: updates from pr feedback

This commit is contained in:
Seth Hoenig 2022-07-21 09:54:27 -05:00
parent 297d386bdc
commit 606e3ebdd4
5 changed files with 13 additions and 8 deletions

3
.changelog/13715.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
client: Add built-in support for checks on nomad services
```

View File

@ -366,7 +366,7 @@ func (t *Tracker) watchTaskEvents() {
// reset task health // reset task health
t.setTaskHealth(false, false) t.setTaskHealth(false, false)
// Avoid the timer from firing at the old start time // Prevent the timer from firing at the old start time
waiter.disable() waiter.disable()
// Set the timer since all tasks are started // Set the timer since all tasks are started
@ -492,9 +492,6 @@ OUTER:
// Store the task registrations // Store the task registrations
t.lock.Lock() t.lock.Lock()
for task, reg := range allocReg.Tasks { for task, reg := range allocReg.Tasks {
//TODO(schmichael) for now skip unknown tasks as
//they're task group services which don't currently
//support checks anyway
if v, ok := t.taskHealth[task]; ok { if v, ok := t.taskHealth[task]; ok {
v.taskRegistrations = reg v.taskRegistrations = reg
} }
@ -571,7 +568,7 @@ func (t *Tracker) watchNomadEvents() {
for { for {
select { select {
// we are shutting down // tracker has been canceled, so stop waiting
case <-t.ctx.Done(): case <-t.ctx.Done():
return return

View File

@ -55,7 +55,7 @@ func (o *observer) start() {
query := checks.GetCheckQuery(o.check) query := checks.GetCheckQuery(o.check)
result := o.checker.Do(o.ctx, o.qc, query) result := o.checker.Do(o.ctx, o.qc, query)
// and put the results into the store // and put the results into the store (already logged)
_ = o.checkStore.Set(o.allocID, result) _ = o.checkStore.Set(o.allocID, result)
// setup timer for next interval // setup timer for next interval

View File

@ -57,6 +57,8 @@ func (s *shim) restore() {
results, err := s.db.GetCheckResults() results, err := s.db.GetCheckResults()
if err != nil { if err != nil {
s.log.Error("failed to restore health check results", "error", err) s.log.Error("failed to restore health check results", "error", err)
// may as well continue and let the check observers repopulate - maybe
// the persistent storage error was transitory
return return
} }
@ -90,7 +92,10 @@ func (s *shim) Set(allocID string, qr *structs.CheckQueryResult) error {
// on Client restart restored check results may be outdated but the status // on Client restart restored check results may be outdated but the status
// is the same as the most recent result // is the same as the most recent result
if !exists || previous.Status != qr.Status { if !exists || previous.Status != qr.Status {
return s.db.PutCheckResult(allocID, qr) if err := s.db.PutCheckResult(allocID, qr); err != nil {
s.log.Error("failed to set check status", "alloc_id", allocID, "check_id", qr.ID, "error", err)
return err
}
} }
return nil return nil

View File

@ -15,7 +15,7 @@ const (
// will not move forward while the check is failing. // will not move forward while the check is failing.
Healthiness CheckMode = "healthiness" Healthiness CheckMode = "healthiness"
// A Readiness check is useful in the context of ensuring a service is // A Readiness check is useful in the context of ensuring a service
// should be performing its duties (regardless of healthiness). This is an // should be performing its duties (regardless of healthiness). This is an
// indicator that the check's on_update configuration is set to "ignore", // indicator that the check's on_update configuration is set to "ignore",
// implying that Deployments will move forward regardless if the check is // implying that Deployments will move forward regardless if the check is