diff --git a/pkg/resources/cruisecontrol/topicManager.go b/pkg/resources/cruisecontrol/topicManager.go index 00b895f1df..9e38da9afa 100644 --- a/pkg/resources/cruisecontrol/topicManager.go +++ b/pkg/resources/cruisecontrol/topicManager.go @@ -99,7 +99,7 @@ func generateCCTopic(cluster *v1beta1.KafkaCluster, client client.Client, log lo return errorfactory.New(errorfactory.ResourceNotReady{}, err, "topic admission failed to connect to kafka cluster") } // If less than the required brokers are available - return not ready - if webhooks.IsInvalidReplicationFactor(err) { + if webhooks.IsAdmissionInvalidReplicationFactor(err) { return errorfactory.New(errorfactory.ResourceNotReady{}, err, fmt.Sprintf("not enough brokers available (at least %d needed) for CC topic", topic.Spec.ReplicationFactor)) } return errorfactory.New(errorfactory.APIFailure{}, err, "could not create cruise control topic") diff --git a/pkg/webhooks/errors.go b/pkg/webhooks/errors.go index 40b8194528..2316b6aab7 100644 --- a/pkg/webhooks/errors.go +++ b/pkg/webhooks/errors.go @@ -40,7 +40,7 @@ func IsAdmissionCantConnectAPIServer(err error) bool { return apierrors.IsInternalError(err) && strings.Contains(err.Error(), cantConnectAPIServerMsg) } -func IsInvalidReplicationFactor(err error) bool { +func IsAdmissionInvalidReplicationFactor(err error) bool { return apierrors.IsInvalid(err) && strings.Contains(err.Error(), invalidReplicationFactorErrMsg) } diff --git a/pkg/webhooks/errors_test.go b/pkg/webhooks/errors_test.go index c744532eff..561b2cc588 100644 --- a/pkg/webhooks/errors_test.go +++ b/pkg/webhooks/errors_test.go @@ -55,17 +55,17 @@ func TestIsInvalidReplicationFactor(t *testing.T) { kafkaTopic.GetObjectKind().GroupVersionKind().GroupKind(), kafkaTopic.Name, fieldErrs) - if !IsInvalidReplicationFactor(err) { + if !IsAdmissionInvalidReplicationFactor(err) { t.Error("Expected is invalid replication error to be true, got false") } err = apierrors.NewServiceUnavailable("some other reason") - if IsInvalidReplicationFactor(err) { + if IsAdmissionInvalidReplicationFactor(err) { t.Error("Expected is invalid replication error to be false, got true") } err = apierrors.NewServiceUnavailable(invalidReplicationFactorErrMsg) - if IsInvalidReplicationFactor(err) { + if IsAdmissionInvalidReplicationFactor(err) { t.Error("Expected is invalid replication error to be false, got true") } }