Skip to content

feat: add isSameResource on HasMetadata#7426

Open
metacosm wants to merge 3 commits intomainfrom
is-same-resource
Open

feat: add isSameResource on HasMetadata#7426
metacosm wants to merge 3 commits intomainfrom
is-same-resource

Conversation

@metacosm
Copy link
Copy Markdown
Collaborator

@metacosm metacosm commented Feb 3, 2026

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

@metacosm metacosm self-assigned this Feb 3, 2026
return false;
}

final var kind = getKind();
Copy link
Copy Markdown
Member

@manusa manusa Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should apiVersion be checked too? (e.g. two resources with same kind but different apiVersion v1beta1 vs. v1alpha1 (or a real legacy case such as apps/v1 vs extensions/v1beta1 Deployment) would be considered the same)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first implementation was doing that and then I read in the Kube docs that an object's identity shouldn't take the API version into consideration… cf https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

We could have an option to also check the API version, if we think it's interesting to do so.

Another question I had, was with respect to the UID… I'm not sure about how it's used and whether or not it should factor in this function.

Copy link
Copy Markdown
Contributor

@csviri csviri Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was just going to ask that, if UID is present on both resources on that case probably would be enough to check that.

Copy link
Copy Markdown
Contributor

@csviri csviri Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API version is tricky, since there should be a conversion hook, and there is always just one stored version, not sure if after the conversion it preserves UID, would be worth to check.
Is is a matter of definition too, what we call "same resource".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be a little cautious introducing notions like this which are not generic kubernetes terms

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question I had wrt to UID is that I was wondering if it's possible for a logical resource which would be recreated with the same UID (since it's supposed to be the same resource) could end up with a different name and namespace? I don't really have much experience dealing with UIDs so I'm not too sure if that's a valid use case or not…

Copy link
Copy Markdown
Contributor

@csviri csviri Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question I had wrt to UID is that I was wondering if it's possible for a logical resource which would be recreated with the same UID (since it's supposed to be the same resource) could end up with a different name and namespace?

Here we are comparing two resources where both should live on the server (or at least live close in time), theoretically this could happen, but I don't think we should care. The probability of UID collision is already:

For example, the number of random version 4 UUIDs which need to be generated in order to have a 50% probability of at least one collision is 2.71 quintillion.
And we are talking about a short period of time this to happen.

If that happens I will eat my red hat :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you manage to check the UID preservation after the conversion hook is applied?
From my side I'm happy to merge this since you folks (and downstream users of JOSDK) are probably the ones who will be consuming it.

@manusa manusa moved this to Review in Eclipse JKube Feb 17, 2026
@manusa manusa added this to the 7.6.0 milestone Feb 17, 2026
@manusa manusa modified the milestones: 7.7.0, 7.6.0 Feb 27, 2026
@manusa manusa moved this from Review to In Progress in Eclipse JKube Mar 2, 2026
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.

3 participants