Skip to content

Commit 0b08007

Browse files
committed
Add description field to the migration plan
Signed-off-by: Sergen Yalçın <[email protected]>
1 parent b70acc1 commit 0b08007

9 files changed

+128
-35
lines changed

pkg/migration/api_steps.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,34 +278,44 @@ func (pg *PlanGenerator) stepAPI(s step) *Step { // nolint:gocyclo // all steps
278278
pg.Plan.Spec.stepMap[stepKey] = &Step{}
279279
switch s { // nolint:exhaustive
280280
case stepPauseManaged:
281-
setPatchStep("pause-managed", pg.Plan.Spec.stepMap[stepKey])
281+
setPatchStep("pause-managed", "Adding pause annotation to the Managed Resource so that the Managed Resource is not reconciled during migration",
282+
pg.Plan.Spec.stepMap[stepKey])
282283

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

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

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

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

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

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

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

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

307316
case stepStartComposites:
308-
setPatchStep("start-composites", pg.Plan.Spec.stepMap[stepKey])
317+
setPatchStep("start-composites", "Removing the pause annotation to start the reconciliation of the newly created Composite Resource",
318+
pg.Plan.Spec.stepMap[stepKey])
309319
default:
310320
panic(fmt.Sprintf(errInvalidStepFmt, s))
311321
}

pkg/migration/configurationmetadata_steps.go

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,47 +125,68 @@ func (pg *PlanGenerator) stepConfigurationWithSubStep(s step, newSubStep bool) *
125125
pg.Plan.Spec.stepMap[stepKey] = &Step{}
126126
switch s { // nolint:gocritic,exhaustive
127127
case stepOrphanMRs:
128-
setPatchStep("deletion-policy-orphan", pg.Plan.Spec.stepMap[stepKey])
128+
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",
129+
pg.Plan.Spec.stepMap[stepKey])
129130
case stepRevertOrphanMRs:
130-
setPatchStep("deletion-policy-delete", pg.Plan.Spec.stepMap[stepKey])
131+
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",
132+
pg.Plan.Spec.stepMap[stepKey])
131133
case stepNewFamilyProvider:
132-
setApplyStep("new-ssop", pg.Plan.Spec.stepMap[stepKey])
134+
setApplyStep("new-ssop", "Installing the new family provider",
135+
pg.Plan.Spec.stepMap[stepKey])
133136
case stepNewServiceScopedProvider:
134-
setApplyStep("new-ssop", pg.Plan.Spec.stepMap[stepKey])
137+
setApplyStep("new-ssop", "Installing the new service scoped providers",
138+
pg.Plan.Spec.stepMap[stepKey])
135139
case stepConfigurationPackageDisableDepResolution:
136-
setPatchStep("disable-dependency-resolution", pg.Plan.Spec.stepMap[stepKey])
140+
setPatchStep("disable-dependency-resolution", "Setting the value of skipDependencyResolution field to true so that dependencies in the configuration package are not resolved automatically",
141+
pg.Plan.Spec.stepMap[stepKey])
137142
case stepConfigurationPackageEnableDepResolution:
138-
setPatchStep("enable-dependency-resolution", pg.Plan.Spec.stepMap[stepKey])
143+
setPatchStep("enable-dependency-resolution", "Setting the value of skipDependencyResolution field in the configuration package back to false",
144+
pg.Plan.Spec.stepMap[stepKey])
139145
case stepEditConfigurationPackage:
140-
setPatchStep("edit-configuration-package", pg.Plan.Spec.stepMap[stepKey])
146+
setPatchStep("edit-configuration-package", "Setting the configuration package reference to new one",
147+
pg.Plan.Spec.stepMap[stepKey])
141148
case stepEditPackageLock:
142-
setPatchStep("edit-package-lock", pg.Plan.Spec.stepMap[stepKey])
149+
setPatchStep("edit-package-lock", "Deleting configuration package dependency from Lock resource",
150+
pg.Plan.Spec.stepMap[stepKey])
143151
case stepDeleteMonolithicProvider:
144-
setDeleteStep("delete-monolithic-provider", pg.Plan.Spec.stepMap[stepKey])
152+
setDeleteStep("delete-monolithic-provider", "Deleting monolithic provider",
153+
pg.Plan.Spec.stepMap[stepKey])
145154
case stepActivateFamilyProviderRevision:
146-
setPatchStep("activate-ssop", pg.Plan.Spec.stepMap[stepKey])
155+
setPatchStep("activate-ssop", "Activating the new family provider after deletion monolithic one",
156+
pg.Plan.Spec.stepMap[stepKey])
147157
case stepActivateServiceScopedProviderRevision:
148-
setPatchStep("activate-ssop", pg.Plan.Spec.stepMap[stepKey])
158+
setPatchStep("activate-ssop", "Activating the new service scoped providers",
159+
pg.Plan.Spec.stepMap[stepKey])
149160
case stepEditConfigurationMetadata:
150-
setExecStep("edit-configuration-metadata", pg.Plan.Spec.stepMap[stepKey])
161+
setExecStep("edit-configuration-metadata", "Editing the Configuration Meta resource with new family provider references",
162+
pg.Plan.Spec.stepMap[stepKey])
151163
case stepBackupMRs:
152-
setExecStep("backup-managed-resources", pg.Plan.Spec.stepMap[stepKey])
164+
setExecStep("backup-managed-resources", "Backing up Managed Resources",
165+
pg.Plan.Spec.stepMap[stepKey])
153166
case stepBackupComposites:
154-
setExecStep("backup-composite-resources", pg.Plan.Spec.stepMap[stepKey])
167+
setExecStep("backup-composite-resources", "Backing up Composite Resources",
168+
pg.Plan.Spec.stepMap[stepKey])
155169
case stepBackupClaims:
156-
setExecStep("backup-claim-resources", pg.Plan.Spec.stepMap[stepKey])
170+
setExecStep("backup-claim-resources", "Backing up Claims",
171+
pg.Plan.Spec.stepMap[stepKey])
157172
case stepCheckHealthFamilyProvider:
158-
setExecStep("wait-for-healthy", pg.Plan.Spec.stepMap[stepKey])
173+
setExecStep("wait-for-healthy", "Checking health of new family provider",
174+
pg.Plan.Spec.stepMap[stepKey])
159175
case stepCheckHealthNewServiceScopedProvider:
160-
setExecStep("wait-for-healthy", pg.Plan.Spec.stepMap[stepKey])
176+
setExecStep("wait-for-healthy", "Checking health of new service scoped provider",
177+
pg.Plan.Spec.stepMap[stepKey])
161178
case stepCheckInstallationFamilyProviderRevision:
162-
setExecStep("wait-for-installed", pg.Plan.Spec.stepMap[stepKey])
179+
setExecStep("wait-for-installed", "Checking installation of new family provider",
180+
pg.Plan.Spec.stepMap[stepKey])
163181
case stepCheckInstallationServiceScopedProviderRevision:
164-
setExecStep("wait-for-installed", pg.Plan.Spec.stepMap[stepKey])
182+
setExecStep("wait-for-installed", "Checking installation of new service scoped provider",
183+
pg.Plan.Spec.stepMap[stepKey])
165184
case stepBuildConfiguration:
166-
setExecStep("build-configuration", pg.Plan.Spec.stepMap[stepKey])
185+
setExecStep("build-configuration", "Building the new configuration pkg",
186+
pg.Plan.Spec.stepMap[stepKey])
167187
case stepPushConfiguration:
168-
setExecStep("push-configuration", pg.Plan.Spec.stepMap[stepKey])
188+
setExecStep("push-configuration", "Pushing the new configuration pkg",
189+
pg.Plan.Spec.stepMap[stepKey])
169190
default:
170191
panic(fmt.Sprintf(errInvalidStepFmt, s))
171192
}

pkg/migration/plan_steps.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,22 @@ const (
3636
errInvalidStepFmt = "invalid step ID: %d"
3737
)
3838

39-
func setApplyStep(name string, s *Step) {
39+
func setApplyStep(name, description string, s *Step) {
4040
s.Name = name
4141
s.Type = StepTypeApply
4242
s.Apply = &ApplyStep{}
43+
s.Description = description
4344
}
4445

45-
func setPatchStep(name string, s *Step) {
46+
func setPatchStep(name, description string, s *Step) {
4647
s.Name = name
4748
s.Type = StepTypePatch
4849
s.Patch = &PatchStep{}
4950
s.Patch.Type = PatchTypeMerge
51+
s.Description = description
5052
}
5153

52-
func setDeleteStep(name string, s *Step) {
54+
func setDeleteStep(name, description string, s *Step) {
5355
s.Name = name
5456
s.Type = StepTypeDelete
5557
deletePolicy := FinalizerPolicyRemove
@@ -58,14 +60,16 @@ func setDeleteStep(name string, s *Step) {
5860
FinalizerPolicy: &deletePolicy,
5961
},
6062
}
63+
s.Description = description
6164
}
6265

63-
func setExecStep(name string, s *Step) {
66+
func setExecStep(name, description string, s *Step) {
6467
s.Name = name
6568
s.Type = StepTypeExec
6669
s.Exec = &ExecStep{
6770
Command: "sh",
6871
}
72+
s.Description = description
6973
}
7074

7175
func (pg *PlanGenerator) commitSteps() {

pkg/migration/testdata/plan/generated/configurationv1_migration_plan.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ spec:
99
manualExecution:
1010
- sh -c "kubectl get managed -o yaml > backup/managed-resources.yaml"
1111
type: Exec
12+
description: "Backing up Managed Resources"
1213

1314
- exec:
1415
command: sh
@@ -19,6 +20,7 @@ spec:
1920
manualExecution:
2021
- sh -c "kubectl get composite -o yaml > backup/composite-resources.yaml"
2122
type: Exec
23+
description: "Backing up Composite Resources"
2224

2325
- exec:
2426
command: sh
@@ -29,6 +31,7 @@ spec:
2931
manualExecution:
3032
- sh -c "kubectl get claim --all-namespaces -o yaml > backup/claim-resources.yaml"
3133
type: Exec
34+
description: "Backing up Claims"
3235

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

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

5358
- exec:
5459
command: sh
@@ -59,5 +64,6 @@ spec:
5964
manualExecution:
6065
- sh -c "up xpkg push {{TARGET_CONFIGURATION_PACKAGE}} -f {{PKG_PATH}}"
6166
type: Exec
67+
description: "Pushing the new configuration pkg"
6268

6369
version: 0.1.0

0 commit comments

Comments
 (0)