Skip to content

Conversation

@jmdeal
Copy link
Member

@jmdeal jmdeal commented Aug 30, 2025

Fixes #N/A

Description
Starting in k8s 1.34, matchLabelKeys values are injected into match expressions by the API server. This matches the implementation for pod affinity. This PR adds a default version provider (overridable by the provider) which will allow us to conditionally disable our own injection on k8s versions 1.34 and greater.

How was this change tested?
make test

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 30, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jmdeal

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 30, 2025
@jmdeal
Copy link
Member Author

jmdeal commented Sep 2, 2025

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 2, 2025
})
}

type KubernetesVersionProvider interface {
Copy link
Member

Choose a reason for hiding this comment

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

Should this go in the version package? Seems a bit odd that this would land in the operator package to me

nodehydration.NewController(kubeClient, cloudProvider),
}

if p, ok := kubeVersionProvider.(*version.Provider); ok {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a better way to handle this by registering the controller on the operator.go side. It feels sort of odd to pass this through and then do static type checking like this to enable the controller mechanism

nodeClaimStateController = informer.NewNodeClaimController(env.Client, cloudProvider, cluster)
recorder = test.NewEventRecorder()
prov = provisioning.NewProvisioner(env.Client, recorder, cloudProvider, cluster, fakeClock)
prov = provisioning.NewProvisioner(env.Client, env.KubernetesVersionProvider(), recorder, cloudProvider, cluster, fakeClock)
Copy link
Member

Choose a reason for hiding this comment

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

I could go either way, but why make this a method and not have this just be an interface that can be accessed directly

return resource.MustParse(fmt.Sprintf("%dm", cpu[r.Intn(len(cpu))]))
}

type staticVersionProvider struct {
Copy link
Member

Choose a reason for hiding this comment

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

Should static version provider just be something that we put in the version package? We could share this across packages, including in the test environment

}
}
marshaled := string(lo.Must(json.Marshal(tsc.LabelSelector.MatchExpressions)))
fmt.Printf("%s\n", marshaled)
Copy link
Member

Choose a reason for hiding this comment

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

I think you need to drop this print statement and the marshaling

@jmdeal
Copy link
Member Author

jmdeal commented Sep 3, 2025

Discussed offline, and agreed that we should figure out why the double-injected requirements are having the impact they are. In theory, it shouldn't matter if we've injected the same match expression twice into the selector term set. We've reverted 1.34 testing for the time being to unblock other PRs, and will reintroduce it once this PR is merged.

@jmdeal
Copy link
Member Author

jmdeal commented Sep 3, 2025

Well this is interesting - it looks like we're probably running into mitchellh/hashstructure#36. I've been able to verify that the issue is caused by us getting the same hash for a TopologyGroup constructed with the "value-a" selector and the "value-b" selector. As a result, we're only constructing a single TopologyGroup.

@jmdeal
Copy link
Member Author

jmdeal commented Sep 3, 2025

I'm going to close this out in favor of #2479 - the two PRs are significantly different in approach.

@jmdeal jmdeal closed this Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants