Skip to content

Commit 1804937

Browse files
authored
feat: adding shared-requestor support in upgrade-controller (#1586)
Network-Operator adaptations for k8s-operator-lib changes, supporting [shared-requestor ](https://github.com/NVIDIA/k8s-operator-libs/blob/main/docs/automatic-ofed-upgrade.md#shared-requestor)flow
2 parents 4de47e2 + fed6850 commit 1804937

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

controllers/upgrade_controller.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"time"
2323

2424
"github.com/NVIDIA/k8s-operator-libs/pkg/upgrade"
25+
"github.com/go-logr/logr"
2526
appsv1 "k8s.io/api/apps/v1"
2627
corev1 "k8s.io/api/core/v1"
2728
"k8s.io/apimachinery/pkg/api/errors"
@@ -194,8 +195,7 @@ func (r *UpgradeReconciler) removeNodeUpgradeStateAnnotations(ctx context.Contex
194195
// SetupWithManager sets up the controller with the Manager.
195196
//
196197
//nolint:dupl
197-
func (r *UpgradeReconciler) SetupWithManager(mgr ctrl.Manager,
198-
requestorPredicate upgrade.ConditionChangedPredicate) error {
198+
func (r *UpgradeReconciler) SetupWithManager(log logr.Logger, mgr ctrl.Manager) error {
199199
// we always add object with a same(static) key to the queue to reduce
200200
// reconciliation count
201201
qHandler := func(q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
@@ -231,7 +231,7 @@ func (r *UpgradeReconciler) SetupWithManager(mgr ctrl.Manager,
231231
labels := object.GetLabels()
232232
_, ok := labels[consts.OfedDriverLabel]
233233
return ok
234-
}), requestorPredicate)
234+
}))
235235

236236
// react only on label and annotation changes
237237
nodePredicates := builder.WithPredicates(
@@ -252,8 +252,12 @@ func (r *UpgradeReconciler) SetupWithManager(mgr ctrl.Manager,
252252
// Conditionally add Watches for NodeMaintenance if UseMaintenanceOperator is true
253253
requestorOpts := upgrade.GetRequestorOptsFromEnvs()
254254
if requestorOpts.UseMaintenanceOperator {
255+
nodeMaintenancePredicate := upgrade.NewConditionChangedPredicate(log,
256+
requestorOpts.MaintenanceOPRequestorID)
257+
requestorIDPredicate := upgrade.NewRequestorIDPredicate(log,
258+
requestorOpts.MaintenanceOPRequestorID)
255259
mngr = mngr.Watches(&maintenancev1alpha1.NodeMaintenance{}, createUpdateDeleteEnqueue,
256-
builder.WithPredicates(requestorPredicate))
260+
builder.WithPredicates(nodeMaintenancePredicate, requestorIDPredicate))
257261
}
258262

259263
return mngr.Complete(r)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/Mellanox/maintenance-operator/api v0.2.2
7-
github.com/NVIDIA/k8s-operator-libs v0.0.0-20250512170135-63bc7baf3f6f
7+
github.com/NVIDIA/k8s-operator-libs v0.0.0-20250708070119-9dc24ccc10ee
88
github.com/caarlos0/env/v6 v6.10.1
99
github.com/containers/image/v5 v5.35.0
1010
github.com/go-logr/logr v1.4.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ
44
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
55
github.com/Mellanox/maintenance-operator/api v0.2.2 h1:7bl/txeHv49NdubQ72AqC7tLXa9oJrZuqk27TG5CybM=
66
github.com/Mellanox/maintenance-operator/api v0.2.2/go.mod h1:pkd4TxjMFItohSXT0D1JhXB/E3d8jE5asBzxNATwT2s=
7-
github.com/NVIDIA/k8s-operator-libs v0.0.0-20250512170135-63bc7baf3f6f h1:nU6yhJjS7eSVWBxnUvF+RIEdTPG1zWKG2Xgy4FJ7JjU=
8-
github.com/NVIDIA/k8s-operator-libs v0.0.0-20250512170135-63bc7baf3f6f/go.mod h1:B5g1bFq39qbuVK62pz0m93Qy3CCjeutfNICSl7SFoYo=
7+
github.com/NVIDIA/k8s-operator-libs v0.0.0-20250708070119-9dc24ccc10ee h1:IW3URIejZ85qDFoMXV1EzuHjjerGd8h0I5BvLGiuqa0=
8+
github.com/NVIDIA/k8s-operator-libs v0.0.0-20250708070119-9dc24ccc10ee/go.mod h1:8skFe7Dyub0FRpk5ysCM88ysFqJpIcw/4ZqLBWcevw8=
99
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
1010
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
1111
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=

main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,12 @@ func setupUpgradeController(mgr ctrl.Manager, migrationChan chan struct{}) error
245245
setupLog.Error(err, "unable to create new ClusterUpdateStateManager", "controller", "Upgrade")
246246
return err
247247
}
248-
requestorPredicate := upgrade.NewConditionChangedPredicate(setupLog,
249-
requestorOpts.MaintenanceOPRequestorID)
250248
if err = (&controllers.UpgradeReconciler{
251249
Client: mgr.GetClient(),
252250
Scheme: mgr.GetScheme(),
253251
StateManager: clusterUpdateStateManager,
254252
MigrationCh: migrationChan,
255-
}).SetupWithManager(mgr, requestorPredicate); err != nil {
253+
}).SetupWithManager(setupLog, mgr); err != nil {
256254
setupLog.Error(err, "unable to create controller", "controller", "Upgrade")
257255
return err
258256
}

0 commit comments

Comments
 (0)