Skip to content

Commit

Permalink
Add maintenance state for customer action needed (Azure#3294)
Browse files Browse the repository at this point in the history
  • Loading branch information
niontive authored and ventifus committed Feb 7, 2024
1 parent 7768311 commit 90cd002
Show file tree
Hide file tree
Showing 8 changed files with 570 additions and 17 deletions.
25 changes: 19 additions & 6 deletions pkg/api/admin/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,37 @@ const (
type MaintenanceState string

const (
MaintenanceStateNone MaintenanceState = "None"
MaintenanceStatePending MaintenanceState = "Pending"
MaintenanceStatePlanned MaintenanceState = "Planned"
MaintenanceStateUnplanned MaintenanceState = "Unplanned"
MaintenanceStateNone MaintenanceState = "None"
MaintenanceStatePending MaintenanceState = "Pending"
MaintenanceStatePlanned MaintenanceState = "Planned"
MaintenanceStateUnplanned MaintenanceState = "Unplanned"
MaintenanceStateCustomerActionNeeded MaintenanceState = "CustomerActionNeeded"
)

type MaintenanceTask string

const (
//
// Maintenance tasks that perform work on the cluster
//

MaintenanceTaskEverything MaintenanceTask = "Everything"
MaintenanceTaskOperator MaintenanceTask = "OperatorUpdate"
MaintenanceTaskRenewCerts MaintenanceTask = "CertificatesRenewal"

//
// Maintenance tasks for updating customer maintenance signals
//

MaintenanceTaskPending MaintenanceTask = "Pending"

// None signal should only be used when (1) admin update fails and (2) SRE fixes the failed admin update without running another admin updates
// Admin update success should automatically set the cluster into None state
MaintenanceTaskPending MaintenanceTask = "Pending"
MaintenanceTaskNone MaintenanceTask = "None"
MaintenanceTaskNone MaintenanceTask = "None"

// Customer action needed signal should only be used when (1) admin update fails and (2) customer needs to take action to resolve the failure
// To remove the signal after customer takes action, use maintenance task None
MaintenanceTaskCustomerActionNeeded MaintenanceTask = "CustomerActionNeeded"
)

// Operator feature flags
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/admin/openshiftcluster_validatestatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func validateMaintenanceTask(task MaintenanceTask) error {
task == MaintenanceTaskOperator ||
task == MaintenanceTaskRenewCerts ||
task == MaintenanceTaskPending ||
task == MaintenanceTaskNone) {
task == MaintenanceTaskNone ||
task == MaintenanceTaskCustomerActionNeeded) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "properties.maintenanceTask", "Invalid enum parameter.")
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/api/admin/openshiftcluster_validatestatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,19 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
oc.Properties.MaintenanceTask = ""
},
},
{
name: "maintenanceTask change to customer action needed allowed",
oc: func() *OpenShiftCluster {
return &OpenShiftCluster{
Properties: OpenShiftClusterProperties{
MaintenanceTask: MaintenanceTaskCustomerActionNeeded,
},
}
},
modify: func(oc *OpenShiftCluster) {
oc.Properties.MaintenanceTask = ""
},
},
{
name: "maintenanceTask change to other values is disallowed",
oc: func() *OpenShiftCluster {
Expand Down
25 changes: 19 additions & 6 deletions pkg/api/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,37 @@ const (
type MaintenanceState string

const (
MaintenanceStateNone MaintenanceState = "None"
MaintenanceStatePending MaintenanceState = "Pending"
MaintenanceStatePlanned MaintenanceState = "Planned"
MaintenanceStateUnplanned MaintenanceState = "Unplanned"
MaintenanceStateNone MaintenanceState = "None"
MaintenanceStatePending MaintenanceState = "Pending"
MaintenanceStatePlanned MaintenanceState = "Planned"
MaintenanceStateUnplanned MaintenanceState = "Unplanned"
MaintenanceStateCustomerActionNeeded MaintenanceState = "CustomerActionNeeded"
)

type MaintenanceTask string

const (
//
// Maintenance tasks that perform work on the cluster
//

MaintenanceTaskEverything MaintenanceTask = "Everything"
MaintenanceTaskOperator MaintenanceTask = "OperatorUpdate"
MaintenanceTaskRenewCerts MaintenanceTask = "CertificatesRenewal"

//
// Maintenance tasks for updating customer maintenance signals
//

MaintenanceTaskPending MaintenanceTask = "Pending"

// None signal should only be used when (1) admin update fails and (2) SRE fixes the failed admin update without running another admin updates
// Admin update success should automatically set the cluster into None state
MaintenanceTaskPending MaintenanceTask = "Pending"
MaintenanceTaskNone MaintenanceTask = "None"
MaintenanceTaskNone MaintenanceTask = "None"

// Customer action needed signal should only be used when (1) admin update fails and (2) customer needs to take action to resolve the failure
// To remove the signal after customer takes action, use maintenance task None
MaintenanceTaskCustomerActionNeeded MaintenanceTask = "CustomerActionNeeded"
)

// IsMaintenanceOngoingTask returns true if the maintenance task should change state to maintenance ongoing (planned/unplanned)
Expand Down
2 changes: 2 additions & 0 deletions pkg/frontend/openshiftcluster_putorpatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ func adminUpdateProvisioningState(doc *api.OpenShiftClusterDocument) {
doc.OpenShiftCluster.Properties.MaintenanceState = api.MaintenanceStatePending
case api.MaintenanceTaskNone:
doc.OpenShiftCluster.Properties.MaintenanceState = api.MaintenanceStateNone
case api.MaintenanceTaskCustomerActionNeeded:
doc.OpenShiftCluster.Properties.MaintenanceState = api.MaintenanceStateCustomerActionNeeded
}

// This enables future admin update actions with body `{}` to succeed
Expand Down
Loading

0 comments on commit 90cd002

Please sign in to comment.