Skip to content

Commit

Permalink
Set OwnerReference to sriov-device-plugin configmap
Browse files Browse the repository at this point in the history
The configmap is created by the operator but never deleted.
Set OwnerReference to SriovOperatorConfig default CR to ensure
its deletion.

Signed-off-by: adrianc <adrianc@nvidia.com>
  • Loading branch information
adrianchiris committed Feb 6, 2024
1 parent 49dde87 commit 6997a65
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (r *SriovNetworkNodePolicyReconciler) Reconcile(ctx context.Context, req ct
return reconcile.Result{}, err
}
// Sync Sriov device plugin ConfigMap object
if err = r.syncDevicePluginConfigMap(ctx, policyList, nodeList); err != nil {
if err = r.syncDevicePluginConfigMap(ctx, defaultOpConf, policyList, nodeList); err != nil {
return reconcile.Result{}, err
}
// Render and sync Daemon objects
Expand Down Expand Up @@ -193,7 +193,8 @@ func (r *SriovNetworkNodePolicyReconciler) SetupWithManager(mgr ctrl.Manager) er
Complete(r)
}

func (r *SriovNetworkNodePolicyReconciler) syncDevicePluginConfigMap(ctx context.Context, pl *sriovnetworkv1.SriovNetworkNodePolicyList, nl *corev1.NodeList) error {
func (r *SriovNetworkNodePolicyReconciler) syncDevicePluginConfigMap(ctx context.Context, dc *sriovnetworkv1.SriovOperatorConfig,
pl *sriovnetworkv1.SriovNetworkNodePolicyList, nl *corev1.NodeList) error {
logger := log.Log.WithName("syncDevicePluginConfigMap")
logger.V(1).Info("Start to sync device plugin ConfigMap")

Expand Down Expand Up @@ -221,6 +222,8 @@ func (r *SriovNetworkNodePolicyReconciler) syncDevicePluginConfigMap(ctx context
},
Data: configData,
}
controllerutil.SetControllerReference(dc, cm, r.Scheme)

found := &corev1.ConfigMap{}
err := r.Get(ctx, types.NamespacedName{Namespace: cm.Namespace, Name: cm.Name}, found)
if err != nil {
Expand Down

0 comments on commit 6997a65

Please sign in to comment.