Skip to content

Commit

Permalink
Enable inventory controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Gchbg committed Jun 13, 2024
1 parent 846f435 commit a4d5bfa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
39 changes: 20 additions & 19 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ type params struct {
enableHTTP2 bool
kubeconfig string
systemNamespace string
enableInventoryController bool
enableMachineController bool
enableMachineClaimController bool
enableOOBController bool
enableInventoryController bool
oobIpLabelSelector string
oobMacDB string
oobCredsRenewalBeforeExpiry time.Duration
Expand All @@ -71,10 +71,10 @@ func parseCmdLine() params {
pflag.Bool("enable-http2", false, "Enable HTTP2 for the metrics and webhook servers.")
pflag.String("kubeconfig", "", "Use a kubeconfig to run out of cluster.")
pflag.String("system-namespace", "", "Use a specific namespace for controller state. If blank, use the in-cluster namespace. Required if running out of cluster.")
pflag.Bool("enable-inventory-controller", true, "Enable the Inventory controller")
pflag.Bool("enable-machine-controller", true, "Enable the Machine controller.")
pflag.Bool("enable-machineclaim-controller", true, "Enable the MachineClaim controller.")
pflag.Bool("enable-oob-controller", true, "Enable the OOB controller.")
pflag.Bool("enable-inventory-controller", true, "Enable the Inventory controller")
pflag.String("oob-ip-label-selector", "", "OOB: Filter IP objects by labels.")
pflag.String("oob-mac-db", "", "OOB: Load MAC DB from file.")
pflag.Duration("oob-creds-renewal-before-expiry", time.Hour*24*7, "OOB: Renew expiring credentials this long before they expire.")
Expand Down Expand Up @@ -107,6 +107,7 @@ func parseCmdLine() params {
enableHTTP2: viper.GetBool("enable-http2"),
kubeconfig: viper.GetString("kubeconfig"),
systemNamespace: viper.GetString("system-namespace"),
enableInventoryController: viper.GetBool("enable-inventory-controller"),
enableMachineController: viper.GetBool("enable-machine-controller"),
enableMachineClaimController: viper.GetBool("enable-machineclaim-controller"),
enableOOBController: viper.GetBool("enable-oob-controller"),
Expand Down Expand Up @@ -237,6 +238,23 @@ func main() {
return
}

if p.enableInventoryController {
var inventoryReconciler *controller.InventoryReconciler
inventoryReconciler, err = controller.NewInventoryReconciler()
if err != nil {
log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "Inventory")
exitCode = 1
return
}

err = inventoryReconciler.SetupWithManager(mgr)
if err != nil {
log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "Inventory")
exitCode = 1
return
}
}

if p.enableMachineController {
var machineReconciler *controller.MachineReconciler
machineReconciler, err = controller.NewMachineReconciler()
Expand Down Expand Up @@ -288,23 +306,6 @@ func main() {
}
}

if p.enableInventoryController {
var inventoryReconciler *controller.InventoryReconciler
inventoryReconciler, err = controller.NewInventoryReconciler()
if err != nil {
log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "Inventory")
exitCode = 1
return
}

err = inventoryReconciler.SetupWithManager(mgr)
if err != nil {
log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "Inventory")
exitCode = 1
return
}
}

// +kubebuilder:scaffold:builder

err = mgr.AddHealthzCheck("health", healthz.Ping)
Expand Down
12 changes: 6 additions & 6 deletions internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ var _ = BeforeSuite(func() {
Expect(mgr).NotTo(BeNil())
Expect(CreateIndexes(ctx, mgr)).To(Succeed())

var inventoryReconciler *InventoryReconciler
inventoryReconciler, err = NewInventoryReconciler()
Expect(err).NotTo(HaveOccurred())
Expect(inventoryReconciler).NotTo(BeNil())
Expect(inventoryReconciler.SetupWithManager(mgr)).To(Succeed())

var machineReconciler *MachineReconciler
machineReconciler, err = NewMachineReconciler()
Expect(err).NotTo(HaveOccurred())
Expand All @@ -139,12 +145,6 @@ var _ = BeforeSuite(func() {
Expect(oobReconciler).NotTo(BeNil())
Expect(oobReconciler.SetupWithManager(mgr)).To(Succeed())

var inventoryReconciler *InventoryReconciler
inventoryReconciler, err = NewInventoryReconciler()
Expect(err).NotTo(HaveOccurred())
Expect(inventoryReconciler).NotTo(BeNil())
Expect(inventoryReconciler.SetupWithManager(mgr)).To(Succeed())

mgrCtx, mgrCancel := context.WithCancel(ctx)
DeferCleanup(mgrCancel)

Expand Down

0 comments on commit a4d5bfa

Please sign in to comment.