Skip to content

Commit

Permalink
PRODENG-2702 mke uninstall activate fix (#493)
Browse files Browse the repository at this point in the history
- MKE uninstall check in phase manager build for the reset command was
  testing if mke.Metadata.Installed, before it could be set.
- MKE uninstall phase now added as long as MKE config block is included
- MKE uninstall phase checks installed status before running

Signed-off-by: James Nesbitt <[email protected]>
  • Loading branch information
james-nesbitt authored Aug 2, 2024
1 parent d23933d commit b3ebb7c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/product/mke/api/cluster_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestMKEClusterSpecMKEURLWithNoMSRMetadata(t *testing.T) {
manager,
msr2,
},
MKE: &MKEConfig{},
MKE: &MKEConfig{},
MSR2: &MSR2Config{},
}

Expand All @@ -83,7 +83,7 @@ func TestMKEClusterSpecMSR2URLWithNoMSRMetadata(t *testing.T) {
manager,
msr2,
},
MKE: &MKEConfig{},
MKE: &MKEConfig{},
MSR2: &MSR2Config{},
}

Expand Down Expand Up @@ -116,7 +116,7 @@ func TestMKEClusterSpecMSR2URLWithoutExternalURL(t *testing.T) {
MSR2Metadata: &MSR2Metadata{Installed: true},
},
},
MKE: &MKEConfig{},
MKE: &MKEConfig{},
MSR2: &MSR2Config{},
}
url, err := spec.MSR2URL()
Expand Down
6 changes: 6 additions & 0 deletions pkg/product/mke/phase/uninstall_mke.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ func (p *UninstallMKE) Title() string {
return "Uninstall MKE components"
}

// ShouldRun should return true only when there is an installation to be
// performed.
func (p *UninstallMKE) ShouldRun() bool {
return p.Config.Spec.MKE != nil && p.Config.Spec.MKE.Metadata != nil && p.Config.Spec.MKE.Metadata.Installed
}

// Run the installer container.
func (p *UninstallMKE) Run() error {
swarmLeader := p.Config.Spec.SwarmLeader()
Expand Down
2 changes: 1 addition & 1 deletion pkg/product/mke/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (p *MKE) Reset() error {
phaseManager.AddPhase(&mke.UninstallMSR3{})
}

if p.ClusterConfig.Spec.MKE != nil && p.ClusterConfig.Spec.MKE.Metadata.Installed {
if p.ClusterConfig.Spec.MKE != nil {
phaseManager.AddPhases(
&mke.UninstallMKE{},
)
Expand Down

0 comments on commit b3ebb7c

Please sign in to comment.