Skip to content

Commit

Permalink
client: updates from pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
shoenig committed Jul 21, 2022
1 parent b2861f2 commit 24dcd1d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .changelog/13715.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
client: Add built-in support for checks on nomad services
```
7 changes: 2 additions & 5 deletions client/allochealth/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func (t *Tracker) watchTaskEvents() {
// reset task health
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()

// Set the timer since all tasks are started
Expand Down Expand Up @@ -492,9 +492,6 @@ OUTER:
// Store the task registrations
t.lock.Lock()
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 {
v.taskRegistrations = reg
}
Expand Down Expand Up @@ -571,7 +568,7 @@ func (t *Tracker) watchNomadEvents() {
for {
select {

// we are shutting down
// tracker has been canceled, so stop waiting
case <-t.ctx.Done():
return

Expand Down
2 changes: 1 addition & 1 deletion client/allocrunner/checks_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (o *observer) start() {
query := checks.GetCheckQuery(o.check)
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)

// setup timer for next interval
Expand Down
7 changes: 6 additions & 1 deletion client/serviceregistration/checks/checkstore/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func (s *shim) restore() {
results, err := s.db.GetCheckResults()
if err != nil {
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
}

Expand Down Expand Up @@ -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
// is the same as the most recent result
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
Expand Down
2 changes: 1 addition & 1 deletion nomad/structs/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
// will not move forward while the check is failing.
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
// indicator that the check's on_update configuration is set to "ignore",
// implying that Deployments will move forward regardless if the check is
Expand Down

0 comments on commit 24dcd1d

Please sign in to comment.