Skip to content

Commit

Permalink
Remove getPodName() method from AbstractModel (#10397)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Scholz <www@scholzj.com>
  • Loading branch information
scholzj authored Jul 28, 2024
1 parent 9ce1d77 commit fa227ce
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,6 @@ public String getCluster() {
return cluster;
}

/**
* Gets the name of a given pod in a StrimziPodSet.
*
* @param podId The ID (ordinal) of the pod.
* @return The name of the pod with the given name.
*/
public String getPodName(Integer podId) {
return componentName + "-" + podId;
}

/**
* @param cluster The cluster name
* @return The name of the Cluster CA certificate secret.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public StrimziPodSet generatePodSet(int replicas,
labels.strimziSelectorLabels().withStrimziPodSetController(componentName),
podId -> WorkloadUtils.createStatefulPod(
reconciliation,
getPodName(podId),
componentName + "-" + podId,
namespace,
labels,
componentName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public StrimziPodSet generatePodSet(int replicas,
labels.strimziSelectorLabels(),
podNum -> WorkloadUtils.createStatefulPod(
reconciliation,
getPodName(podNum),
KafkaResources.zookeeperPodName(cluster, podNum),
namespace,
labels,
componentName,
Expand All @@ -425,7 +425,7 @@ public StrimziPodSet generatePodSet(int replicas,
templatePod != null ? templatePod.getAffinity() : null,
null,
List.of(createContainer(imagePullPolicy)),
getPodSetVolumes(getPodName(podNum), isOpenShift),
getPodSetVolumes(KafkaResources.zookeeperPodName(cluster, podNum), isOpenShift),
imagePullSecrets,
securityProvider.zooKeeperPodSecurityContext(new PodSecurityProviderContextImpl(storage, templatePod))
)
Expand Down Expand Up @@ -636,7 +636,7 @@ public Set<NodeRef> nodes() {
Set<NodeRef> nodes = new LinkedHashSet<>();

for (int i = 0; i < replicas; i++) {
nodes.add(new NodeRef(getPodName(i), i, null, false, false));
nodes.add(new NodeRef(KafkaResources.zookeeperPodName(cluster, i), i, null, false, false));
}

return nodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@ private Future<Void> scaleDownDeployment(int replicas) {
private Future<Void> scaleUpStrimziPodSet(int replicas) {
LOGGER.infoCr(reconciliation, "Scaling up StrimziPodSet {}", connect.getComponentName());
return podSetOperator.reconcile(reconciliation, reconciliation.namespace(), connect.getComponentName(), connect.generatePodSet(replicas, controllerAnnotations, podAnnotations, isOpenshift, imagePullPolicy, imagePullSecrets, customContainerImage))
.compose(i -> podOperator.readiness(reconciliation, reconciliation.namespace(), connect.getPodName(replicas - 1), 1_000, operationTimeoutMs));
.compose(i -> podOperator.readiness(reconciliation, reconciliation.namespace(), connect.getComponentName() + "-" + (replicas - 1), 1_000, operationTimeoutMs));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class KafkaClusterPodSetTest {

@ParallelTest
public void testPodSet() {
StrimziPodSet ps = KC.generatePodSets(true, null, null, brokerId -> Map.of("test-anno", KC.getPodName(brokerId))).get(0);
StrimziPodSet ps = KC.generatePodSets(true, null, null, brokerId -> Map.of("test-anno", KafkaResources.kafkaPodName(CLUSTER, brokerId))).get(0);

assertThat(ps.getMetadata().getName(), is(KafkaResources.kafkaComponentName(CLUSTER)));
assertThat(ps.getMetadata().getLabels().entrySet().containsAll(KC.labels.withAdditionalLabels(null).toMap().entrySet()), is(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,14 +751,6 @@ public void testPerBrokerConfiguration() {
assertThat(config, CoreMatchers.containsString("advertised.listeners=CONTROLPLANE-9090://foo-kafka-1.foo-kafka-brokers.test.svc:9090,REPLICATION-9091://foo-kafka-1.foo-kafka-brokers.test.svc:9091,PLAIN-9092://broker-1:9092,TLS-9093://broker-1:10001\n"));
}

@ParallelTest
public void testPodNames() {

for (int i = 0; i < REPLICAS; i++) {
assertThat(KC.getPodName(i), is(KafkaResources.kafkaComponentName(CLUSTER) + "-" + i));
}
}

@ParallelTest
public void testPvcNames() {
Kafka kafkaAssembly = new KafkaBuilder(KAFKA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,6 @@ public void testInvalidVersion() {
});
}

@ParallelTest
public void testPodNames() {
for (int i = 0; i < REPLICAS; i++) {
assertThat(ZC.getPodName(i), is(KafkaResources.zookeeperPodName(CLUSTER, i)));
}
}

@ParallelTest
public void testPvcNames() {
Kafka ka = new KafkaBuilder(KAFKA)
Expand Down

0 comments on commit fa227ce

Please sign in to comment.