Skip to content

Commit

Permalink
Update to use starting ordinal in appropriate files
Browse files Browse the repository at this point in the history
  • Loading branch information
vimystic committed Nov 20, 2024
1 parent b9ccbfa commit 804e076
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/fullnode/configmap_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/fullnode/node_key_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/fullnode/peer_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/fullnode/pvc_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/fullnode/service_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 804e076

Please sign in to comment.