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

fix(hostnamegenerator): selectors validation and matching #10688

Conversation

jakubdyszkiewicz
Copy link
Contributor

Checklist prior to review

I noticed a bug when implementing hostnames for MeshMultiZoneService.
If we define this HostnameGenerator

spec:
  selectors:
    meshService: {}

It also selects MeshExternalServices.

It does not make sense to have one HostnameGenerator for MeshExternalService, MeshService, so we should require exact one field in Selectors.
Additionally, MeshService and MeshExternalService fields were not pointers so it was impossible to distinguish

spec:
  selectors: {}

from

spec:
  selectors:
    meshService: {}

I also added builders, but not samples because we are still unsure what good default values are.

  • Link to relevant issue as well as docs and UI issues --
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as a image registry) and it will work on Windows, system specific functions like syscall.Mkfifo have equivalent implementation on the other OS --
  • Tests (Unit test, E2E tests, manual test on universal and k8s) --
    • Don't forget ci/ labels to run additional/fewer tests
  • Do you need to update UPGRADE.md? --
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label) --

@jakubdyszkiewicz jakubdyszkiewicz requested a review from a team as a code owner July 1, 2024 13:35
@jakubdyszkiewicz jakubdyszkiewicz requested review from jijiechen and lukidzi and removed request for a team July 1, 2024 13:35
Copy link
Contributor

@lukidzi lukidzi left a comment

Choose a reason for hiding this comment

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

I assume we use merge release to master to sync the change?

Signed-off-by: Jakub Dyszkiewicz <[email protected]>
@jakubdyszkiewicz jakubdyszkiewicz enabled auto-merge (squash) July 2, 2024 06:46
@jakubdyszkiewicz jakubdyszkiewicz merged commit 12d2ea7 into kumahq:release-2.8 Jul 2, 2024
15 checks passed
Copy link
Contributor

@slonka slonka left a comment

Choose a reason for hiding this comment

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

just nits

selectorsDefined++
}
if selectorsDefined != 1 {
verr.AddViolationAt(path, "exact one selector (meshService, meshExternalService) must be defined")
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick:

Suggested change
verr.AddViolationAt(path, "exact one selector (meshService, meshExternalService) must be defined")
verr.AddViolationAt(path, "exactly one selector (meshService, meshExternalService) must be defined")

ErrorCase("spec.selector empty",
validators.Violation{
Field: `spec.selector`,
Message: `exact one selector (meshService, meshExternalService) must be defined`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Message: `exact one selector (meshService, meshExternalService) must be defined`,
Message: `exactly one selector (meshService, meshExternalService) must be defined`,

ErrorCase("spec.selector has too many selectors",
validators.Violation{
Field: `spec.selector`,
Message: `exact one selector (meshService, meshExternalService) must be defined`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Message: `exact one selector (meshService, meshExternalService) must be defined`,
Message: `exactly one selector (meshService, meshExternalService) must be defined`,

This pull request was closed.
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