From 804e076cfb22233fe7b8b1c8474fc7156e5b92f7 Mon Sep 17 00:00:00 2001 From: vimystic <122659254+vimystic@users.noreply.github.com> Date: Tue, 19 Nov 2024 22:18:19 -0700 Subject: [PATCH] Update to use starting ordinal in appropriate files --- internal/fullnode/configmap_builder.go | 2 +- internal/fullnode/node_key_builder.go | 2 +- internal/fullnode/peer_collector.go | 2 +- internal/fullnode/pvc_control.go | 2 +- internal/fullnode/service_builder.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/fullnode/configmap_builder.go b/internal/fullnode/configmap_builder.go index af9bbb51..74249158 100644 --- a/internal/fullnode/configmap_builder.go +++ b/internal/fullnode/configmap_builder.go @@ -31,7 +31,7 @@ func BuildConfigMaps(crd *cosmosv1.CosmosFullNode, peers Peers) ([]diff.Resource defer bufPool.Put(buf) defer buf.Reset() - for i := int32(0); i < crd.Spec.Replicas; i++ { + for i := crd.Spec.Ordinal.Start; i < crd.Spec.Ordinal.Start+crd.Spec.Replicas; i++ { data := make(map[string]string) instance := instanceName(crd, i) if err := addConfigToml(buf, data, crd, instance, peers); err != nil { diff --git a/internal/fullnode/node_key_builder.go b/internal/fullnode/node_key_builder.go index 3ed330b8..e610be90 100644 --- a/internal/fullnode/node_key_builder.go +++ b/internal/fullnode/node_key_builder.go @@ -21,7 +21,7 @@ const nodeKeyFile = "node_key.json" // Returns an error if a new node key cannot be serialized. (Should never happen.) func BuildNodeKeySecrets(existing []*corev1.Secret, crd *cosmosv1.CosmosFullNode) ([]diff.Resource[*corev1.Secret], error) { secrets := make([]diff.Resource[*corev1.Secret], crd.Spec.Replicas) - for i := int32(0); i < crd.Spec.Replicas; i++ { + for i := crd.Spec.Ordinal.Start; i < crd.Spec.Ordinal.Start+crd.Spec.Replicas; i++ { var s corev1.Secret s.Name = nodeKeySecretName(crd, i) s.Namespace = crd.Namespace diff --git a/internal/fullnode/peer_collector.go b/internal/fullnode/peer_collector.go index 37c27c3a..555ef803 100644 --- a/internal/fullnode/peer_collector.go +++ b/internal/fullnode/peer_collector.go @@ -110,7 +110,7 @@ func (c PeerCollector) Collect(ctx context.Context, crd *cosmosv1.CosmosFullNode if crd.Spec.Service.ClusterDomain != nil { clusterDomain = *crd.Spec.Service.ClusterDomain } - for i := int32(0); i < crd.Spec.Replicas; i++ { + for i := crd.Spec.Ordinal.Start; i < crd.Spec.Ordinal.Start+crd.Spec.Replicas; i++ { secretName := nodeKeySecretName(crd, i) var secret corev1.Secret // Hoping the caching layer kubebuilder prevents API errors or rate limits. Simplifies logic to use a Get here diff --git a/internal/fullnode/pvc_control.go b/internal/fullnode/pvc_control.go index 6786f377..588daa2b 100644 --- a/internal/fullnode/pvc_control.go +++ b/internal/fullnode/pvc_control.go @@ -51,7 +51,7 @@ func (control PVCControl) Reconcile(ctx context.Context, reporter kube.Reporter, dataSources := make(map[int32]*dataSource) if len(currentPVCs) < int(crd.Spec.Replicas) { - for i := int32(0); i < crd.Spec.Replicas; i++ { + for i := crd.Spec.Ordinal.Start; i < crd.Spec.Ordinal.Start+crd.Spec.Replicas; i++ { name := pvcName(crd, i) found := false for _, pvc := range currentPVCs { diff --git a/internal/fullnode/service_builder.go b/internal/fullnode/service_builder.go index 2831a12a..db534553 100644 --- a/internal/fullnode/service_builder.go +++ b/internal/fullnode/service_builder.go @@ -32,7 +32,7 @@ func BuildServices(crd *cosmosv1.CosmosFullNode) []diff.Resource[*corev1.Service maxExternal := lo.Clamp(max, 0, crd.Spec.Replicas) p2ps := make([]diff.Resource[*corev1.Service], crd.Spec.Replicas) - for i := int32(0); i < crd.Spec.Replicas; i++ { + for i := crd.Spec.Ordinal.Start; i < crd.Spec.Ordinal.Start+crd.Spec.Replicas; i++ { ordinal := i var svc corev1.Service svc.Name = p2pServiceName(crd, ordinal)