Skip to content

Commit

Permalink
optimize & use starting ordinal for pvcs too
Browse files Browse the repository at this point in the history
  • Loading branch information
vimystic committed Nov 20, 2024
1 parent 62db355 commit b9ccbfa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/v1/cosmosfullnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CosmosFullNodeController = "CosmosFullNode"
type Ordinal struct {
// Start specifies the initial ordinal number for pod naming
// +kubebuilder:validation:Minimum:=0
Start *int32 `json:"start,omitempty"`
Start int32 `json:"start,omitempty"`
}

// FullNodeSpec defines the desired state of CosmosFullNode
Expand Down
7 changes: 1 addition & 6 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions controllers/cosmosfullnode_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ func (r *CosmosFullNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reque
return stopResult, client.IgnoreNotFound(err)
}

startingOrdinal := int32(0)
if crd.Spec.Ordinal.Start != nil {
startingOrdinal = *crd.Spec.Ordinal.Start
}

reporter := kube.NewEventReporter(logger, r.recorder, crd)

fullnode.ResetStatus(crd)
Expand Down Expand Up @@ -179,7 +174,7 @@ func (r *CosmosFullNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}

// Reconcile pods.
podRequeue, err := r.podControl.Reconcile(ctx, reporter, crd, configCksums, syncInfo, startingOrdinal)
podRequeue, err := r.podControl.Reconcile(ctx, reporter, crd, configCksums, syncInfo, crd.Spec.Ordinal.Start)
if err != nil {
errs.Append(err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/fullnode/pvc_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func BuildPVCs(
}

var pvcs []diff.Resource[*corev1.PersistentVolumeClaim]
for i := int32(0); i < crd.Spec.Replicas; i++ {
for i := crd.Spec.Ordinal.Start; i < crd.Spec.Ordinal.Start+crd.Spec.Replicas; i++ {
if pvcDisabled(crd, i) {
continue
}
Expand Down

0 comments on commit b9ccbfa

Please sign in to comment.