diff --git a/api/v1/cosmosfullnode_types.go b/api/v1/cosmosfullnode_types.go index 39fe5b79..e4cb7386 100644 --- a/api/v1/cosmosfullnode_types.go +++ b/api/v1/cosmosfullnode_types.go @@ -142,9 +142,9 @@ type FullNodeStatus struct { // +optional SyncInfo *SyncInfoStatus `json:"syncInfo,omitempty"` - // Startup information. collected when node starts up. + // Latest Height information. collected when node starts up and when RPC is successfully queried. // +optional - StartupHeight map[string]uint64 `json:"startupInfo,omitempty"` + Height map[string]uint64 `json:"height,omitempty"` } type SyncInfoStatus struct { diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 13c062cb..9e75954b 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -342,8 +342,8 @@ func (in *FullNodeStatus) DeepCopyInto(out *FullNodeStatus) { *out = new(SyncInfoStatus) (*in).DeepCopyInto(*out) } - if in.StartupHeight != nil { - in, out := &in.StartupHeight, &out.StartupHeight + if in.Height != nil { + in, out := &in.Height, &out.Height *out = make(map[string]uint64, len(*in)) for key, val := range *in { (*out)[key] = val diff --git a/cmd/versioncheck.go b/cmd/versioncheck.go index 2e32f19f..d5b8bf6b 100644 --- a/cmd/versioncheck.go +++ b/cmd/versioncheck.go @@ -105,11 +105,11 @@ func VersionCheckCmd(scheme *runtime.Scheme) *cobra.Command { height := store.LatestVersion() fmt.Printf("%d", height) - if crd.Status.StartupHeight == nil { - crd.Status.StartupHeight = make(map[string]uint64) + if crd.Status.Height == nil { + crd.Status.Height = make(map[string]uint64) } - crd.Status.StartupHeight[thisPod.Name] = uint64(height) + crd.Status.Height[thisPod.Name] = uint64(height) if err := kClient.Status().Update( ctx, crd, diff --git a/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml b/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml index 5ee7a58f..194ed51c 100644 --- a/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml +++ b/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml @@ -5937,6 +5937,13 @@ spec: status: description: FullNodeStatus defines the observed state of CosmosFullNode properties: + height: + additionalProperties: + format: int64 + type: integer + description: Latest Height information. collected when node starts + up and when RPC is successfully queried. + type: object observedGeneration: description: The most recent generation observed by the controller. format: int64 @@ -5995,12 +6002,6 @@ spec: - requestedSize type: object type: object - startupInfo: - additionalProperties: - format: int64 - type: integer - description: Startup information. collected when node starts up. - type: object status: description: A generic message for the user. May contain errors. type: string diff --git a/controllers/cosmosfullnode_controller.go b/controllers/cosmosfullnode_controller.go index 4c85e526..221cecfe 100644 --- a/controllers/cosmosfullnode_controller.go +++ b/controllers/cosmosfullnode_controller.go @@ -227,6 +227,14 @@ func (r *CosmosFullNodeReconciler) updateStatus(ctx context.Context, crd *cosmos status.StatusMessage = crd.Status.StatusMessage status.Peers = crd.Status.Peers status.SyncInfo = &consensus + for _, v := range consensus.Pods { + if v.Height != nil && *v.Height > 0 { + if status.Height == nil { + status.Height = make(map[string]uint64) + } + status.Height[v.Pod] = *v.Height + } + } }); err != nil { log.FromContext(ctx).Error(err, "Failed to patch status") } diff --git a/internal/fullnode/build_pods.go b/internal/fullnode/build_pods.go index 0c113893..d22027af 100644 --- a/internal/fullnode/build_pods.go +++ b/internal/fullnode/build_pods.go @@ -30,17 +30,8 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res } if len(crd.Spec.ChainSpec.Versions) > 0 { instanceHeight := uint64(0) - if startupHeight, ok := crd.Status.StartupHeight[pod.Name]; ok { - instanceHeight = startupHeight - } - for _, instance := range crd.Status.SyncInfo.Pods { - if instance.Pod == pod.Name { - if instance.Height == nil { - break - } - instanceHeight = *instance.Height - break - } + if height, ok := crd.Status.Height[pod.Name]; ok { + instanceHeight = height } var image string for _, version := range crd.Spec.ChainSpec.Versions { diff --git a/internal/fullnode/configmap_builder.go b/internal/fullnode/configmap_builder.go index f389c3c8..da49b57e 100644 --- a/internal/fullnode/configmap_builder.go +++ b/internal/fullnode/configmap_builder.go @@ -41,16 +41,8 @@ func BuildConfigMaps(crd *cosmosv1.CosmosFullNode, peers Peers) ([]diff.Resource appCfg := crd.Spec.ChainSpec.App if len(crd.Spec.ChainSpec.Versions) > 0 { instanceHeight := uint64(0) - if startupHeight, ok := crd.Status.StartupHeight[instance]; ok { - instanceHeight = startupHeight - } - for _, v := range crd.Status.SyncInfo.Pods { - if v.Pod == instance { - if v.Height != nil { - instanceHeight = *v.Height - } - break - } + if height, ok := crd.Status.Height[instance]; ok { + instanceHeight = height } haltHeight := uint64(0) for i, v := range crd.Spec.ChainSpec.Versions {