-
Notifications
You must be signed in to change notification settings - Fork 127
networks: Add Owner annotation to NetAttachDefs #897
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ import ( | |
| "sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
|
|
||
| sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" | ||
| "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" | ||
| "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" | ||
| "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars" | ||
| ) | ||
|
|
@@ -189,6 +190,20 @@ func (r *genericNetworkReconciler) Reconcile(ctx context.Context, req ctrl.Reque | |
| } | ||
| } else { | ||
| reqLogger.Info("NetworkAttachmentDefinition CR already exist") | ||
|
|
||
| foundOwner := found.GetAnnotations()[consts.OwnerRefAnnotation] | ||
| expectedOwner := netAttDef.GetAnnotations()[consts.OwnerRefAnnotation] | ||
|
|
||
| // Note for the future: the `foundOwner != ""` condition can be removed to make the operator not touching the NetworkAttachmentDefinition created | ||
| // by the user. | ||
| if foundOwner != "" && foundOwner != expectedOwner { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a quick question if we have
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, we do: in case we have: which comes from an SriovNetwork in the sriov-operator-ns namespace when reconciling another network object: the generated net-attach-def has The policy, as of now, is the first reconciler networkobject is the owner |
||
| reqLogger.Info("A NetworkAttachmentDefinition with the same name already exists and it does not belong to this resource", | ||
| "Namespace", netAttDef.Namespace, "Name", netAttDef.Name, | ||
| "CurrentOwner", foundOwner, "ExpectedOwner", expectedOwner, | ||
| ) | ||
| return reconcile.Result{}, nil | ||
| } | ||
|
|
||
adrianchiris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if !equality.Semantic.DeepEqual(found.Spec, netAttDef.Spec) || !equality.Semantic.DeepEqual(found.GetAnnotations(), netAttDef.GetAnnotations()) { | ||
| reqLogger.Info("Update NetworkAttachmentDefinition CR", "Namespace", netAttDef.Namespace, "Name", netAttDef.Name) | ||
| netAttDef.SetResourceVersion(found.GetResourceVersion()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.