-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
⚠️ Add support to auto-update external references #2267
⚠️ Add support to auto-update external references #2267
Conversation
Going to add tests once code looks good / this is what we expect |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 |
@@ -182,6 +196,18 @@ func (r *MachineDeploymentReconciler) reconcile(_ context.Context, cluster *clus | |||
return ctrl.Result{}, errors.Errorf("unexpected deployment strategy type: %s", d.Spec.Strategy.Type) | |||
} | |||
|
|||
func (r *MachineDeploymentReconciler) reconcileExternalReference(ctx context.Context, cluster *clusterv1.Cluster, ref *corev1.ObjectReference) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we go ahead and set ownerref (non-controller) here for the referenced templates as well? I'm worried that we could potentially delete a template that is still referenced by an existing MachineDeployment if for some reason all of the associated MachineSets are deleted.
util/conversion/conversion.go
Outdated
"testing" | ||
|
||
fuzz "github.com/google/gofuzz" | ||
"github.com/onsi/gomega" | ||
"github.com/pkg/errors" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import caused me to double take... not sure why they aren't exposing this out via k8s.io/api/apiextensions/...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related-ish kubernetes/client-go#247
3092565
to
e1319b5
Compare
util/conversion/conversion.go
Outdated
// If there is no label, return early without changing the reference. | ||
supportedVersions, ok := crd.Labels[contract] | ||
if !ok { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return an error here since we are saying that the labels will be required for v1alpha3+?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering the same if we should treat it as an error, or just let the reference be what it is. I'd prefer erroring out though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my preference here is to go ahead and error, since it is breaking the contract we are defining, but I'll defer to @ncdc for final ack/nack :)
util/conversion/conversion.go
Outdated
|
||
// Modify the GroupVersionKind with the new version. | ||
gvk := ref.GroupVersionKind() | ||
gvk.Version = versions[len(versions)-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it would make sense to sort the available versions using https://godoc.org/k8s.io/apimachinery/pkg/version#CompareKubeAwareVersionStrings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice! I can definitely add this in
e1319b5
to
fd7d10c
Compare
Tests are gonna fail until kubernetes-sigs/controller-tools#400 is implemented, because that will change the actual base files vs kustomize won't until they're rebuilt. This is of course a possible solution, if we want to go down another path, that's also fine. The method to check for the CRD versions is also going to be very expensive until we can use kubernetes-sigs/controller-runtime#792 |
@vincepri aside from the controller-tools changes, is this generally good to go, or is there more to do? It's the last piece of the puzzle!!! |
The controller-tools change is needed for tests, I'll try to see if I can do a patch locally though |
fd7d10c
to
9247216
Compare
9247216
to
6161888
Compare
I might get away with it in tests for now, pushed an update |
6161888
to
aa14269
Compare
203a7a5
to
7cabe4b
Compare
7cabe4b
to
739755c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for me, two nits not blocking
util/util.go
Outdated
// optional "alpha" or "beta" strings followed by a minor version (e.g. v1, v2beta1). | ||
// Versions will be sorted based on GA/alpha/beta first and then major and minor | ||
// versions. e.g. v2, v1, v1beta2, v1beta1, v1alpha1. | ||
type KubeVersions []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KubeAwareVersion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, KubeVersions
instantly makes me think of KubernetesVersion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opted for KubeAwareAPIVersions
to be extra clear :)
22b8f14
to
b3ea5b0
Compare
/retest This looks good to me, I think the capd e2e has just been having a bad time today. |
b3ea5b0
to
90e3795
Compare
"sigs.k8s.io/controller-runtime/pkg/conversion" | ||
) | ||
|
||
const ( | ||
DataAnnotation = "cluster.x-k8s.io/conversion-data" | ||
) | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var ( | |
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't actually be assigned to a constant because the value comes from a function and can only be resolved at runtime
Signed-off-by: Vince Prignano <vincepri@vmware.com>
90e3795
to
9ad583b
Compare
/lgtm |
@vincepri: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Signed-off-by: Vince Prignano vincepri@vmware.com
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #2140