From ccc564a809a6c959f26f73ba08ecbca74bc0eaf9 Mon Sep 17 00:00:00 2001 From: Jakub Scholz Date: Fri, 27 Dec 2024 12:17:03 +0100 Subject: [PATCH] Remove deprecated EO Secret methods (#10993) Signed-off-by: Jakub Scholz --- .../api/kafka/model/kafka/KafkaResources.java | 16 ------------ .../assembly/EntityOperatorReconciler.java | 14 ----------- .../EntityOperatorReconcilerTest.java | 25 ------------------- 3 files changed, 55 deletions(-) diff --git a/api/src/main/java/io/strimzi/api/kafka/model/kafka/KafkaResources.java b/api/src/main/java/io/strimzi/api/kafka/model/kafka/KafkaResources.java index 332be67b8db..1ccd985cfa8 100644 --- a/api/src/main/java/io/strimzi/api/kafka/model/kafka/KafkaResources.java +++ b/api/src/main/java/io/strimzi/api/kafka/model/kafka/KafkaResources.java @@ -261,22 +261,6 @@ public static String entityOperatorDeploymentName(String clusterName) { return clusterName + "-entity-operator"; } - /** - * Returns the name of the Entity Operator {@code Secret} for a {@code Kafka} cluster of the given name. - * This {@code Secret} will only exist if {@code Kafka.spec.entityOperator} is configured in the - * {@code Kafka} resource with the given name. - * - * This secret is not used anymore and is deprecated. This method will be removed in the future. - * - * @param clusterName The {@code metadata.name} of the {@code Kafka} resource. - * - * @return The name of the corresponding Entity Operator {@code Secret}. - */ - @Deprecated - public static String entityOperatorSecretName(String clusterName) { - return entityOperatorDeploymentName(clusterName) + "-certs"; - } - //////// // Entity Topic Operator methods //////// diff --git a/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/EntityOperatorReconciler.java b/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/EntityOperatorReconciler.java index 60e8ead1056..6efc3178e01 100644 --- a/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/EntityOperatorReconciler.java +++ b/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/EntityOperatorReconciler.java @@ -116,7 +116,6 @@ public Future reconcile(boolean isOpenShift, ImagePullPolicy imagePullPoli .compose(i -> topicOperatorConfigMap()) .compose(i -> userOperatorConfigMap()) .compose(i -> topicOperatorCruiseControlApiSecret()) - .compose(i -> deleteOldEntityOperatorSecret()) .compose(i -> topicOperatorSecret(clock)) .compose(i -> userOperatorSecret(clock)) .compose(i -> deployment(isOpenShift, imagePullPolicy, imagePullSecrets)) @@ -342,19 +341,6 @@ protected Future userOperatorConfigMap() { } } - /** - * Deletes the Entity Operator secret. This Secret was used in the past when both Topic and User operators were - * using the same user account. It is not used anymore, but we delete it if it exists from previous version. - * - * @return Future which completes when the reconciliation is done - */ - @SuppressWarnings("deprecation") - protected Future deleteOldEntityOperatorSecret() { - return secretOperator - .reconcile(reconciliation, reconciliation.namespace(), KafkaResources.entityOperatorSecretName(reconciliation.name()), null) - .map((Void) null); - } - /** * Manages the Topic Operator certificates Secret. * diff --git a/cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/EntityOperatorReconcilerTest.java b/cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/EntityOperatorReconcilerTest.java index ad4dd7b9d22..4468c4dad25 100644 --- a/cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/EntityOperatorReconcilerTest.java +++ b/cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/EntityOperatorReconcilerTest.java @@ -55,7 +55,6 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; -@SuppressWarnings("deprecation") // Because of deprecated KafkaResources.entityOperatorSecretName @ExtendWith(VertxExtension.class) public class EntityOperatorReconcilerTest { private static final String NAMESPACE = "namespace"; @@ -103,8 +102,6 @@ public void reconcileWithToAndUo(VertxTestContext context) { when(mockSecretOps.getAsync(eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)))).thenReturn(Future.succeededFuture()); when(mockSecretOps.getAsync(eq(NAMESPACE), eq(KafkaResources.entityUserOperatorSecretName(NAME)))).thenReturn(Future.succeededFuture()); - ArgumentCaptor operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class); - when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor toSecretCaptor = ArgumentCaptor.forClass(Secret.class); when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor uoSecretCaptor = ArgumentCaptor.forClass(Secret.class); @@ -156,8 +153,6 @@ public void reconcileWithToAndUo(VertxTestContext context) { assertThat(saCaptor.getAllValues().size(), is(1)); assertThat(saCaptor.getValue(), is(notNullValue())); - assertThat(operatorSecretCaptor.getAllValues().size(), is(1)); - assertThat(operatorSecretCaptor.getAllValues().get(0), is(nullValue())); assertThat(toSecretCaptor.getAllValues().size(), is(1)); assertThat(toSecretCaptor.getAllValues().get(0), is(notNullValue())); assertThat(uoSecretCaptor.getAllValues().size(), is(1)); @@ -208,8 +203,6 @@ public void reconcileWithToAndUoAndWatchNamespaces(VertxTestContext context) { when(mockSecretOps.getAsync(eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)))).thenReturn(Future.succeededFuture()); when(mockSecretOps.getAsync(eq(NAMESPACE), eq(KafkaResources.entityUserOperatorSecretName(NAME)))).thenReturn(Future.succeededFuture()); - ArgumentCaptor operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class); - when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor toSecretCaptor = ArgumentCaptor.forClass(Secret.class); when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor uoSecretCaptor = ArgumentCaptor.forClass(Secret.class); @@ -269,8 +262,6 @@ public void reconcileWithToAndUoAndWatchNamespaces(VertxTestContext context) { assertThat(saCaptor.getAllValues().size(), is(1)); assertThat(saCaptor.getValue(), is(notNullValue())); - assertThat(operatorSecretCaptor.getAllValues().size(), is(1)); - assertThat(operatorSecretCaptor.getAllValues().get(0), is(nullValue())); assertThat(toSecretCaptor.getAllValues().size(), is(1)); assertThat(toSecretCaptor.getAllValues().get(0), is(notNullValue())); assertThat(uoSecretCaptor.getAllValues().size(), is(1)); @@ -325,8 +316,6 @@ public void reconcileWithToOnly(boolean cruiseControlEnabled, VertxTestContext c when(mockSaOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorDeploymentName(NAME)), saCaptor.capture())).thenReturn(Future.succeededFuture()); when(mockSecretOps.getAsync(eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)))).thenReturn(Future.succeededFuture()); - ArgumentCaptor operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class); - when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor toSecretCaptor = ArgumentCaptor.forClass(Secret.class); when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture()); if (cruiseControlEnabled) { @@ -383,8 +372,6 @@ public void reconcileWithToOnly(boolean cruiseControlEnabled, VertxTestContext c assertThat(saCaptor.getAllValues().size(), is(1)); assertThat(saCaptor.getValue(), is(notNullValue())); - assertThat(operatorSecretCaptor.getAllValues().size(), is(1)); - assertThat(operatorSecretCaptor.getAllValues().get(0), is(nullValue())); if (cruiseControlEnabled) { assertThat(toSecretCaptor.getAllValues().size(), is(2)); assertThat(toSecretCaptor.getAllValues().get(0), is(notNullValue())); @@ -437,8 +424,6 @@ public void reconcileWithUoOnly(VertxTestContext context) { when(mockSaOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorDeploymentName(NAME)), saCaptor.capture())).thenReturn(Future.succeededFuture()); when(mockSecretOps.getAsync(eq(NAMESPACE), eq(KafkaResources.entityUserOperatorSecretName(NAME)))).thenReturn(Future.succeededFuture()); - ArgumentCaptor operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class); - when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor toSecretCaptor = ArgumentCaptor.forClass(Secret.class); when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor uoSecretCaptor = ArgumentCaptor.forClass(Secret.class); @@ -488,8 +473,6 @@ public void reconcileWithUoOnly(VertxTestContext context) { assertThat(saCaptor.getAllValues().size(), is(1)); assertThat(saCaptor.getValue(), is(notNullValue())); - assertThat(operatorSecretCaptor.getAllValues().size(), is(1)); - assertThat(operatorSecretCaptor.getAllValues().get(0), is(nullValue())); assertThat(toSecretCaptor.getAllValues().size(), is(1)); assertThat(toSecretCaptor.getAllValues().get(0), is(nullValue())); assertThat(uoSecretCaptor.getAllValues().size(), is(1)); @@ -535,8 +518,6 @@ public void reconcileWithoutUoAndTo(VertxTestContext context) { ArgumentCaptor saCaptor = ArgumentCaptor.forClass(ServiceAccount.class); when(mockSaOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorDeploymentName(NAME)), saCaptor.capture())).thenReturn(Future.succeededFuture()); - ArgumentCaptor operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class); - when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor toSecretCaptor = ArgumentCaptor.forClass(Secret.class); when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor uoSecretCaptor = ArgumentCaptor.forClass(Secret.class); @@ -584,8 +565,6 @@ public void reconcileWithoutUoAndTo(VertxTestContext context) { assertThat(saCaptor.getAllValues().size(), is(1)); assertThat(saCaptor.getValue(), is(nullValue())); - assertThat(operatorSecretCaptor.getAllValues().size(), is(1)); - assertThat(operatorSecretCaptor.getAllValues().get(0), is(nullValue())); assertThat(toSecretCaptor.getAllValues().size(), is(1)); assertThat(toSecretCaptor.getAllValues().get(0), is(nullValue())); assertThat(uoSecretCaptor.getAllValues().size(), is(1)); @@ -628,8 +607,6 @@ public void reconcileWithoutEo(VertxTestContext context) { ArgumentCaptor saCaptor = ArgumentCaptor.forClass(ServiceAccount.class); when(mockSaOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorDeploymentName(NAME)), saCaptor.capture())).thenReturn(Future.succeededFuture()); - ArgumentCaptor operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class); - when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor toSecretCaptor = ArgumentCaptor.forClass(Secret.class); when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture()); ArgumentCaptor uoSecretCaptor = ArgumentCaptor.forClass(Secret.class); @@ -670,8 +647,6 @@ public void reconcileWithoutEo(VertxTestContext context) { assertThat(saCaptor.getAllValues().size(), is(1)); assertThat(saCaptor.getValue(), is(nullValue())); - assertThat(operatorSecretCaptor.getAllValues().size(), is(1)); - assertThat(operatorSecretCaptor.getAllValues().get(0), is(nullValue())); assertThat(toSecretCaptor.getAllValues().size(), is(1)); assertThat(toSecretCaptor.getAllValues().get(0), is(nullValue())); assertThat(uoSecretCaptor.getAllValues().size(), is(1));