diff --git a/core/instance/instance_test.go b/core/instance/instance_test.go index e6dfd05d2..cbc0136de 100644 --- a/core/instance/instance_test.go +++ b/core/instance/instance_test.go @@ -29,7 +29,7 @@ func Test_Status_Unmarshal(t *testing.T) { Overall: status.Down, Provisioned: provisioned.Mixed, UpdatedAt: time.Date(2022, time.December, 28, 11, 21, 45, 800780633, time.UTC), - Resources: []resource.ExposedStatus{ + Resources: []resource.Status{ { ResourceID: (*resourceid.T)(nil), Rid: "volume#1", diff --git a/core/instance/monitor.go b/core/instance/monitor.go index 37b24dd97..3dc9984a4 100644 --- a/core/instance/monitor.go +++ b/core/instance/monitor.go @@ -397,7 +397,7 @@ func (m ResourceMonitors) DeepCopy() ResourceMonitors { return xmap.Copy(m) } -func (mon Monitor) ResourceFlagRestartString(rid resourceid.T, r resource.ExposedStatus) string { +func (mon Monitor) ResourceFlagRestartString(rid resourceid.T, r resource.Status) string { // Restart and retries retries := 0 if rmon := mon.Resources.Get(rid.Name); rmon != nil { diff --git a/core/instance/status.go b/core/instance/status.go index d2c307600..1ce2d21e8 100644 --- a/core/instance/status.go +++ b/core/instance/status.go @@ -27,14 +27,14 @@ type ( UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"` } - ResourceStatuses map[string]resource.ExposedStatus + ResourceStatuses map[string]resource.Status // ResourceRunningSet is the list of resource currently running (sync and task). ResourceRunningSet []string // ResourceOrder is a sortable list representation of the // instance status resources map. - ResourceOrder []resource.ExposedStatus + ResourceOrder []resource.Status ) func (m ResourceStatuses) DeepCopy() ResourceStatuses { @@ -59,8 +59,8 @@ func (t ResourceRunningSet) Has(rid string) bool { // 1/ driver group // 2/ subset // 3/ resource name -func (t *Status) SortedResources() []resource.ExposedStatus { - l := make([]resource.ExposedStatus, 0) +func (t *Status) SortedResources() []resource.Status { + l := make([]resource.Status, 0) for rid, rstat := range t.Resources { id, err := resourceid.Parse(rid) if err != nil { @@ -116,7 +116,7 @@ func (a ResourceOrder) Less(i, j int) bool { // E Encap // P Provisioned // S Standby -func (t Status) ResourceFlagsString(rid resourceid.T, r resource.ExposedStatus) string { +func (t Status) ResourceFlagsString(rid resourceid.T, r resource.Status) string { flags := "" // Running task or sync diff --git a/core/object/actor_status.go b/core/object/actor_status.go index 206c5fef9..f827a0837 100644 --- a/core/object/actor_status.go +++ b/core/object/actor_status.go @@ -105,7 +105,7 @@ func (t *actor) resourceStatusEval(ctx context.Context, data *instance.Status) e data.Resources = make(instance.ResourceStatuses) var mu sync.Mutex err := t.ResourceSets().Do(ctx, t, "", "status", func(ctx context.Context, r resource.Driver) error { - xd := resource.GetExposedStatus(ctx, r) + xd := resource.GetStatus(ctx, r) // If the resource is up but the provisioned flag is unset, set // the provisioned flag. diff --git a/core/resource/resource.go b/core/resource/resource.go index 8b5f9eb5a..f302a8366 100644 --- a/core/resource/resource.go +++ b/core/resource/resource.go @@ -203,9 +203,9 @@ type ( // TagSet is the list of unique tag names found in the resource definition. TagSet []string - // ExposedStatus is the structure representing the resource status, + // Status is the structure representing the resource status, // which is embedded in the instance status. - ExposedStatus struct { + Status struct { ResourceID *resourceid.T `json:"-" yaml:"-"` Label string `json:"label" yaml:"label"` Log []*StatusLogEntry `json:"log,omitempty" yaml:"log,omitempty"` @@ -234,7 +234,7 @@ type ( Hook int - ExposedStatusInfoSchedAction struct { + StatusInfoSchedAction struct { Last time.Time `json:"last" yaml:"last"` } @@ -866,7 +866,7 @@ func Start(ctx context.Context, r Driver) error { return nil } -// Resync execute the resource Resync function, if exposed. +// Resync execute the resource Resync function, if implemented by the driver. func Resync(ctx context.Context, r Driver) error { var i any = r s, ok := i.(resyncer) @@ -885,7 +885,7 @@ func Resync(ctx context.Context, r Driver) error { return nil } -// Full execute the resource Update function, if exposed. +// Full execute the resource Update function, if implemented by the driver. func Full(ctx context.Context, r Driver) error { var i any = r s, ok := i.(fuller) @@ -904,7 +904,7 @@ func Full(ctx context.Context, r Driver) error { return nil } -// Update execute the resource Update function, if exposed. +// Update execute the resource Update function, if implemented by the driver. func Update(ctx context.Context, r Driver) error { var i any = r s, ok := i.(updater) @@ -1134,9 +1134,9 @@ func SCSIPersistentReservationStatus(r Driver) status.T { } } -// GetExposedStatus returns the resource exposed status data for embedding into the instance status data. -func GetExposedStatus(ctx context.Context, r Driver) ExposedStatus { - return ExposedStatus{ +// GetStatus returns the resource Status for embedding into the instance.Status. +func GetStatus(ctx context.Context, r Driver) Status { + return Status{ Label: formatResourceLabel(r), Type: r.Manifest().DriverID.String(), Status: EvalStatus(ctx, r), @@ -1144,7 +1144,7 @@ func GetExposedStatus(ctx context.Context, r Driver) ExposedStatus { Tags: r.TagSet(), Log: r.StatusLog().Entries(), Provisioned: getProvisionStatus(r), - Info: exposedStatusInfo(r), + Info: getStatusInfo(r), Restart: RestartFlag(r.RestartCount()), Optional: OptionalFlag(r.IsOptional()), Standby: StandbyFlag(r.IsStandby()), @@ -1154,7 +1154,7 @@ func GetExposedStatus(ctx context.Context, r Driver) ExposedStatus { } func printStatus(ctx context.Context, r Driver) error { - data := GetExposedStatus(ctx, r) + data := GetStatus(ctx, r) enc := json.NewEncoder(os.Stdout) enc.SetIndent("", " ") return enc.Encode(data) @@ -1214,22 +1214,22 @@ func (t *T) DoWithLock(disable bool, timeout time.Duration, intent string, f fun return f() } -func exposedStatusInfo(t Driver) (data map[string]any) { +func getStatusInfo(t Driver) (data map[string]any) { if i, ok := t.(StatusInfoer); ok { data = i.StatusInfo() } else { data = make(map[string]any) } if i, ok := t.(Scheduler); ok { - data["sched"] = exposedStatusInfoSched(i) + data["sched"] = getStatusInfoSched(i) } return data } -func exposedStatusInfoSched(t Scheduler) map[string]ExposedStatusInfoSchedAction { - data := make(map[string]ExposedStatusInfoSchedAction) +func getStatusInfoSched(t Scheduler) map[string]StatusInfoSchedAction { + data := make(map[string]StatusInfoSchedAction) for _, e := range t.Schedules() { - ad := ExposedStatusInfoSchedAction{ + ad := StatusInfoSchedAction{ Last: e.LastRunAt, } data[e.Action] = ad @@ -1237,14 +1237,14 @@ func exposedStatusInfoSched(t Scheduler) map[string]ExposedStatusInfoSchedAction return data } -func (exposedStatus ExposedStatus) DeepCopy() *ExposedStatus { - newValue := ExposedStatus{} - if b, err := json.Marshal(exposedStatus); err != nil { - return &ExposedStatus{} +func (rstat Status) DeepCopy() *Status { + newValue := Status{} + if b, err := json.Marshal(rstat); err != nil { + return &Status{} } else if err := json.Unmarshal(b, &newValue); err == nil { return &newValue } - return &ExposedStatus{} + return &Status{} } func (t SCSIPersistentReservation) IsSCSIPersistentReservationPreemptAbortDisabled() bool { diff --git a/daemon/dns/main_cmd.go b/daemon/dns/main_cmd.go index d432730e5..cbb5b0641 100644 --- a/daemon/dns/main_cmd.go +++ b/daemon/dns/main_cmd.go @@ -127,7 +127,7 @@ func (t *dns) onInstanceStatusUpdated(c *msgbus.InstanceStatusUpdated) { }) } - stageSRVs := func(r resource.ExposedStatus) { + stageSRVs := func(r resource.Status) { i, ok := r.Info[exposeInfoKey] if !ok { return