From 62db3553c8839ff05d1d833d7c91ed929bbf2778 Mon Sep 17 00:00:00 2001 From: vimystic <122659254+vimystic@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:37:03 -0700 Subject: [PATCH] Update: reorg so that we use a similar structure to stateful set instead of *imaginary* name --- api/v1/cosmosfullnode_types.go | 12 ++++++--- api/v1/zz_generated.deepcopy.go | 26 +++++++++++++++---- .../cosmos.strange.love_cosmosfullnodes.yaml | 16 +++++++----- controllers/cosmosfullnode_controller.go | 4 +-- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/api/v1/cosmosfullnode_types.go b/api/v1/cosmosfullnode_types.go index 88f5a56f..0e1bae31 100644 --- a/api/v1/cosmosfullnode_types.go +++ b/api/v1/cosmosfullnode_types.go @@ -32,14 +32,20 @@ const CosmosFullNodeController = "CosmosFullNode" // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. +// Ordinal specifies the configuration for pod ordinal numbers +type Ordinal struct { + // Start specifies the initial ordinal number for pod naming + // +kubebuilder:validation:Minimum:=0 + Start *int32 `json:"start,omitempty"` +} + // FullNodeSpec defines the desired state of CosmosFullNode type FullNodeSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file - // StartingOrdinal specifies the initial ordinal number for pod naming - // +kubebuilder:validation:Minimum:=0 - StartingOrdinal *int32 `json:"startingOrdinal,omitempty"` + // Ordinal specifies the configuration for pod ordinal numbers + Ordinal Ordinal `json:"ordinal,omitempty"` // Number of replicas to create. // Individual replicas have a consistent identity. diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 4c54a4ca..c83f6129 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -288,11 +288,7 @@ func (in *FullNodeSnapshotStatus) DeepCopy() *FullNodeSnapshotStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FullNodeSpec) DeepCopyInto(out *FullNodeSpec) { *out = *in - if in.StartingOrdinal != nil { - in, out := &in.StartingOrdinal, &out.StartingOrdinal - *out = new(int32) - **out = **in - } + in.Ordinal.DeepCopyInto(&out.Ordinal) in.ChainSpec.DeepCopyInto(&out.ChainSpec) in.PodTemplate.DeepCopyInto(&out.PodTemplate) in.RolloutStrategy.DeepCopyInto(&out.RolloutStrategy) @@ -457,6 +453,26 @@ func (in *Metadata) DeepCopy() *Metadata { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Ordinal) DeepCopyInto(out *Ordinal) { + *out = *in + if in.Start != nil { + in, out := &in.Start, &out.Start + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Ordinal. +func (in *Ordinal) DeepCopy() *Ordinal { + if in == nil { + return nil + } + out := new(Ordinal) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PVCAutoScaleSpec) DeepCopyInto(out *PVCAutoScaleSpec) { *out = *in diff --git a/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml b/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml index 67ad2d58..3dc55a10 100644 --- a/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml +++ b/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml @@ -555,6 +555,16 @@ spec: Example: cosmos-1 Used for debugging. type: object + ordinal: + description: Ordinal specifies the configuration for pod ordinal numbers + properties: + start: + description: Start specifies the initial ordinal number for pod + naming + format: int32 + minimum: 0 + type: integer + type: object podTemplate: description: |- Template applied to all pods. @@ -5783,12 +5793,6 @@ spec: type: string type: object type: object - startingOrdinal: - description: StartingOrdinal specifies the initial ordinal number - for pod naming - format: int32 - minimum: 0 - type: integer strategy: description: How to scale pods when performing an update. properties: diff --git a/controllers/cosmosfullnode_controller.go b/controllers/cosmosfullnode_controller.go index 580aa45e..02935680 100644 --- a/controllers/cosmosfullnode_controller.go +++ b/controllers/cosmosfullnode_controller.go @@ -116,8 +116,8 @@ func (r *CosmosFullNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reque } startingOrdinal := int32(0) - if crd.Spec.StartingOrdinal != nil { - startingOrdinal = *crd.Spec.StartingOrdinal + if crd.Spec.Ordinal.Start != nil { + startingOrdinal = *crd.Spec.Ordinal.Start } reporter := kube.NewEventReporter(logger, r.recorder, crd)