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 authored and manusa committed Oct 19, 2022
1 parent 366ede8 commit 2b34132
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
11 changes: 6 additions & 5 deletions CHANGELOG.md
Expand Up @@ -3,17 +3,18 @@
### 6.2-SNAPSHOT

#### Bugs
* Fix #3733: The authentication command from the .kube/config won't be discarded if no arguments are specified
* Fix #4312: fix timestamp can't be deserialized for IstioCondition
* 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
* Fix #4460: removing split packages. Converting Default clients into adapters rather than real instances.
* Fix #4426: [java-generator] Encode an `AnyType` instead of an Object if `x-kubernetes-preserve-unknown-fields` is present and the type is null.
* Fix #4441: corrected patch base handling for the patch methods available from a Resource - resource(item).patch() will be evaluated as resource(latest).patch(item). Also undeprecated patch(item), which is consistent with leaving patch(context, item) undeprecated as well. For consistency with the other operations (such as edit), patch(item) will use the context item as the base when available, or the server side item when not. This means that patch(item) is only the same as resource(item).patch() when the patch(item) is called when the context item is missing or is the same as the latest.
* Fix #4442: TokenRefreshInterceptor doesn't overwrite existing OAuth token with empty string
* Fix #4350: SchemaSwap annotation is now repeatable and is applied multiple times if classes are used more than once in the class hierarchy.
* Fix #4459: Fixed OSGi startup exceptions while using KubernetesClient/OpenShiftClient
* Fix #4482: Fixing blocking behavior of okhttp log watch
* Fix #4460: removing split packages. Converting Default clients into adapters rather than real instances.
* Fix #4473: Fix regression in backoff interval introduced in #4365
* Fix #4426: [java-generator] Encode an `AnyType` instead of an Object if `x-kubernetes-preserve-unknown-fields` is present and the type is null.
* Fix #4478: Removing the resourceVersion bump with null status
* Fix #4482: Fixing blocking behavior of okhttp log watch

#### Improvements
* Fix #4471: Adding KubernetesClientBuilder.withHttpClientBuilderConsumer to further customize the HttpClient for any implementation.
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 2b34132

Please sign in to comment.