Skip to content

Commit

Permalink
Update conditions under which metal3 pod would be deployed
Browse files Browse the repository at this point in the history
When the provisioning config is not present, there is no need for the
MAO to keep trying to deploy the metal3 pod.
  • Loading branch information
sadasu committed Apr 17, 2020
1 parent b9b4aae commit 3b6a7c3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 9 additions & 0 deletions pkg/operator/baremetal_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ type BaremetalProvisioningConfig struct {
ProvisioningOSDownloadURL string
}

func isBaremetalProvisioningConfigAvailable(dc dynamic.Interface, configName string) bool {
provisioningClient := dc.Resource(provisioningGVR)
_, err := provisioningClient.Get(context.Background(), configName, metav1.GetOptions{})
if err != nil {
return false
}
return true
}

func getBaremetalProvisioningConfig(dc dynamic.Interface, configName string) (BaremetalProvisioningConfig, error) {
provisioningClient := dc.Resource(provisioningGVR)
provisioningConfig, err := provisioningClient.Get(context.Background(), configName, metav1.GetOptions{})
Expand Down
11 changes: 8 additions & 3 deletions pkg/operator/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ func (optr *Operator) syncAll(config *OperatorConfig) error {
}
glog.V(3).Info("Synced up all machine-api-controller components")

// In addition, if the Provider is BareMetal, then bring up
// the baremetal-operator pod
// In addition, if the Provider is BareMetal, then imay have to deploy metal3 pod.
if config.BaremetalControllers.BaremetalOperator != "" {
if !isBaremetalProvisioningConfigAvailable(optr.dynamicClient, baremetalProvisioningCR) {
glog.V(3).Info("Not necessary to deploy metal3 pod for this baremetal install.")
return nil
}
if err := optr.syncBaremetalControllers(config); err != nil {
if err := optr.statusDegraded(err.Error()); err != nil {
// Just log the error here. We still want to
Expand Down Expand Up @@ -118,8 +121,10 @@ func (optr *Operator) syncBaremetalControllers(config *OperatorConfig) error {
// Try to get baremetal provisioning config from a CR
baremetalProvisioningConfig, err := getBaremetalProvisioningConfig(optr.dynamicClient, baremetalProvisioningCR)
if err != nil {
// Could not read provisioning-configuration CR.
glog.Errorf("Unable to read Baremetal Provisioning config from CR %s.", baremetalProvisioningCR)
glog.Infof("Will try to read Baremetal Provisioning config from ConfigMap %s instead", baremetalConfigmap)
// This could be a Baremetal deployment that does not require metal3 pod to be deployed.
return nil
}
// Create a Secret needed for the Metal3 deployment
if err := createMariadbPasswordSecret(optr.kubeClient.CoreV1(), config); err != nil {
Expand Down

0 comments on commit 3b6a7c3

Please sign in to comment.