From 97cbd296f1a8ebc480d928ee1ba3fb88024cefa9 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Fri, 26 Jul 2024 13:56:01 +1000 Subject: [PATCH] more work on sets --- pkg/mimo/cmd/cli.go | 1 + pkg/mimo/sets/sets.go | 24 ++++++++++++++++++++++-- pkg/mimo/sets/tls_cert_rotate.go | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 pkg/mimo/sets/tls_cert_rotate.go diff --git a/pkg/mimo/cmd/cli.go b/pkg/mimo/cmd/cli.go index 6857953d2..ab22142be 100644 --- a/pkg/mimo/cmd/cli.go +++ b/pkg/mimo/cmd/cli.go @@ -16,6 +16,7 @@ import ( "github.com/Azure/ARO-RP/pkg/metrics/statsd" "github.com/Azure/ARO-RP/pkg/metrics/statsd/golang" "github.com/Azure/ARO-RP/pkg/mimo/actuator" + "github.com/Azure/ARO-RP/pkg/mimo/sets" "github.com/Azure/ARO-RP/pkg/proxy" utillog "github.com/Azure/ARO-RP/pkg/util/log" "github.com/Azure/ARO-RP/pkg/util/service" diff --git a/pkg/mimo/sets/sets.go b/pkg/mimo/sets/sets.go index 0e003bba2..5b54581ea 100644 --- a/pkg/mimo/sets/sets.go +++ b/pkg/mimo/sets/sets.go @@ -1,8 +1,28 @@ package sets -import "time" +import ( + "time" + + "github.com/Azure/ARO-RP/pkg/api" + "github.com/Azure/ARO-RP/pkg/util/mimo" + "github.com/Azure/ARO-RP/pkg/util/steps" +) const DEFAULT_POLL_TIME = time.Second * 10 const DEFAULT_TIMEOUT_DURATION = time.Minute * 20 -var DEFAULT_MAINTENANCE_SETS = map[string]MaintenanceSet{} +var DEFAULT_MAINTENANCE_SETS = map[string]MaintenanceSet{ + "9b741734-6505-447f-8510-85eb0ae561a2": TLSCertRotation, +} + +func run(t mimo.TaskContext, s []steps.Step) (api.MaintenanceManifestState, string) { + _, err := steps.Run(t, t.Log(), DEFAULT_POLL_TIME, s, t.Now) + + if err != nil { + if mimo.IsRetryableError(err) { + return api.MaintenanceManifestStatePending, err.Error() + } + return api.MaintenanceManifestStateFailed, err.Error() + } + return api.MaintenanceManifestStateCompleted, t.GetResultMessage() +} diff --git a/pkg/mimo/sets/tls_cert_rotate.go b/pkg/mimo/sets/tls_cert_rotate.go new file mode 100644 index 000000000..a687da006 --- /dev/null +++ b/pkg/mimo/sets/tls_cert_rotate.go @@ -0,0 +1,16 @@ +package sets + +import ( + "github.com/Azure/ARO-RP/pkg/api" + "github.com/Azure/ARO-RP/pkg/mimo/tasks/cluster" + "github.com/Azure/ARO-RP/pkg/util/mimo" + "github.com/Azure/ARO-RP/pkg/util/steps" +) + +func TLSCertRotation(t mimo.TaskContext, doc *api.MaintenanceManifestDocument, oc *api.OpenShiftClusterDocument) (api.MaintenanceManifestState, string) { + s := []steps.Step{ + steps.Action(cluster.EnsureAPIServerIsUp), + } + + return run(t, s) +}