Skip to content

Commit 33bd9d4

Browse files
committed
restart pod if both patchable and non-patchable field changed
1 parent 7bce54a commit 33bd9d4

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

operator/src/main/java/oracle/kubernetes/operator/helpers/PodStepContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,14 @@ public NextAction apply(Packet packet) {
529529
V1Pod currentPod = getSko().getPod().get();
530530
if (currentPod == null) {
531531
return doNext(createNewPod(getNext()), packet);
532+
} else if (!canUseCurrentPod(currentPod)) {
533+
LOGGER.info(MessageKeys.CYCLING_POD, currentPod, getPodModel());
534+
return doNext(replaceCurrentPod(getNext()), packet);
532535
} else if (mustPatchPod(currentPod)) {
533536
return doNext(patchCurrentPod(currentPod, getNext()), packet);
534-
} else if (canUseCurrentPod(currentPod)) {
537+
} else {
535538
logPodExists();
536539
return doNext(packet);
537-
} else {
538-
LOGGER.info(MessageKeys.CYCLING_POD, currentPod, getPodModel());
539-
return doNext(replaceCurrentPod(getNext()), packet);
540540
}
541541
}
542542
}

operator/src/test/java/oracle/kubernetes/operator/helpers/PodHelperTestBase.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,13 @@ public void whenPodCustomerLabelHasBadValue_replaceIt() {
504504
"value");
505505
}
506506

507+
@Test
508+
public void whenPodLacksExpectedCustomerLabelAndRequestRequirement_replaceIt() {
509+
configurator.withPodLabel("expected.label", "value").withRequestRequirement("widgets", "10");
510+
511+
verifyReplacePodWhen(pod -> {});
512+
}
513+
507514
@Test
508515
public void whenPodHasUnknownCustomerAnnotations_ignoreIt() {
509516
verifyPodNotReplacedWhen(pod -> pod.getMetadata().putAnnotationsItem("annotation", "value"));

site/server-lifecycle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ The operator will restart servers when any of the follow properties on the domai
152152
* `volumes`
153153
* `volumeMounts`
154154

155+
**Note**: if the only change detected is the addition or modification of a domain-specified label or annotation,
156+
the operator will *patch* the server's pod rather than restarting it. Removing a label or annotation from
157+
the domain resource will cause neither a restart nor a patch. It is possible to force a restart to remove
158+
such a label or annotation by modifying the restartVersion.
159+
155160
### Rolling restarts
156161

157162
Clustered servers that need to be restarted are gradually restarted (for example, `rolling restarted`) so that the cluster is not taken out of service and in-flight work can be migrated to other servers in the cluster.

0 commit comments

Comments
 (0)