diff --git a/controllers/ytsaurus_local_test.go b/controllers/ytsaurus_local_test.go index 662d925c..debf5cc9 100644 --- a/controllers/ytsaurus_local_test.go +++ b/controllers/ytsaurus_local_test.go @@ -6,6 +6,8 @@ import ( "testing" "time" + "k8s.io/utils/ptr" + "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -56,6 +58,11 @@ func TestYtsaurusFromScratch(t *testing.T) { defer h.Stop() ytsaurusResource := testutil.BuildMinimalYtsaurus(namespace, ytsaurusName) + // FIXME(khlebnikov): This test is broken by design. + ytsaurusResource.Spec.PrimaryMasters.MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.Discovery.MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.HTTPProxies[0].MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.DataNodes[0].MinReadyInstanceCount = ptr.To(0) testutil.DeployObject(h, &ytsaurusResource) for _, compName := range []string{ @@ -109,6 +116,11 @@ func TestYtsaurusUpdateStatelessComponent(t *testing.T) { defer h.Stop() ytsaurusResource := testutil.BuildMinimalYtsaurus(namespace, ytsaurusName) + // FIXME(khlebnikov): This test is broken by design. + ytsaurusResource.Spec.PrimaryMasters.MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.Discovery.MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.HTTPProxies[0].MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.DataNodes[0].MinReadyInstanceCount = ptr.To(0) testutil.DeployObject(h, &ytsaurusResource) waitClusterState(h, ytv1.ClusterStateRunning) @@ -132,6 +144,11 @@ func TestYtsaurusUpdateMasterBlocked(t *testing.T) { defer h.Stop() ytsaurusResource := testutil.BuildMinimalYtsaurus(namespace, ytsaurusName) + // FIXME(khlebnikov): This test is broken by design. + ytsaurusResource.Spec.PrimaryMasters.MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.Discovery.MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.HTTPProxies[0].MinReadyInstanceCount = ptr.To(0) + ytsaurusResource.Spec.DataNodes[0].MinReadyInstanceCount = ptr.To(0) testutil.DeployObject(h, &ytsaurusResource) waitClusterState(h, ytv1.ClusterStateRunning) diff --git a/pkg/components/server.go b/pkg/components/server.go index 4b789f10..cb64263a 100644 --- a/pkg/components/server.go +++ b/pkg/components/server.go @@ -251,7 +251,7 @@ func (s *serverImpl) needUpdate() bool { } func (s *serverImpl) arePodsReady(ctx context.Context) bool { - return s.statefulSet.ArePodsReady(ctx, s.instanceSpec.MinReadyInstanceCount) + return s.statefulSet.ArePodsReady(ctx, int(s.instanceSpec.InstanceCount), s.instanceSpec.MinReadyInstanceCount) } func (s *serverImpl) buildStatefulSet() *appsv1.StatefulSet { diff --git a/pkg/resources/statefulset.go b/pkg/resources/statefulset.go index e01d6535..b9911d97 100644 --- a/pkg/resources/statefulset.go +++ b/pkg/resources/statefulset.go @@ -100,15 +100,15 @@ func (s *StatefulSet) ArePodsRemoved(ctx context.Context) bool { return true } -func (s *StatefulSet) ArePodsReady(ctx context.Context, minReadyInstanceCount *int) bool { +func (s *StatefulSet) ArePodsReady(ctx context.Context, instanceCount int, minReadyInstanceCount *int) bool { logger := log.FromContext(ctx) podList := s.getPods(ctx) if podList == nil { return false } - effectiveMinReadyInstanceCount := len(podList.Items) - if minReadyInstanceCount != nil && *minReadyInstanceCount < len(podList.Items) { + effectiveMinReadyInstanceCount := instanceCount + if minReadyInstanceCount != nil && *minReadyInstanceCount < instanceCount { effectiveMinReadyInstanceCount = *minReadyInstanceCount }