Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split the error message in backend syncer health processing #864

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/backends/backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (b *Backends) Delete(name string, version meta.Version, scope meta.KeyType)
func (b *Backends) Health(name string, version meta.Version, scope meta.KeyType) (string, error) {
be, err := b.Get(name, version, scope)
if err != nil || len(be.Backends) == 0 {
return "Unknown", fmt.Errorf("error getting health for backend %s: %v", name, err)
return "Unknown", fmt.Errorf("error getting backend %q: %v", name, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we separate out the cases here

if err != nil {
  return "Unknown", fmt.Errorf("error betting backend...", ...)
}
if len(be.Backends) == 0 {
  return "Unknown", fmt.Errorf("backend list is empty...", ...)
}

}

// TODO: Look at more than one backend's status
Expand All @@ -179,9 +179,14 @@ func (b *Backends) Health(name string, version meta.Version, scope meta.KeyType)
return "Unknown", fmt.Errorf("invalid scope for Health(): %s", scope)
}

if err != nil || len(hs.HealthStatus) == 0 || hs.HealthStatus[0] == nil {
if err != nil {
return "Unknown", fmt.Errorf("error getting health for backend %q: %v", name, err)
}
if len(hs.HealthStatus) == 0 || hs.HealthStatus[0] == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we get a nil in the first element? seems incorrect (somewhere).

klog.V(3).Infof("backend service %q does not have health status: %v", name, hs.HealthStatus)
return "Unknown", nil
}

// TODO: State transition are important, not just the latest.
return hs.HealthStatus[0].HealthState, nil
}
Expand Down