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

Incorrect User-Agent #3857

Open
cowwoc opened this issue Jan 8, 2025 · 3 comments
Open

Incorrect User-Agent #3857

cowwoc opened this issue Jan 8, 2025 · 3 comments

Comments

@cowwoc
Copy link

cowwoc commented Jan 8, 2025

Describe the bug
When running this code:

public V1ConfigMap createOrReplace(V1ConfigMap configMap) throws ApiException
{
  V1ObjectMeta metadata = configMap.getMetadata();
  assert (metadata != null);
  // https://github.com/kubernetes-client/java/issues/3653#issuecomment-2307770649
  V1Patch configMapPatch = new V1Patch(JSON.serialize(configMap));
  return PatchUtils.patch(V1ConfigMap.class,
    () -> core.patchNamespacedConfigMap(metadata.getName(), metadata.getNamespace(), configMapPatch).
    fieldManager(fieldManager).
    force(true).
    buildCall(null),
    V1Patch.PATCH_FORMAT_APPLY_YAML,
    client);
}

If I step through the code with a debugger, I can see that the Request object created by PatchUtils.patch() is using the wrong User-Agent version: Request{method=PATCH, url=https://fb6cde70-6232-42cf-a2e1-211ac67c62ed.k8s.ondigitalocean.com/api/v1/namespaces/default/configmaps/install-helm-script?fieldManager=LicensedCluster&force=true, headers=[authorization:Bearer redacted, Accept:application/json, Content-Type:application/json, User-Agent:Kubernetes Java Client/21.0.0-SNAPSHOT]}

I am using v22.0.0, not 21.0.0-SNAPSHOT.

Client Version

<dependency>
  <groupId>io.kubernetes</groupId>
  <artifactId>client-java</artifactId>
  <version>22.0.0</version>
</dependency>

Kubernetes Version
1.31.1

Java Version
Java 23.0.1

To Reproduce
Run the aforementioned code

Expected behavior
The User-Agent should be equal to Kubernetes Java Client/22.0.0.

KubeConfig
N/A

Server (please complete the following information):

  • OS: Linux
  • Environment: DigitalOcean Kubernetes (DOKS)
  • Cloud: DigitalOcean
@brendandburns
Copy link
Contributor

I think this comes from here:

https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/Configuration.java#L17

We probably need to update it before we cut a release. We'll have to figure out the best way to get that into our automation. I would have thought that mvn release:prepare would do it for us, but apparently not.

@cowwoc
Copy link
Author

cowwoc commented Jan 9, 2025

@brendandburns Why don't you embed and read the version number from the JAR file? That's much easier to do than have Maven update source-code files.

@brendandburns
Copy link
Contributor

Happy to take a PR to add support for that.

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

No branches or pull requests

2 participants