Skip to content

Commit

Permalink
Report per-job store health in /v2/systems API
Browse files Browse the repository at this point in the history
During the Ad Hoc Backup wizard, the card for storage was trying
to convey health status, but the `healthy` attribute it relied on
was not actually being set by the API we were calling.

Fixes https://trello.com/c/lJShu0A9/45-cloud-storage-is-connected-and-green-but-showing-error
  • Loading branch information
dennisjbell authored and jhunt committed Jul 7, 2018
1 parent ec83324 commit 5de42eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type v2SystemJob struct {
Name string `json:"name"`
Summary string `json:"summary"`
Plugin string `json:"plugin"`
Healthy bool `json:"healthy"`
} `json:"store"`

Keep struct {
Expand Down Expand Up @@ -3226,6 +3227,7 @@ func (core *Core) v2copyTarget(dst *v2System, target *db.Target) error {
dst.Jobs[j].Store.UUID = job.Store.UUID
dst.Jobs[j].Store.Name = job.Store.Name
dst.Jobs[j].Store.Summary = job.Store.Summary
dst.Jobs[j].Store.Healthy = job.Store.Healthy
dst.Jobs[j].Retention.UUID = job.Policy.UUID
dst.Jobs[j].Retention.Name = job.Policy.Name
dst.Jobs[j].Retention.Summary = job.Policy.Summary
Expand Down
9 changes: 5 additions & 4 deletions db/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Job struct {
Agent string `json:"agent"`
Plugin string `json:"plugin"`
Summary string `json:"summary"`
Healthy bool `json:"healthy"`

Endpoint string `json:"endpoint,omitempty"`
Config map[string]interface{} `json:"config,omitempty"`
Expand Down Expand Up @@ -132,7 +133,7 @@ func (f *JobFilter) Query(driver string) (string, []interface{}, error) {
SELECT j.uuid, j.name, j.summary, j.paused, j.schedule, j.tenant_uuid, j.fixed_key,
r.name, r.summary, r.uuid, r.expiry,
s.uuid, s.name, s.plugin, s.endpoint, s.summary,
s.uuid, s.name, s.plugin, s.endpoint, s.summary, s.healthy,
t.uuid, t.name, t.plugin, t.endpoint, t.agent,
k.started_at, k.status
Expand Down Expand Up @@ -172,7 +173,7 @@ func (db *DB) GetAllJobs(filter *JobFilter) ([]*Job, error) {
if err = r.Scan(
&this, &j.Name, &j.Summary, &j.Paused, &j.Schedule, &tenant, &j.FixedKey,
&j.Policy.Name, &j.Policy.Summary, &policy, &j.Expiry,
&store, &j.Store.Name, &j.Store.Plugin, &j.Store.Endpoint, &j.Store.Summary,
&store, &j.Store.Name, &j.Store.Plugin, &j.Store.Endpoint, &j.Store.Summary, &j.Store.Healthy,
&target, &j.Target.Name, &j.Target.Plugin, &j.Target.Endpoint,
&j.Agent, &last, &status); err != nil {
return l, err
Expand All @@ -199,7 +200,7 @@ func (db *DB) GetJob(id uuid.UUID) (*Job, error) {
r, err := db.Query(`
SELECT j.uuid, j.name, j.summary, j.paused, j.schedule, j.tenant_uuid, j.fixed_key,
r.name, r.summary, r.uuid, r.expiry,
s.uuid, s.name, s.plugin, s.endpoint, s.summary,
s.uuid, s.name, s.plugin, s.endpoint, s.summary, s.healthy,
t.uuid, t.name, t.plugin, t.endpoint, t.agent
FROM jobs j
Expand All @@ -222,7 +223,7 @@ func (db *DB) GetJob(id uuid.UUID) (*Job, error) {
if err = r.Scan(
&this, &j.Name, &j.Summary, &j.Paused, &j.Schedule, &tenant, &j.FixedKey,
&j.Policy.Name, &j.Policy.Summary, &policy, &j.Expiry,
&store, &j.Store.Name, &j.Store.Plugin, &j.Store.Endpoint, &j.Store.Summary,
&store, &j.Store.Name, &j.Store.Plugin, &j.Store.Endpoint, &j.Store.Summary, &j.Store.Healthy,
&target, &j.Target.Name, &j.Target.Plugin, &j.Target.Endpoint,
&j.Agent); err != nil {
return nil, err
Expand Down

0 comments on commit 5de42eb

Please sign in to comment.