Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable multiple installations by not failing if all existing default resources exists #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pkg/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ func validateResourcesDoesNotExist(portClient *cli.PortClient, defaults *Default
func createResources(portClient *cli.PortClient, defaults *Defaults, config *port.Config) *AbortDefaultCreationError {
if err := validateResourcesDoesNotExist(portClient, defaults, config); err != nil {
klog.Warningf("Failed to create resources: %v.", err.Errors)
return err
}

bareBlueprints, patchStages := deconstructBlueprintsToCreationSteps(defaults.Blueprints)
Expand Down Expand Up @@ -206,7 +205,6 @@ func createResources(portClient *cli.PortClient, defaults *Defaults, config *por
waitGroup.Wait()

if err := validateResourcesErrors(createdBlueprints, createdPages, resourceErrors); err != nil {
return err
}

for _, patchStage := range patchStages {
Expand All @@ -224,7 +222,6 @@ func createResources(portClient *cli.PortClient, defaults *Defaults, config *por
}

if err := validateResourcesErrors(createdBlueprints, createdPages, resourceErrors); err != nil {
return err
}

for _, blueprintScorecards := range defaults.Scorecards {
Expand All @@ -242,7 +239,6 @@ func createResources(portClient *cli.PortClient, defaults *Defaults, config *por
waitGroup.Wait()

if err := validateResourcesErrors(createdBlueprints, createdPages, resourceErrors); err != nil {
return err
}

for _, pageToCreate := range defaults.Pages {
Expand All @@ -261,12 +257,10 @@ func createResources(portClient *cli.PortClient, defaults *Defaults, config *por
waitGroup.Wait()

if err := validateResourcesErrors(createdBlueprints, createdPages, resourceErrors); err != nil {
return err
}

if err := integration.CreateIntegration(portClient, config.StateKey, config.EventListenerType, defaults.AppConfig); err != nil {
klog.Warningf("Failed to create integration with default configuration. state key %s: %v", config.StateKey, err.Error())
return &AbortDefaultCreationError{BlueprintsToRollback: createdBlueprints, PagesToRollback: createdPages, Errors: []error{err}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we would want to ignore a failure in this case?

}

return nil
Expand Down
8 changes: 4 additions & 4 deletions pkg/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ func Test_InitIntegration_BlueprintExists(t *testing.T) {
assert.Nil(t, e)

i, err := integration.GetIntegration(f.portClient, f.stateKey)
assert.Nil(t, i.Config.Resources)
assert.NotNil(t, i.Config.Resources)
assert.Nil(t, err)

_, err = blueprint.GetBlueprint(f.portClient, "workload")
assert.Nil(t, err)

testUtils.CheckResourcesExistence(false, false, f.portClient, f.t, []string{"namespace", "cluster"}, []string{"workload_overview_dashboard", "availability_scorecard_dashboard"}, []string{})
testUtils.CheckResourcesExistence(true, false, f.portClient, f.t, []string{"namespace", "cluster"}, []string{"workload_overview_dashboard", "availability_scorecard_dashboard"}, []string{})
}

func Test_InitIntegration_PageExists(t *testing.T) {
Expand All @@ -157,13 +157,13 @@ func Test_InitIntegration_PageExists(t *testing.T) {
assert.Nil(t, e)

i, err := integration.GetIntegration(f.portClient, f.stateKey)
assert.Nil(t, i.Config.Resources)
assert.NotNil(t, i.Config.Resources)
assert.Nil(t, err)

_, err = page.GetPage(f.portClient, "workload_overview_dashboard")
assert.Nil(t, err)

testUtils.CheckResourcesExistence(false, false, f.portClient, f.t, []string{"workload", "namespace", "cluster"}, []string{"availability_scorecard_dashboard"}, []string{})
testUtils.CheckResourcesExistence(true, false, f.portClient, f.t, []string{"workload", "namespace", "cluster"}, []string{"availability_scorecard_dashboard"}, []string{})
}

func Test_InitIntegration_ExistingIntegration(t *testing.T) {
Expand Down
Loading