Skip to content

Commit

Permalink
Recovery plans only store the "name" of a resolution
Browse files Browse the repository at this point in the history
The "plan" is not necessary for resolving problems via the director

[#185483613]

Authored-by: Chris Selzo <[email protected]>
  • Loading branch information
selzoc committed Jul 3, 2023
1 parent 763d0a4 commit cecc52c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions cmd/create_recovery_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
)

type InstanceGroupPlan struct {
Name string `yaml:"name"`
MaxInFlight string `yaml:"max_in_flight,omitempty"`
PlannedResolutions map[string]boshdir.ProblemResolution `yaml:"planned_resolutions"`
Name string `yaml:"name"`
MaxInFlight string `yaml:"max_in_flight,omitempty"`
PlannedResolutions map[string]string `yaml:"planned_resolutions"`
}

type RecoveryPlan struct {
Expand Down Expand Up @@ -80,10 +80,10 @@ func sortedInstanceGroups(problemsByInstanceGroup map[string][]boshdir.Problem)
return instanceGroups
}

func (c CreateRecoveryPlanCmd) processProblemsByType(problems []boshdir.Problem) (map[string]boshdir.ProblemResolution, error) {
func (c CreateRecoveryPlanCmd) processProblemsByType(problems []boshdir.Problem) (map[string]string, error) {
problemsByType := mapProblemsByTrait(problems, func(p boshdir.Problem) string { return p.Type })

resolutions := make(map[string]boshdir.ProblemResolution)
resolutions := make(map[string]string)
for problemType, problemsForType := range problemsByType {
c.printProblemTable(problemType, problemsForType)

Expand All @@ -97,7 +97,7 @@ func (c CreateRecoveryPlanCmd) processProblemsByType(problems []boshdir.Problem)
return nil, err
}

resolutions[problemType] = problemsForType[0].Resolutions[chosenIndex]
resolutions[problemType] = *problemsForType[0].Resolutions[chosenIndex].Name
}

return resolutions, nil
Expand Down
6 changes: 3 additions & 3 deletions cmd/create_recovery_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ var _ = Describe("CreateRecoveryPlanCmd", func() {

Expect(actualPlan.InstanceGroupsPlan[0].Name).To(Equal("diego_cell"))
Expect(actualPlan.InstanceGroupsPlan[0].PlannedResolutions).To(HaveLen(1))
Expect(actualPlan.InstanceGroupsPlan[0].PlannedResolutions).To(HaveKeyWithValue("unresponsive_agent", skipResolution))
Expect(actualPlan.InstanceGroupsPlan[0].PlannedResolutions).To(HaveKeyWithValue("unresponsive_agent", *skipResolution.Name))

Expect(actualPlan.InstanceGroupsPlan[1].Name).To(Equal("router"))
Expect(actualPlan.InstanceGroupsPlan[1].PlannedResolutions).To(HaveLen(2))
Expect(actualPlan.InstanceGroupsPlan[1].PlannedResolutions).To(HaveKeyWithValue("missing_vm", recreateResolution))
Expect(actualPlan.InstanceGroupsPlan[1].PlannedResolutions).To(HaveKeyWithValue("mount_info_mismatch", reattachDiskAndRebootResolution))
Expect(actualPlan.InstanceGroupsPlan[1].PlannedResolutions).To(HaveKeyWithValue("missing_vm", *recreateResolution.Name))
Expect(actualPlan.InstanceGroupsPlan[1].PlannedResolutions).To(HaveKeyWithValue("mount_info_mismatch", *reattachDiskAndRebootResolution.Name))
})

It("returns an error if asking fails", func() {
Expand Down

0 comments on commit cecc52c

Please sign in to comment.