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 21, 2020
1 parent b9b4aae commit 311e7b3
Show file tree
Hide file tree
Showing 2 changed files with 13 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
7 changes: 4 additions & 3 deletions pkg/operator/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ 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
if config.BaremetalControllers.BaremetalOperator != "" {
// In addition, if the Provider is BareMetal and a provisioning config is available,
// then bring up the baremetal-operator pod
if config.BaremetalControllers.BaremetalOperator != "" &&
isBaremetalProvisioningConfigAvailable(optr.dynamicClient, baremetalProvisioningCR) {
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

0 comments on commit 311e7b3

Please sign in to comment.