Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions pkg/controller/clusterstorage/clusterstorage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
)

var log = logf.Log.WithName("controller_clusterstorage")
var unsupportedPlatformError = errors.New("unsupported platform")

const (
// OwnerLabelNamespace is the label key for the owner namespace
Expand Down Expand Up @@ -191,34 +192,42 @@ func (r *ReconcileClusterStorage) syncStatus(clusterOperator *configv1.ClusterOp
Status: configv1.ConditionFalse,
}
v1helpers.SetStatusCondition(&clusterOperator.Status.Conditions, notProgressing)
var message string

// if error is anything other than unsupported platform, we are failing
if err != nil {
failing := configv1.ClusterOperatorStatusCondition{
Type: configv1.OperatorFailing,
Status: configv1.ConditionTrue,
Reason: "Error",
Message: err.Error(),
}
v1helpers.SetStatusCondition(&clusterOperator.Status.Conditions, failing)
if err != unsupportedPlatformError {
failing := configv1.ClusterOperatorStatusCondition{
Type: configv1.OperatorFailing,
Status: configv1.ConditionTrue,
Reason: "Error",
Message: err.Error(),
}
v1helpers.SetStatusCondition(&clusterOperator.Status.Conditions, failing)

unavailable := configv1.ClusterOperatorStatusCondition{
Type: configv1.OperatorAvailable,
Status: configv1.ConditionFalse,
}
v1helpers.SetStatusCondition(&clusterOperator.Status.Conditions, unavailable)
unavailable := configv1.ClusterOperatorStatusCondition{
Type: configv1.OperatorAvailable,
Status: configv1.ConditionFalse,
}
v1helpers.SetStatusCondition(&clusterOperator.Status.Conditions, unavailable)

updateErr := r.client.Status().Update(context.TODO(), clusterOperator)
if updateErr != nil {
log.Error(updateErr, "Failed to update ClusterOperator status")
return updateErr
updateErr := r.client.Status().Update(context.TODO(), clusterOperator)
if updateErr != nil {
log.Error(updateErr, "Failed to update ClusterOperator status")
return updateErr
}
return nil
}
return nil
message = "Unsupported platform for storageclass creation"
}

available := configv1.ClusterOperatorStatusCondition{
Type: configv1.OperatorAvailable,
Status: configv1.ConditionTrue,
}
if message != "" {
available.Message = message
}
v1helpers.SetStatusCondition(&clusterOperator.Status.Conditions, available)

notFailing := configv1.ClusterOperatorStatusCondition{
Expand Down Expand Up @@ -247,7 +256,7 @@ func newStorageClassForCluster(cm *corev1.ConfigMap) (*storagev1.StorageClass, e
return resourceread.ReadStorageClassV1OrDie(generated.MustAsset("assets/openstack.yaml")), nil
}

return nil, errors.New("unsupported platform")
return nil, unsupportedPlatformError
}

func getPlatform(cm *corev1.ConfigMap) (*installer.Platform, error) {
Expand Down