Skip to content

Commit

Permalink
fix fabric8io#4478: status handling was inserting an explicit missing…
Browse files Browse the repository at this point in the history
… node
  • Loading branch information
shawkins committed Oct 6, 2022
1 parent 15f8335 commit 703fafd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
### 6.2-SNAPSHOT

#### Bugs
* Fix #4478: Removing the resourceVersion bump with null status
* Fix #4369: Informers will retry with a backoff on list/watch failure as they did in 5.12 and prior.
* Fix #4350: SchemaSwap annotation is now repeatable and is applied multiple times if classes are used more than once in the class hierarchy.
* Fix #3733: The authentication command from the .kube/config won't be discarded if no arguments are specified
Expand Down
Expand Up @@ -67,7 +67,7 @@ public MockResponse handle(String path, String contentType, String requestBody)
final JsonNode updatedResource;
if (isStatusPath(path)) {
updatedResource = currentResource.deepCopy();
setStatus(updatedResource, fullPatch.path(STATUS));
setStatus(updatedResource, fullPatch.get(STATUS));
} else {
updatedResource = fullPatch;
// preserve original status (PATCH requests to the custom resource ignore changes to the status stanza)
Expand Down
Expand Up @@ -48,12 +48,12 @@ public MockResponse handle(String path, String contentType, String requestBody)
final JsonNode updatedResource;
if (isStatusPath(path)) {
updatedResource = currentResource.deepCopy();
setStatus(updatedResource, persistence.asNode(requestBody).path(STATUS));
setStatus(updatedResource, persistence.asNode(requestBody).get(STATUS));
} else {
updatedResource = persistence.asNode(requestBody);
// preserve original status (PUT requests to the custom resource ignore changes to the status stanza)
if (persistence.isStatusSubresourceEnabledForResource(path)) {
setStatus(updatedResource, currentResource.path(STATUS));
setStatus(updatedResource, currentResource.get(STATUS));
}
}
validatePath(attributes, updatedResource);
Expand Down
Expand Up @@ -195,6 +195,30 @@ void testStatusPatch() {
assertNotNull(result.getStatus());
}

@Test
void testNullStatus() {
CronTab cronTab = createCronTab("my-new-cron-object", "* * * * */5", 3, "my-awesome-cron-image");

NonNamespaceOperation<CronTab, KubernetesResourceList<CronTab>, Resource<CronTab>> cronTabClient = client
.resources(CronTab.class).inNamespace("test-ns");

CronTab result = cronTabClient.resource(cronTab).create();

// should be null after create
assertNull(result.getStatus());
String resourceVersion = result.getMetadata().getResourceVersion();

// should be a no-op
result = cronTabClient.resource(result).patchStatus();
assertNull(result.getStatus());
assertEquals(resourceVersion, result.getMetadata().getResourceVersion());

// should be a no-op
result = cronTabClient.resource(result).replace();
assertNull(result.getStatus());
assertEquals(resourceVersion, result.getMetadata().getResourceVersion());
}

void assertCronTab(CronTab cronTab, String name, String cronTabSpec, int replicas, String image) {
assertEquals(name, cronTab.getMetadata().getName());
assertEquals(cronTabSpec, cronTab.getSpec().getCronSpec());
Expand Down

0 comments on commit 703fafd

Please sign in to comment.