Skip to content

Commit

Permalink
another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
birdayz committed Sep 26, 2024
1 parent 9841584 commit e7b94a0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
3 changes: 2 additions & 1 deletion operator/internal/controller/redpanda/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ func (r *ClusterReconciler) Reconcile(
}

if err = r.setPodNodeIDAnnotation(ctx, &vectorizedCluster, log, ar); err != nil {
log.Error(err, "setting pod node_id annotation")
// Setting NodeID annotations is best-effort. Log the error, but don't fail because of it.
log.Error(err, "failed to set node_id annotation")
}

result, errs := ar.Ensure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package test

import (
"context"
"fmt"
"time"

. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -70,7 +69,7 @@ var _ = Describe("Redpanda cluster scale resource", func() {
})

Context("When scaling down a cluster", func() {
FIt("Should always decommission the last pods of a cluster one at time", func() {
It("Should always decommission the last pods of a cluster one at time", func() {
By("Allowing creation of a new cluster with 3 replicas")
key, redpandaCluster := getClusterWithReplicas("decommission", 3)
Expect(k8sClient.Create(context.Background(), redpandaCluster)).Should(Succeed())
Expand All @@ -81,7 +80,6 @@ var _ = Describe("Redpanda cluster scale resource", func() {
testAdminAPI.AddBroker(rpadmin.Broker{NodeID: 2, MembershipStatus: rpadmin.MembershipStatusActive})
var sts appsv1.StatefulSet
Eventually(resourceDataGetter(key, &sts, func() interface{} {
fmt.Println("ready", sts.Status.ReadyReplicas)
return *sts.Spec.Replicas
}), timeout, interval).Should(Equal(int32(3)))
Eventually(resourceDataGetter(key, redpandaCluster, func() interface{} {
Expand All @@ -96,7 +94,6 @@ var _ = Describe("Redpanda cluster scale resource", func() {

By("Start decommissioning node with ordinal 2")
Eventually(resourceDataGetter(key, redpandaCluster, func() interface{} {
fmt.Println("XXXXXXX", "ready", redpandaCluster.Status.NodePools["default"].ReadyReplicas)
if redpandaCluster.GetDecommissionBrokerID() == nil {
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions operator/internal/controller/test/cluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/redpanda-data/redpanda-operator/operator/api/vectorized/v1alpha1"
"github.com/redpanda-data/redpanda-operator/operator/pkg/labels"
res "github.com/redpanda-data/redpanda-operator/operator/pkg/resources"
)

Expand Down Expand Up @@ -920,6 +921,7 @@ func readyPodsForCluster(cluster *v1alpha1.Cluster) []*corev1.Pod {
"app.kubernetes.io/component": "redpanda",
"app.kubernetes.io/instance": cluster.Name,
"app.kubernetes.io/name": "redpanda",
labels.NodePoolKey: "default",
},
},
Spec: corev1.PodSpec{
Expand Down
10 changes: 0 additions & 10 deletions operator/pkg/resources/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,6 @@ func (r *StatefulSetResource) Ensure(ctx context.Context) error {
}
}

// Initialize NodePool status if not yet done.
// This is relevant for:
// - Migration cases, where a pre-nodepool operator was running so far.
// - New NodePool thast does not yet have a status.
if _, ok := r.pandaCluster.Status.NodePools[r.nodePool.Name]; !ok {
r.pandaCluster.Status.NodePools[r.nodePool.Name] = vectorizedv1alpha1.NodePoolStatus{
CurrentReplicas: ptr.Deref(r.nodePool.Replicas, 0), // Initial currentReplicas to desired replicas
}
}

obj, err := r.obj(ctx)
if err != nil {
return fmt.Errorf("unable to construct StatefulSet object: %w", err)
Expand Down

0 comments on commit e7b94a0

Please sign in to comment.