Skip to content

Commit

Permalink
ensure network daemon checks if machineConfigPool resource registered…
Browse files Browse the repository at this point in the history
… before attempting to pause the MachineConfigPool

In hypershift: there are no machineConfigPool resources registered and therefore no need to pause the MachineConfigPool resource when sriov-network-operator is orchestrating sr-iov configuration. This adds a check to see if that api resource is registered with the cluster before attempting to pause the machineConfigPool resource
  • Loading branch information
relyt0925 committed Aug 15, 2022
1 parent 82f8612 commit 19b1812
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,37 @@ func (dn *Daemon) getDrainLock(ctx context.Context, done chan bool) {
})
}

// isMachineConfigPoolResourceRegistered checks to see if the MachineConfigPool API Resource
// is registered in the Openshift cluster
func isMachineConfigPoolResourceRegistered(c *mcclientset.Clientset) (bool, error) {
machineConfigPoolResourceName := "machineconfigpool"
availableAPIs, err := c.ServerResourcesForGroupVersion(mcfgv1.GroupVersion.String())
if err != nil && !errors.IsNotFound(err) {
return false, err
}
if availableAPIs != nil {
for _, api := range availableAPIs.APIResources {
if api.SingularName == machineConfigPoolResourceName {
return true, nil
}
}
}
return false, nil
}

func (dn *Daemon) pauseMCP() error {
glog.Info("pauseMCP(): pausing MCP")
var err error

isRegistered, err := isMachineConfigPoolResourceRegistered(dn.mcClient)
if err != nil {
return err
}
// In hypershift: there are no machineConfigPool resources
// if the MachineConfigPool resource is not registered in API there is no need to pause it
if !isRegistered {
glog.Info("pauseMCP(): MCP resource not registered")
return nil
}
mcpInformerFactory := mcfginformers.NewSharedInformerFactory(dn.mcClient,
time.Second*30,
)
Expand Down

0 comments on commit 19b1812

Please sign in to comment.