fabric8io / kubernetes-client

Java client for Kubernetes & OpenShift
http://fabric8.io
Apache License 2.0
3.42k stars 1.46k forks source link

Inconsistencies with mock server timestamps #6632

Open Hoferl opened 2 days ago

Hoferl commented 2 days ago

Is your enhancement related to a problem? Please describe

I am using the KubernetesMockServer for testing my K8s Operator which uses the deletionTimestamp in the metadata when deleting a resource. The problem is that I expect this timestamp to be formatted with a trailing timezone for parsing, but the mock server returns it in a different format. The creationTimestamp on the other hand is formatted as expected.

Example: deletionTimestamp = "2024-11-19T15:18:14.048045500" creationTimestamp = "2024-11-19T14:18:11.071782Z"

I assume both fields are set and managed by the mock server, is this different behavior intended? Setting the Timezone in my Java Test code to UTC resolves the 1 hour difference but does not add a "Z".

Describe the solution you'd like

I would expect the same formatting for both timestamps. Ideally it would be in the ISO 8601 format with UTC as timezone, as this is the Kubernetes default afaik.

Describe alternatives you've considered

No response

Additional context

I use version 6.13.4

manusa commented 2 days ago

Looks like a bug. If it's easy for you, can you try to see if this is still the case in the 7.0-SNAPSHOT. The bug is likely there still, but just in case.

Hoferl commented 2 days ago

I would need to build it locally to have a 7.0-SNAPSHOT available, right?

manusa commented 2 days ago

The snapshots are published, you can enable them by adding this to your project pom.xml or global ~/.m2/settings.xml

      <repositories>
        <repository>
          <id>sonatype-snapshots</id>
          <url>https://oss.sonatype.org/content/repositories/snapshots</url>
          <releases><enabled>false</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
Hoferl commented 2 days ago

Hi, I was able to test it with the 7.0-SNAPSHOT version and like you assumed the behavior does not change, the bug is still there.