Skip to content

fix: Use correct url to get pod logs #7128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jonasrutishauser
Copy link

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

Signed-off-by: Jonas Rutishauser <[email protected]>
@jonasrutishauser jonasrutishauser marked this pull request as ready for review June 12, 2025 18:03
@rohanKanojia
Copy link
Member

@jonasrutishauser : Could you please provide more context? What URL was being generated by client earlier? With .withItem(null) call, what change is happening in generated request?

@jonasrutishauser
Copy link
Author

@jonasrutishauser : Could you please provide more context? What URL was being generated by client earlier? With .withItem(null) call, what change is happening in generated request?

Running the extended integration test without the code modification gives the following exception:

io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: https://192.168.39.131:8443/apis/batch/v1/namespaces/00000000-0000-0000-0000-0000000001a6/pods?labelSelector=controller-uid%3D7e99aa45-9c05-46ad-9cf3-0fce73c1ddbb. Message: the server could not find the requested resource. Received status: Status(apiVersion=v1, code=404, details=StatusDetails(causes=[], group=null, kind=null, name=null, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=the server could not find the requested resource, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=NotFound, status=Failure, additionalProperties={}).
	at io.fabric8.kubernetes.client.KubernetesClientException.copyAsCause(KubernetesClientException.java:205)
	at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.waitForResult(OperationSupport.java:507)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:451)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:419)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:98)
	at io.fabric8.kubernetes.client.utils.internal.PodOperationUtil.getPodOperationsForController(PodOperationUtil.java:116)
	at io.fabric8.kubernetes.client.utils.internal.PodOperationUtil.getPodOperationsForController(PodOperationUtil.java:79)
	at io.fabric8.kubernetes.client.dsl.internal.batch.v1.JobOperationsImpl.doGetLog(JobOperationsImpl.java:118)
	at io.fabric8.kubernetes.client.dsl.internal.batch.v1.JobOperationsImpl.watchLog(JobOperationsImpl.java:150)
	at io.fabric8.kubernetes.JobIT.testGetLog(JobIT.java:59)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

The problem is that a call to withApiGroupName() does no change as long as the item is defined. See (item always wins)

private void setApiGroupName(String apiGroupName) {
this.apiGroupName = ApiVersionUtil.apiGroup(item, apiGroupName);
}
and
public static <T> String apiGroup(T item, String apiGroup) {
if (item instanceof HasMetadata && Utils.isNotNullOrEmpty(((HasMetadata) item).getApiVersion())) {
return trimGroupOrNull(((HasMetadata) item).getApiVersion());
} else if (apiGroup != null && !apiGroup.isEmpty()) {
return trimGroup(apiGroup);
}
return null;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants