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 10, 2022
1 parent 772737c commit a552123
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,33 @@ func (dn *Daemon) getDrainLock(ctx context.Context, done chan bool) {
})
}

// isMachineConfigPoolResourceRegistered checks to see if the MachineConfigPool API Resource
// is registed 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.Name == machineConfigPoolresourceName || 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)
// In hypershift: there are no machineConfigPool resources
// if the MachineConfigPool resource is not registered in API there is no need to pause it
if err != nil || !isRegistered {
return err
}
mcpInformerFactory := mcfginformers.NewSharedInformerFactory(dn.mcClient,
time.Second*30,
)
Expand Down

0 comments on commit a552123

Please sign in to comment.