Skip to content

Commit

Permalink
Merge pull request rook#4965 from nizamial09/follow_state
Browse files Browse the repository at this point in the history
ceph: Follow up for adding the state variable
  • Loading branch information
travisn authored Mar 4, 2020
2 parents 545630c + 3296fc6 commit 022ff8a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
13 changes: 12 additions & 1 deletion pkg/apis/ceph.rook.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ type MonitoringSpec struct {
}

type ClusterStatus struct {
State string `json:"state,omitempty"`
State ClusterState `json:"state,omitempty"`
Phase ConditionType `json:"phase,omitempty"`
Message string `json:"message,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
Expand Down Expand Up @@ -193,6 +193,17 @@ const (
DefaultFailureDomain = "host"
)

type ClusterState string

const (
ClusterStateCreating ClusterState = "Creating"
ClusterStateCreated ClusterState = "Created"
ClusterStateUpdating ClusterState = "Updating"
ClusterStateConnecting ClusterState = "Connecting"
ClusterStateConnected ClusterState = "Connected"
ClusterStateError ClusterState = "Error"
)

type MonSpec struct {
Count int `json:"count,omitempty"`
AllowMultiplePerNode bool `json:"allowMultiplePerNode,omitempty"`
Expand Down
34 changes: 20 additions & 14 deletions pkg/operator/ceph/config/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,27 @@ func setCondition(context *clusterd.Context, namespace, name string, newConditio
// 2. We can't change the enum values of the State since that is also
// a breaking change. Therefore, we translate new phases to the original
// State values
func translatePhasetoState(phase cephv1.ConditionType) string {
if phase == cephv1.ConditionProgressing {
return "Creating"
} else if phase == cephv1.ConditionReady {
return "Created"
} else if phase == cephv1.ConditionUpgrading || phase == cephv1.ConditionUpdating {
return "Updating"
} else if phase == cephv1.ConditionFailure || phase == cephv1.ConditionIgnored {
return "Error"
} else if phase == cephv1.ConditionConnected {
return "Connected"
} else if phase == cephv1.ConditionConnecting {
return "Connecting"
func translatePhasetoState(phase cephv1.ConditionType) cephv1.ClusterState {
switch phase {
case cephv1.ConditionConnecting:
return cephv1.ClusterStateConnecting
case cephv1.ConditionConnected:
return cephv1.ClusterStateConnected
case cephv1.ConditionFailure:
return cephv1.ClusterStateError
case cephv1.ConditionIgnored:
return cephv1.ClusterStateError
case cephv1.ConditionProgressing:
return cephv1.ClusterStateCreating
case cephv1.ConditionReady:
return cephv1.ClusterStateCreated
case cephv1.ConditionUpgrading:
return cephv1.ClusterStateUpdating
case cephv1.ConditionUpdating:
return cephv1.ClusterStateUpdating
default:
return ""
}
return ""
}

// Updating the status of Progressing, Updating or Upgrading to False once cluster is Ready
Expand Down

0 comments on commit 022ff8a

Please sign in to comment.