Skip to content
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

CustomObjectsApi.getNamespacedCustomObject does not return metadata in the latest version of the client #3589

Open
SachinHg opened this issue Jul 23, 2024 · 6 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@SachinHg
Copy link

SachinHg commented Jul 23, 2024

Describe the bug
We use CustomObjectsApi to deal with the CRUD operations for istio related resources. Since upgrading the k8s client version to 20.0.1, the CustomObjectsApi.getNamespacedCustomObject does not return metadata as part of the response. This used to work in the older version of the client 1.12.

Client Version
20.0.1

Kubernetes Version
1.29

Java Version
Java 21

To Reproduce
Steps to reproduce the behavior:

public class CustomObjectResourceVersion {

public static void main(String[] args) {
    try {
        ApiClient client = Config.defaultClient();
        io.kubernetes.client.openapi.Configuration.setDefaultApiClient(client);

        CustomObjectsApi customObjectsApi = new CustomObjectsApi(client);

        String group = "networking.istio.io";
        String version = "v1beta1";
        String namespace = "default"; 
        String plural = "virtualservices";
        String name = "vs-name"; 

        Map<String, Object> customObject = (Map<String, Object>) customObjectsApi.getNamespacedCustomObject(
                group,
                version,
                namespace,
                plural,
                name
        );

       Gson gson = new Gson();
       String vsJsonString = gson.toJson(customObject);
       VirtualService existingVirtualService = gson.fromJson(vsJsonString, VirtualService.class);
      String resourceVersion = existingVirtualService.getMetadata().getResourceVersion();
} catch(Exception e) {
      e.printStackTrace();
}

}

Expected behavior
It should return the metadata.

Output of raw JSON

{\\\"group\\\":\\\"networking.istio.io\\\",\\\"version\\\":\\\"v1beta1\\\",\\\"namespace\\\":\\\"namespace-name\\\",\\\"plural\\\":\\\"virtualservices\\\",\\\"name\\\":\\\"example-virtualservice-name\\\"} \"}
@brendandburns
Copy link
Contributor

Can you print the raw JSON object and attach it to this issue?

@brendandburns
Copy link
Contributor

Additionally, can you try the 20.0.1-legacy version and see if that works?

@SachinHg
Copy link
Author

SachinHg commented Jul 24, 2024

@brendandburns updated the issue description with the raw json object. I can also confirm that this works without any problem with 20.0.1-legacy

@brendandburns
Copy link
Contributor

For the raw JSON, I was hoping for the JSON that came back from the API server, not the JSON output of the client side object.

Can you provide the JSON from the server so that we can determine if there is some sort of parsing error?

For context, the code generator changed in the 20 release, which is likely the difference causing this, but I'm not certain exactly what is going wrong.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 23, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants