-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat: Support multiple MOFED DS #691
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 |
---|---|---|
|
@@ -82,7 +82,7 @@ func setupWebhookControllers(mgr ctrl.Manager) error { | |
return nil | ||
} | ||
|
||
func setupCRDControllers(ctx context.Context, c client.Client, mgr ctrl.Manager) error { | ||
func setupCRDControllers(ctx context.Context, c client.Client, mgr ctrl.Manager, migrationChan chan struct{}) error { | ||
ctrLog := setupLog.WithName("controller") | ||
clusterTypeProvider, err := clustertype.NewProvider(ctx, c) | ||
|
||
|
@@ -98,27 +98,31 @@ func setupCRDControllers(ctx context.Context, c client.Client, mgr ctrl.Manager) | |
Scheme: mgr.GetScheme(), | ||
ClusterTypeProvider: clusterTypeProvider, // we want to cache information about the cluster type | ||
StaticConfigProvider: staticInfoProvider, | ||
MigrationCh: migrationChan, | ||
}).SetupWithManager(mgr, ctrLog.WithName("NicClusterPolicy")); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "NicClusterPolicy") | ||
return err | ||
} | ||
if err := (&controllers.MacvlanNetworkReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
MigrationCh: migrationChan, | ||
}).SetupWithManager(mgr, ctrLog.WithName("MacVlanNetwork")); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "MacvlanNetwork") | ||
return err | ||
} | ||
if err := (&controllers.HostDeviceNetworkReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
MigrationCh: migrationChan, | ||
}).SetupWithManager(mgr, ctrLog.WithName("HostDeviceNetwork")); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "HostDeviceNetwork") | ||
return err | ||
} | ||
if err := (&controllers.IPoIBNetworkReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
MigrationCh: migrationChan, | ||
}).SetupWithManager(mgr, ctrLog.WithName("IPoIBNetwork")); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "IPoIBNetwork") | ||
return err | ||
|
@@ -166,35 +170,26 @@ func main() { | |
os.Exit(1) | ||
} | ||
|
||
// run migration logic before controllers start | ||
if err := migrate.Migrate(stopCtx, setupLog.WithName("migrate"), directClient); err != nil { | ||
setupLog.Error(err, "failed to run migration logic") | ||
os.Exit(1) | ||
migrationCompletionChan := make(chan struct{}) | ||
m := migrate.Migrator{ | ||
K8sClient: directClient, | ||
MigrationCh: migrationCompletionChan, | ||
LeaderElection: enableLeaderElection, | ||
Logger: ctrl.Log.WithName("Migrator"), | ||
} | ||
Comment on lines
-170
to
179
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. What's the reason for moving this logic to a runnable? 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. We want to use the leader election mechanism and make sure it runs only when we get the leader election by using 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. Would it be possible to deprecate the helm hooks in favor of this approach? 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. I think one of thing we would like is to get rid of creating the instance of NicClusterPolicy as part of the helm before we go and remove this hook. The process should be:
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. Let's try to get this prioritized IMO - makes a lot of things simpler for deploying network operator. |
||
|
||
err = setupCRDControllers(stopCtx, directClient, mgr) | ||
err = mgr.Add(&m) | ||
if err != nil { | ||
setupLog.Error(err, "failed to add Migrator to the Manager") | ||
os.Exit(1) | ||
} | ||
|
||
upgrade.SetDriverName("ofed") | ||
|
||
upgradeLogger := ctrl.Log.WithName("controllers").WithName("Upgrade") | ||
|
||
clusterUpdateStateManager, err := upgrade.NewClusterUpgradeStateManager( | ||
upgradeLogger.WithName("clusterUpgradeManager"), config.GetConfigOrDie(), nil) | ||
|
||
err = setupCRDControllers(stopCtx, directClient, mgr, migrationCompletionChan) | ||
if err != nil { | ||
setupLog.Error(err, "unable to create new ClusterUpdateStateManager", "controller", "Upgrade") | ||
os.Exit(1) | ||
} | ||
|
||
if err = (&controllers.UpgradeReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
StateManager: clusterUpdateStateManager, | ||
}).SetupWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "Upgrade") | ||
err = setupUpgradeController(mgr, migrationCompletionChan) | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
|
||
|
@@ -221,3 +216,28 @@ func main() { | |
os.Exit(1) | ||
} | ||
} | ||
|
||
func setupUpgradeController(mgr ctrl.Manager, migrationChan chan struct{}) error { | ||
upgrade.SetDriverName("ofed") | ||
|
||
upgradeLogger := ctrl.Log.WithName("controllers").WithName("Upgrade") | ||
|
||
clusterUpdateStateManager, err := upgrade.NewClusterUpgradeStateManager( | ||
upgradeLogger.WithName("clusterUpgradeManager"), config.GetConfigOrDie(), nil) | ||
|
||
if err != nil { | ||
setupLog.Error(err, "unable to create new ClusterUpdateStateManager", "controller", "Upgrade") | ||
return err | ||
} | ||
|
||
if err = (&controllers.UpgradeReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
StateManager: clusterUpdateStateManager, | ||
MigrationCh: migrationChan, | ||
}).SetupWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "Upgrade") | ||
return err | ||
} | ||
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.
We should probably add this to all controllers - even if not strictly needed right now. Might even be worth doing a reconcile-wrapper, but I think this snipped as is in all controllers is good enough for now. Maybe also add a comment to give folks clues as to what we're waiting for at this point.
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.
done
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.
nit: it would be good to make it in a separate commit