Skip to content

Commit

Permalink
Remove deprecated EO Secret methods (#10993)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Scholz <[email protected]>
  • Loading branch information
scholzj authored Dec 27, 2024
1 parent 416c5da commit ccc564a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public Future<Void> 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))
Expand Down Expand Up @@ -342,19 +341,6 @@ protected Future<Void> 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<Void> deleteOldEntityOperatorSecret() {
return secretOperator
.reconcile(reconciliation, reconciliation.namespace(), KafkaResources.entityOperatorSecretName(reconciliation.name()), null)
.map((Void) null);
}

/**
* Manages the Topic Operator certificates Secret.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<Secret> operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> toSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> uoSecretCaptor = ArgumentCaptor.forClass(Secret.class);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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<Secret> operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> toSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> uoSecretCaptor = ArgumentCaptor.forClass(Secret.class);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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<Secret> operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> toSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture());
if (cruiseControlEnabled) {
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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<Secret> operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> toSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> uoSecretCaptor = ArgumentCaptor.forClass(Secret.class);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -535,8 +518,6 @@ public void reconcileWithoutUoAndTo(VertxTestContext context) {
ArgumentCaptor<ServiceAccount> saCaptor = ArgumentCaptor.forClass(ServiceAccount.class);
when(mockSaOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorDeploymentName(NAME)), saCaptor.capture())).thenReturn(Future.succeededFuture());

ArgumentCaptor<Secret> operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> toSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> uoSecretCaptor = ArgumentCaptor.forClass(Secret.class);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -628,8 +607,6 @@ public void reconcileWithoutEo(VertxTestContext context) {
ArgumentCaptor<ServiceAccount> saCaptor = ArgumentCaptor.forClass(ServiceAccount.class);
when(mockSaOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorDeploymentName(NAME)), saCaptor.capture())).thenReturn(Future.succeededFuture());

ArgumentCaptor<Secret> operatorSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityOperatorSecretName(NAME)), operatorSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> toSecretCaptor = ArgumentCaptor.forClass(Secret.class);
when(mockSecretOps.reconcile(any(), eq(NAMESPACE), eq(KafkaResources.entityTopicOperatorSecretName(NAME)), toSecretCaptor.capture())).thenReturn(Future.succeededFuture());
ArgumentCaptor<Secret> uoSecretCaptor = ArgumentCaptor.forClass(Secret.class);
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit ccc564a

Please sign in to comment.