Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Fix teardown to clean up operator namespace#82
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,6 +8,7 @@ import ( | ||
| "os" | ||
| "os/exec" | ||
| "strings" | ||
| "sync" | ||
| "time" | ||
| "github.com/fatih/color" | ||
| @@ -571,9 +572,19 @@ func (d *Deployer) Deploy(ctx context.Context, components component.Component, r | ||
| d.logger.Infof("Initiating deployment of %s", components) | ||
| if components.IncludesOperator() { | ||
| // If only deploying operator, use the operator-only flow | ||
| if components.IncludesOperatorExplicitly() { | ||
| return d.deployOperatorOnly(ctx) | ||
| } | ||
| // Deploy operator first if needed (unless using Helm) | ||
| // Operator is required for central/sensor deployments when not using Helm | ||
| if !d.useHelm { | ||
| if err := d.ensureOperatorDeployed(ctx); err != nil { | ||
| return fmt.Errorf("failed to deploy operator: %w", err) | ||
| } | ||
| } | ||
| if components.IncludesCentral() { | ||
| if err := d.deployCentral(ctx, resources, exposure); err != nil { | ||
| return fmt.Errorf("failed to deploy central: %w", err) | ||
| @@ -660,11 +671,40 @@ func (d *Deployer) Teardown(ctx context.Context, components component.Component) | ||
| return d.teardownCentral(ctx) | ||
| case component.SecuredCluster: | ||
| return d.teardownSecuredCluster(ctx) | ||
| case component.All: | ||
| if err := d.teardownSecuredCluster(ctx); err != nil { | ||
| d.logger.Warningf("Error tearing down secured cluster: %v", err) | ||
| case component.Both, component.All: | ||
| // Tear down components in parallel for better performance | ||
| var wg sync.WaitGroup | ||
mclasmeier marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // Always tear down central and sensor | ||
| wg.Add(2) | ||
| go func() { | ||
| defer wg.Done() | ||
| if err := d.teardownSecuredCluster(ctx); err != nil { | ||
| d.logger.Warningf("Error tearing down secured cluster: %v", err) | ||
| } | ||
| }() | ||
| go func() { | ||
| defer wg.Done() | ||
| if err := d.teardownCentral(ctx); err != nil { | ||
| d.logger.Warningf("Error tearing down central: %v", err) | ||
| } | ||
| }() | ||
| // For 'all', also tear down the operator in parallel | ||
| if components == component.All { | ||
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| if err := d.teardownOperator(ctx); err != nil { | ||
| d.logger.Warningf("Error tearing down operator: %v", err) | ||
| } | ||
| }() | ||
| } | ||
| return d.teardownCentral(ctx) | ||
| wg.Wait() | ||
| return nil | ||
| default: | ||
| return fmt.Errorf("unknown component: %s", components) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -24,8 +24,8 @@ const ( | ||
| operatorDeploymentName = "rhacs-operator-controller-manager" | ||
| ) | ||
| // deployOperator deploys the RHACS operator | ||
| func (d *Deployer) deployOperator(ctx context.Context) error { | ||
| // deployOperatorNonOLM deploys the RHACS operator without OLM | ||
| func (d *Deployer) deployOperatorNonOLM(ctx context.Context) error { | ||
| d.logger.Infof("Operator tag: %s", d.operatorTag) | ||
| if d.useKonflux { | ||
| if err := d.ensureKonfluxImageRewriting(ctx); err != nil { | ||
| @@ -396,6 +396,7 @@ metadata: | ||
| name: %s | ||
| labels: | ||
| name: %s | ||
| app.kubernetes.io/managed-by: roxie | ||
AlexVulaj marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| `, operatorNamespace, operatorNamespace) | ||
| _, err := d.runKubectl(ctx, KubectlOptions{ | ||
| @@ -634,3 +635,17 @@ func (d *Deployer) teardownOperatorNonOLM(ctx context.Context) error { | ||
| d.logger.Success("✓ Non-OLM operator resources removed") | ||
| return nil | ||
| } | ||
| // teardownOperator removes the operator if it exists, detecting the deployment mode automatically. | ||
| func (d *Deployer) teardownOperator(ctx context.Context) error { | ||
| operatorExists, operatorMode := d.detectOperatorDeploymentMode(ctx) | ||
| if !operatorExists { | ||
| d.logger.Dim("No operator deployment found, skipping operator teardown") | ||
| return nil | ||
| } | ||
| if operatorMode == OperatorModeOLM { | ||
| return d.teardownOperatorOLM(ctx) | ||
| } | ||
| return d.teardownOperatorNonOLM(ctx) | ||
| } | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.