KafkaSetOperator extends StatefulSetOperator { public static boolean needsRollingUpdate(StatefulSetDiff diff) { if (diff.changesLabels()) { log.debug("Changed labels => needs rolling update"); return true; } if (diff.changesSpecTemplate()) { log.debug("Changed template spec => needs rolling update"); return true; } if (diff.changesVolumeClaimTemplates()) { log.debug("Changed volume claim template => needs rolling update"); return true; } if (diff.changesVolumeSize()) { log.debug("Changed size of the volume claim template => no need for rolling update"); return false; } return false; } KafkaSetOperator(Vertx vertx, KubernetesClient client, long operationTimeoutMs,
                            AdminClientProvider adminClientProvider); static boolean needsRollingUpdate(StatefulSetDiff diff); @Override Future<Void> maybeRollingUpdate(StatefulSet sts, Function<Pod, List<String>> podNeedsRestart); @Override Future<Void> maybeRollingUpdate(StatefulSet sts, Function<Pod, List<String>> podNeedsRestart,
                                           Secret clusterCaCertSecret, Secret coKeySecret);  }
@Test public void testNotNeedsRollingUpdateWhenIdentical() { assertThat(KafkaSetOperator.needsRollingUpdate(createDiff()), is(false)); }
@Test public void testNotNeedsRollingUpdateWhenReplicasDecrease() { currectSts.getSpec().setReplicas(desiredSts.getSpec().getReplicas() + 1); assertThat(KafkaSetOperator.needsRollingUpdate(createDiff()), is(false)); }
@Test public void testNeedsRollingUpdateWhenLabelsRemoved() { Map<String, String> labels = new HashMap(desiredSts.getMetadata().getLabels()); labels.put("foo", "bar"); currectSts.getMetadata().setLabels(labels); assertThat(KafkaSetOperator.needsRollingUpdate(createDiff()), is(true)); }
@Test public void testNeedsRollingUpdateWhenImageChanges() { String newImage = currectSts.getSpec().getTemplate().getSpec().getContainers().get(0).getImage() + "-foo"; currectSts.getSpec().getTemplate().getSpec().getContainers().get(0).setImage(newImage); assertThat(KafkaSetOperator.needsRollingUpdate(createDiff()), is(true)); }
@Test public void testNeedsRollingUpdateWhenReadinessDelayChanges() { Integer newDelay = currectSts.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getInitialDelaySeconds() + 1; currectSts.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().setInitialDelaySeconds(newDelay); assertThat(KafkaSetOperator.needsRollingUpdate(createDiff()), is(true)); }
@Test public void testNeedsRollingUpdateWhenReadinessTimeoutChanges() { Integer newTimeout = currectSts.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getTimeoutSeconds() + 1; currectSts.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().setTimeoutSeconds(newTimeout); assertThat(KafkaSetOperator.needsRollingUpdate(createDiff()), is(true)); }
@Test public void testNeedsRollingUpdateWhenNewEnvRemoved() { String envVar = "SOME_RANDOM_ENV"; currectSts.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().add(new EnvVar(envVar, "foo", null)); assertThat(KafkaSetOperator.needsRollingUpdate(createDiff()), is(true)); }