Skip to content

Commit

Permalink
Add description field to the migration plan
Browse files Browse the repository at this point in the history
Signed-off-by: Sergen Yalçın <[email protected]>
  • Loading branch information
sergenyalcin committed Jul 20, 2023
1 parent b70acc1 commit 0b08007
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 35 deletions.
30 changes: 20 additions & 10 deletions pkg/migration/api_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,34 +278,44 @@ func (pg *PlanGenerator) stepAPI(s step) *Step { // nolint:gocyclo // all steps
pg.Plan.Spec.stepMap[stepKey] = &Step{}
switch s { // nolint:exhaustive
case stepPauseManaged:
setPatchStep("pause-managed", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("pause-managed", "Adding pause annotation to the Managed Resource so that the Managed Resource is not reconciled during migration",
pg.Plan.Spec.stepMap[stepKey])

case stepPauseComposites:
setPatchStep("pause-composites", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("pause-composites", "Adding pause annotation to the Composite Resource so that the Composite Resource is not reconciled during migration",
pg.Plan.Spec.stepMap[stepKey])

case stepCreateNewManaged:
setApplyStep("create-new-managed", pg.Plan.Spec.stepMap[stepKey])
setApplyStep("create-new-managed", "Creating the Managed Resource that has the new API",
pg.Plan.Spec.stepMap[stepKey])

case stepNewCompositions:
setApplyStep("new-compositions", pg.Plan.Spec.stepMap[stepKey])
setApplyStep("new-compositions", "Creating the Compositions that have the new API",
pg.Plan.Spec.stepMap[stepKey])

case stepEditComposites:
setPatchStep("edit-composites", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("edit-composites", "Editing the Composite Resources with the correct references",
pg.Plan.Spec.stepMap[stepKey])

case stepEditClaims:
setPatchStep("edit-claims", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("edit-claims", "Editing the Claims with the correct references",
pg.Plan.Spec.stepMap[stepKey])

case stepDeletionPolicyOrphan:
setPatchStep("deletion-policy-orphan", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("deletion-policy-orphan", "Setting Deletion Policy to Orphan before deleting old Managed Resource so that physical resource is not deleted",
pg.Plan.Spec.stepMap[stepKey])

case stepDeleteOldManaged:
setDeleteStep("delete-old-managed", pg.Plan.Spec.stepMap[stepKey])
setDeleteStep("delete-old-managed", "Deleting the old Managed Resource",
pg.Plan.Spec.stepMap[stepKey])

case stepStartManaged:
setPatchStep("start-managed", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("start-managed", "Removing the pause annotation to start the reconciliation of the newly created Managed Resource",
pg.Plan.Spec.stepMap[stepKey])

case stepStartComposites:
setPatchStep("start-composites", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("start-composites", "Removing the pause annotation to start the reconciliation of the newly created Composite Resource",
pg.Plan.Spec.stepMap[stepKey])
default:
panic(fmt.Sprintf(errInvalidStepFmt, s))
}
Expand Down
63 changes: 42 additions & 21 deletions pkg/migration/configurationmetadata_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,47 +125,68 @@ func (pg *PlanGenerator) stepConfigurationWithSubStep(s step, newSubStep bool) *
pg.Plan.Spec.stepMap[stepKey] = &Step{}
switch s { // nolint:gocritic,exhaustive
case stepOrphanMRs:
setPatchStep("deletion-policy-orphan", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("deletion-policy-orphan", "Setting the deletion policies of Managed Resources to Orphan as a precaution against any unexpected problems that may occur during migration",
pg.Plan.Spec.stepMap[stepKey])
case stepRevertOrphanMRs:
setPatchStep("deletion-policy-delete", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("deletion-policy-delete", "Setting the deletion policies of Managed Resources whose deletion policy is set to Orphan at the beginning of the migration, to Delete again",
pg.Plan.Spec.stepMap[stepKey])
case stepNewFamilyProvider:
setApplyStep("new-ssop", pg.Plan.Spec.stepMap[stepKey])
setApplyStep("new-ssop", "Installing the new family provider",
pg.Plan.Spec.stepMap[stepKey])
case stepNewServiceScopedProvider:
setApplyStep("new-ssop", pg.Plan.Spec.stepMap[stepKey])
setApplyStep("new-ssop", "Installing the new service scoped providers",
pg.Plan.Spec.stepMap[stepKey])
case stepConfigurationPackageDisableDepResolution:
setPatchStep("disable-dependency-resolution", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("disable-dependency-resolution", "Setting the value of skipDependencyResolution field to true so that dependencies in the configuration package are not resolved automatically",
pg.Plan.Spec.stepMap[stepKey])
case stepConfigurationPackageEnableDepResolution:
setPatchStep("enable-dependency-resolution", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("enable-dependency-resolution", "Setting the value of skipDependencyResolution field in the configuration package back to false",
pg.Plan.Spec.stepMap[stepKey])
case stepEditConfigurationPackage:
setPatchStep("edit-configuration-package", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("edit-configuration-package", "Setting the configuration package reference to new one",
pg.Plan.Spec.stepMap[stepKey])
case stepEditPackageLock:
setPatchStep("edit-package-lock", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("edit-package-lock", "Deleting configuration package dependency from Lock resource",
pg.Plan.Spec.stepMap[stepKey])
case stepDeleteMonolithicProvider:
setDeleteStep("delete-monolithic-provider", pg.Plan.Spec.stepMap[stepKey])
setDeleteStep("delete-monolithic-provider", "Deleting monolithic provider",
pg.Plan.Spec.stepMap[stepKey])
case stepActivateFamilyProviderRevision:
setPatchStep("activate-ssop", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("activate-ssop", "Activating the new family provider after deletion monolithic one",
pg.Plan.Spec.stepMap[stepKey])
case stepActivateServiceScopedProviderRevision:
setPatchStep("activate-ssop", pg.Plan.Spec.stepMap[stepKey])
setPatchStep("activate-ssop", "Activating the new service scoped providers",
pg.Plan.Spec.stepMap[stepKey])
case stepEditConfigurationMetadata:
setExecStep("edit-configuration-metadata", pg.Plan.Spec.stepMap[stepKey])
setExecStep("edit-configuration-metadata", "Editing the Configuration Meta resource with new family provider references",
pg.Plan.Spec.stepMap[stepKey])
case stepBackupMRs:
setExecStep("backup-managed-resources", pg.Plan.Spec.stepMap[stepKey])
setExecStep("backup-managed-resources", "Backing up Managed Resources",
pg.Plan.Spec.stepMap[stepKey])
case stepBackupComposites:
setExecStep("backup-composite-resources", pg.Plan.Spec.stepMap[stepKey])
setExecStep("backup-composite-resources", "Backing up Composite Resources",
pg.Plan.Spec.stepMap[stepKey])
case stepBackupClaims:
setExecStep("backup-claim-resources", pg.Plan.Spec.stepMap[stepKey])
setExecStep("backup-claim-resources", "Backing up Claims",
pg.Plan.Spec.stepMap[stepKey])
case stepCheckHealthFamilyProvider:
setExecStep("wait-for-healthy", pg.Plan.Spec.stepMap[stepKey])
setExecStep("wait-for-healthy", "Checking health of new family provider",
pg.Plan.Spec.stepMap[stepKey])
case stepCheckHealthNewServiceScopedProvider:
setExecStep("wait-for-healthy", pg.Plan.Spec.stepMap[stepKey])
setExecStep("wait-for-healthy", "Checking health of new service scoped provider",
pg.Plan.Spec.stepMap[stepKey])
case stepCheckInstallationFamilyProviderRevision:
setExecStep("wait-for-installed", pg.Plan.Spec.stepMap[stepKey])
setExecStep("wait-for-installed", "Checking installation of new family provider",
pg.Plan.Spec.stepMap[stepKey])
case stepCheckInstallationServiceScopedProviderRevision:
setExecStep("wait-for-installed", pg.Plan.Spec.stepMap[stepKey])
setExecStep("wait-for-installed", "Checking installation of new service scoped provider",
pg.Plan.Spec.stepMap[stepKey])
case stepBuildConfiguration:
setExecStep("build-configuration", pg.Plan.Spec.stepMap[stepKey])
setExecStep("build-configuration", "Building the new configuration pkg",
pg.Plan.Spec.stepMap[stepKey])
case stepPushConfiguration:
setExecStep("push-configuration", pg.Plan.Spec.stepMap[stepKey])
setExecStep("push-configuration", "Pushing the new configuration pkg",
pg.Plan.Spec.stepMap[stepKey])
default:
panic(fmt.Sprintf(errInvalidStepFmt, s))
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/migration/plan_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ const (
errInvalidStepFmt = "invalid step ID: %d"
)

func setApplyStep(name string, s *Step) {
func setApplyStep(name, description string, s *Step) {
s.Name = name
s.Type = StepTypeApply
s.Apply = &ApplyStep{}
s.Description = description
}

func setPatchStep(name string, s *Step) {
func setPatchStep(name, description string, s *Step) {
s.Name = name
s.Type = StepTypePatch
s.Patch = &PatchStep{}
s.Patch.Type = PatchTypeMerge
s.Description = description
}

func setDeleteStep(name string, s *Step) {
func setDeleteStep(name, description string, s *Step) {
s.Name = name
s.Type = StepTypeDelete
deletePolicy := FinalizerPolicyRemove
Expand All @@ -58,14 +60,16 @@ func setDeleteStep(name string, s *Step) {
FinalizerPolicy: &deletePolicy,
},
}
s.Description = description
}

func setExecStep(name string, s *Step) {
func setExecStep(name, description string, s *Step) {
s.Name = name
s.Type = StepTypeExec
s.Exec = &ExecStep{
Command: "sh",
}
s.Description = description
}

func (pg *PlanGenerator) commitSteps() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ spec:
manualExecution:
- sh -c "kubectl get managed -o yaml > backup/managed-resources.yaml"
type: Exec
description: "Backing up Managed Resources"

- exec:
command: sh
Expand All @@ -19,6 +20,7 @@ spec:
manualExecution:
- sh -c "kubectl get composite -o yaml > backup/composite-resources.yaml"
type: Exec
description: "Backing up Composite Resources"

- exec:
command: sh
Expand All @@ -29,6 +31,7 @@ spec:
manualExecution:
- sh -c "kubectl get claim --all-namespaces -o yaml > backup/claim-resources.yaml"
type: Exec
description: "Backing up Claims"

- exec:
command: sh
Expand All @@ -39,6 +42,7 @@ spec:
manualExecution:
- sh -c "cp edit-configuration-metadata/platform-ref-aws.configurations.meta.pkg.crossplane.io_v1.yaml testdata/plan/configurationv1.yaml"
type: Exec
description: "Editing the Configuration Meta resource with new family provider references"

- exec:
command: sh
Expand All @@ -49,6 +53,7 @@ spec:
manualExecution:
- sh -c "up xpkg build --package-root={{PKG_ROOT}} --examples-root={{EXAMPLES_ROOT}} -o {{PKG_PATH}}"
type: Exec
description: "Building the new configuration pkg"

- exec:
command: sh
Expand All @@ -59,5 +64,6 @@ spec:
manualExecution:
- sh -c "up xpkg push {{TARGET_CONFIGURATION_PACKAGE}} -f {{PKG_PATH}}"
type: Exec
description: "Pushing the new configuration pkg"

version: 0.1.0
Loading

0 comments on commit 0b08007

Please sign in to comment.