Skip to content

feat: add --no-wait flag for CloudFormation stack operations#60

Open
cdoan1 wants to merge 2 commits into
openshift-online:mainfrom
cdoan1:ROSAENG-1071
Open

feat: add --no-wait flag for CloudFormation stack operations#60
cdoan1 wants to merge 2 commits into
openshift-online:mainfrom
cdoan1:ROSAENG-1071

Conversation

@cdoan1

@cdoan1 cdoan1 commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Add --no-wait flag to all create and delete subcommands to allow non-blocking CloudFormation operations. When set, the CLI submits the stack operation and returns immediately without waiting for completion.

Changes:

  • CloudFormation client: Add NoWait field to CreateStackParams, UpdateStackParams, and DeleteStack signature
  • Service layer: Thread NoWait through all Create/Delete request structs (clustervpc, clusteriam, clusteroidc)
  • Command layer: Add --no-wait flag to all create/delete commands and adjust output messages accordingly

This reduces CI pipeline time by allowing async stack teardown in pre-merge e2e tests while preserving blocking behavior by default for reliability.

Fixes: ROSAENG-1071

Description

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or tooling change

Testing

  • Unit tests pass (make test)
  • Integration tests pass (if applicable)
  • Manual verification completed

Checklist

  • My code follows the project's coding conventions
  • I have updated documentation as needed
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass

Summary by CodeRabbit

New Features

  • Added a --no-wait flag to bootstrap, cluster-iam, cluster-oidc, and cluster-vpc create and delete commands (defaulting to enabled). When set, commands now submit the CloudFormation operation immediately and return stack IDs for progress tracking instead of waiting to complete.

Bug Fixes

  • Improved stack operation handling so “no-wait” paths return quickly using the submitted stack identifier (and creation outputs are only shown when waiting).

@openshift-ci

openshift-ci Bot commented May 13, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cdoan1

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 13, 2026
@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

Walkthrough

CloudFormation operations (create, update, delete) across multiple commands now support a --no-wait flag that returns immediately with a stack ID instead of polling until completion. The client, service request structures, and command implementations are updated consistently to thread this flag through the call chain.

Changes

Async CloudFormation Operations

Layer / File(s) Summary
CloudFormation client and parameter updates
internal/aws/cloudformation/client.go, internal/aws/cloudformation/stack.go
CreateStack and UpdateStack now capture the API response and return early with stack ID when NoWait is true, bypassing waiter polling. DeleteStack accepts a noWait parameter with matching behavior. CreateStackParams and UpdateStackParams each add a NoWait bool field.
Service request structures
internal/services/clusteriam/service.go, internal/services/clusteroidc/service.go, internal/services/clustervpc/service.go
Six request types add a NoWait bool field: CreateIAMRequest, DeleteIAMRequest, CreateOIDCRequest, DeleteOIDCRequest, CreateVPCRequest, and DeleteVPCRequest.
Service method implementations
internal/services/clusteriam/service.go, internal/services/clusteroidc/service.go, internal/services/clustervpc/service.go
Service methods (CreateIAM, updateIAM, DeleteIAM, CreateOIDC, updateOIDCStack, updateIAMTrustPolicies, DeleteOIDC, CreateVPC, DeleteVPC) read NoWait from requests and propagate it into CloudFormation client calls.
Bootstrap create and delete commands
internal/commands/bootstrap/create.go, internal/commands/bootstrap/delete.go
Both commands add --no-wait flags (default true) to options. runCreate and runDelete forward the flag into service requests and conditionally output "submitted" or success messages.
Cluster IAM create and delete commands
internal/commands/clusteriam/create.go, internal/commands/clusteriam/delete.go
Commands add --no-wait flag. runCreate wires NoWait into both CreateIAMRequest and CreateOIDCRequest; runDelete applies it to DeleteIAMRequest. Output branches between async and sync messaging.
Cluster OIDC create and delete commands
internal/commands/clusteroidc/create.go, internal/commands/clusteroidc/delete.go
Commands add --no-wait flag. Output conditionally prints "submitted" messages with stack IDs or success messages with stack IDs and resource details.
Cluster VPC create and delete commands
internal/commands/clustervpc/create.go, internal/commands/clustervpc/delete.go
Commands add --no-wait flag wired to service requests. Output branches between async "submitted" messages (with status-check instructions) and success messages with outputs.

Sequence Diagram

sequenceDiagram
    participant User
    participant Cmd as Command Handler
    participant Svc as Service Layer
    participant CFN as CloudFormation Client
    participant AWS as AWS CloudFormation

    rect rgba(100, 200, 100, 0.5)
    Note over User,AWS: Synchronous Operation (default --no-wait=false)
    User->>Cmd: create --stack mystack
    Cmd->>Svc: CreateRequest{NoWait: false}
    Svc->>CFN: CreateStack{NoWait: false}
    CFN->>AWS: CreateStack API
    AWS-->>CFN: StackId
    CFN->>CFN: Poll DescribeStacks
    AWS-->>CFN: Status: CREATE_COMPLETE
    CFN->>AWS: DescribeStackResources
    AWS-->>CFN: Outputs
    CFN-->>Svc: StackOutput{StackId, Outputs}
    Svc-->>Cmd: {StackId, Outputs}
    Cmd->>User: Created successfully! Outputs: [...]
    end

    rect rgba(200, 100, 100, 0.5)
    Note over User,AWS: Asynchronous Operation (--no-wait=true)
    User->>Cmd: create --stack mystack --no-wait
    Cmd->>Svc: CreateRequest{NoWait: true}
    Svc->>CFN: CreateStack{NoWait: true}
    CFN->>AWS: CreateStack API
    AWS-->>CFN: StackId
    CFN-->>Svc: StackOutput{StackId, Outputs: nil}
    Svc-->>Cmd: {StackId, Outputs: nil}
    Cmd->>User: Stack creation submitted! StackId: xyz (Check status: describe ...)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
Container-Privileges ❌ Error The PR introduces docker-compose.localstack.yaml with privileged: true and user: "0" (root). While this is for local testing and has justification comment, it violates the security check requirements. Remove privileged: true and user: "0" from docker-compose.localstack.yaml, or restrict this file to development-only with clear warnings about local-only usage.
Docstring Coverage ⚠️ Warning Docstring coverage is 26.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Ai-Attribution ⚠️ Warning AI tool (Claude Sonnet 4.5) was used but attributed incorrectly with Co-Authored-By instead of proper Red Hat trailers (Assisted-by or Generated-by). Replace Co-Authored-By trailer with proper Red Hat attribution: Assisted-by or Generated-by for the AI-assisted/generated work.
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: adding a --no-wait flag for CloudFormation stack operations across multiple commands and service layers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Weak-Crypto ✅ Passed PR does not introduce weak crypto algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or insecure secret comparisons. The crypto references are to legitimate inter...
No-Sensitive-Data-In-Logs ✅ Passed PR adds no-wait functionality with only appropriate console output (stack IDs, CloudFormation ARNs, status messages). No logging of sensitive data like passwords, tokens, API keys, PII, session IDs...
No-Hardcoded-Secrets ✅ Passed No hardcoded secrets detected in the PR. Changes only add NoWait boolean flags and conditional logic; no API keys, tokens, passwords, or other credentials were introduced.
No-Injection-Vectors ✅ Passed No injection vectors detected. The PR only adds boolean flags for control flow (if statements) with no SQL concatenation, shell injection, unsafe deserialization, or code execution patterns.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@cdoan1
cdoan1 requested a review from typeid May 13, 2026 03:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/commands/clusteriam/create.go (1)

136-174: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Skip OIDC setup when --no-wait flag is used alongside --oidc-issuer-url.

When both --no-wait and --oidc-issuer-url are provided, the IAM stack is created asynchronously (lines 136+), but the code immediately attempts to update that stack's trust policies via updateIAMTrustPolicies() in the CreateOIDC service function. AWS CloudFormation does not permit UpdateStack operations on stacks in CREATE_IN_PROGRESS state—the stack must first reach CREATE_COMPLETE. This causes the update to fail while the IAM stack is still being created.

💡 Suggested guard for the async path
 	// If OIDC issuer URL was provided, also create the OIDC provider stack
 	if opts.oidcIssuerURL != "" {
+		if opts.noWait {
+			fmt.Println("IAM stack creation submitted.")
+			fmt.Println("Skipping automatic OIDC provider creation in --no-wait mode because IAM stack may still be in progress.")
+			fmt.Println("Run 'rosactl cluster-oidc create' after IAM stack creation completes.")
+			return nil
+		}
+
 		fmt.Println()
 		fmt.Println("OIDC issuer URL provided — also creating OIDC provider...")
 		fmt.Println()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/commands/clusteriam/create.go` around lines 136 - 174, The
CreateOIDC flow is attempting to perform an UpdateStack (via
updateIAMTrustPolicies) while the IAM CloudFormation stack may still be in
CREATE_IN_PROGRESS when --no-wait is used; change clusteroidc.CreateOIDC (and
any helper that calls updateIAMTrustPolicies) to skip the trust-policy update
when CreateOIDCRequest.NoWait is true (or detect stack state CREATE_IN_PROGRESS
and return success without calling updateIAMTrustPolicies), and instead return
the submitted StackID/Outputs immediately so the caller
(internal/commands/clusteriam/create.go) can report the async submission; ensure
the NoWait code path never calls updateIAMTrustPolicies to avoid
UpdateStack-on-CREATE_IN_PROGRESS failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/commands/clusteriam/create.go`:
- Around line 136-174: The CreateOIDC flow is attempting to perform an
UpdateStack (via updateIAMTrustPolicies) while the IAM CloudFormation stack may
still be in CREATE_IN_PROGRESS when --no-wait is used; change
clusteroidc.CreateOIDC (and any helper that calls updateIAMTrustPolicies) to
skip the trust-policy update when CreateOIDCRequest.NoWait is true (or detect
stack state CREATE_IN_PROGRESS and return success without calling
updateIAMTrustPolicies), and instead return the submitted StackID/Outputs
immediately so the caller (internal/commands/clusteriam/create.go) can report
the async submission; ensure the NoWait code path never calls
updateIAMTrustPolicies to avoid UpdateStack-on-CREATE_IN_PROGRESS failures.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 1d5e3925-daac-4df2-a767-2e8a2d767a51

📥 Commits

Reviewing files that changed from the base of the PR and between b77c9b9 and b3b1003.

📒 Files selected for processing (13)
  • internal/aws/cloudformation/client.go
  • internal/aws/cloudformation/stack.go
  • internal/commands/bootstrap/create.go
  • internal/commands/bootstrap/delete.go
  • internal/commands/clusteriam/create.go
  • internal/commands/clusteriam/delete.go
  • internal/commands/clusteroidc/create.go
  • internal/commands/clusteroidc/delete.go
  • internal/commands/clustervpc/create.go
  • internal/commands/clustervpc/delete.go
  • internal/services/clusteriam/service.go
  • internal/services/clusteroidc/service.go
  • internal/services/clustervpc/service.go

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2026
Add --no-wait flag to all create and delete subcommands to allow
non-blocking CloudFormation operations. When set, the CLI submits
the stack operation and returns immediately without waiting for
completion.

Changes:
- CloudFormation client: Add NoWait field to CreateStackParams,
  UpdateStackParams, and DeleteStack signature
- Service layer: Thread NoWait through all Create/Delete request
  structs (clustervpc, clusteriam, clusteroidc)
- Command layer: Add --no-wait flag to all create/delete commands
  and adjust output messages accordingly

This reduces CI pipeline time by allowing async stack teardown in
pre-merge e2e tests while preserving blocking behavior by default
for reliability.

Fixes: ROSAENG-1071

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 15, 2026
Make --no-wait=true the default for all CloudFormation operations to
return immediately without blocking. Users can override with --no-wait=false
to wait for completion.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/commands/clusteriam/create.go (1)

119-122: ⚡ Quick win

Add user guidance for checking stack status when using --no-wait.

When the command returns immediately, users receive no guidance on how to verify completion. CloudFormation operations can take 5–15 minutes, and users may need to confirm success before proceeding with dependent operations.

Consider adding actionable next steps, such as:

  • AWS CLI command to check stack status: aws cloudformation describe-stacks --stack-name rosa-{cluster-name}-iam --region {region}
  • Link to AWS Console CloudFormation page
  • Expected completion time estimate
💡 Suggested enhancement
 	if opts.noWait {
 		fmt.Println("Stack creation submitted!")
 		fmt.Printf("   Stack ID: %s\n", resp.StackID)
+		fmt.Println()
+		fmt.Println("To check stack status, run:")
+		fmt.Printf("   aws cloudformation describe-stacks --stack-name rosa-%s-iam --region %s\n", opts.clusterName, opts.region)
 	} else {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/commands/clusteriam/create.go` around lines 119 - 122, When the
`opts.noWait` flag is true in the create.go file, users receive the stack
creation confirmation with a Stack ID but lack guidance on verifying completion.
After printing the Stack ID in the noWait block, add additional output that
includes an example AWS CLI command to check the stack status (using aws
cloudformation describe-stacks with the stack name and region), mention the
expected CloudFormation operation time frame (5-15 minutes), and optionally
reference the AWS Console CloudFormation page where users can monitor progress.
This provides actionable next steps for users who cannot wait for the operation
to complete.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/commands/clusteriam/create.go`:
- Line 60: The BoolVar flag definition for noWait in the create command has a
default value of true, which contradicts the PR objective to maintain blocking
behavior by default. Change the default value from true to false in the BoolVar
call so that the command blocks and waits for stack creation to complete by
default, allowing users to opt-in to non-blocking behavior by explicitly passing
the --no-wait flag.

---

Nitpick comments:
In `@internal/commands/clusteriam/create.go`:
- Around line 119-122: When the `opts.noWait` flag is true in the create.go
file, users receive the stack creation confirmation with a Stack ID but lack
guidance on verifying completion. After printing the Stack ID in the noWait
block, add additional output that includes an example AWS CLI command to check
the stack status (using aws cloudformation describe-stacks with the stack name
and region), mention the expected CloudFormation operation time frame (5-15
minutes), and optionally reference the AWS Console CloudFormation page where
users can monitor progress. This provides actionable next steps for users who
cannot wait for the operation to complete.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift-online/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ccb2c380-4b1d-415f-b67d-f5d116d7bfab

📥 Commits

Reviewing files that changed from the base of the PR and between 24178dd and c49b568.

📒 Files selected for processing (8)
  • internal/commands/bootstrap/create.go
  • internal/commands/bootstrap/delete.go
  • internal/commands/clusteriam/create.go
  • internal/commands/clusteriam/delete.go
  • internal/commands/clusteroidc/create.go
  • internal/commands/clusteroidc/delete.go
  • internal/commands/clustervpc/create.go
  • internal/commands/clustervpc/delete.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • internal/commands/clusteroidc/delete.go
  • internal/commands/bootstrap/create.go
  • internal/commands/clustervpc/delete.go
  • internal/commands/clusteroidc/create.go
  • internal/commands/bootstrap/delete.go
  • internal/commands/clustervpc/create.go
  • internal/commands/clusteriam/delete.go


cmd.Flags().StringVar(&opts.oidcIssuerURL, "oidc-issuer-url", "", "OIDC issuer URL (optional — also creates OIDC provider if provided)")
cmd.Flags().StringVar(&opts.region, "region", "", "AWS region (required)")
cmd.Flags().BoolVar(&opts.noWait, "no-wait", true, "Return immediately without waiting for stack creation to complete")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: default contradicts PR objectives and breaks reliability guarantee.

The default value true makes the command return immediately without waiting for stack creation, contradicting the PR description: "maintaining blocking behavior by default to preserve reliability." This inverts the intended behavior and will break existing workflows that depend on blocking completion.

The primary motivation is to reduce CI pipeline time, but that should be opt-in (--no-wait) rather than the default. The commit message acknowledges the default is true, which conflicts with the stated design intent in the PR objectives.

🔧 Proposed fix
-	cmd.Flags().BoolVar(&opts.noWait, "no-wait", true, "Return immediately without waiting for stack creation to complete")
+	cmd.Flags().BoolVar(&opts.noWait, "no-wait", false, "Return immediately without waiting for stack creation to complete")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cmd.Flags().BoolVar(&opts.noWait, "no-wait", true, "Return immediately without waiting for stack creation to complete")
cmd.Flags().BoolVar(&opts.noWait, "no-wait", false, "Return immediately without waiting for stack creation to complete")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/commands/clusteriam/create.go` at line 60, The BoolVar flag
definition for noWait in the create command has a default value of true, which
contradicts the PR objective to maintain blocking behavior by default. Change
the default value from true to false in the BoolVar call so that the command
blocks and waits for stack creation to complete by default, allowing users to
opt-in to non-blocking behavior by explicitly passing the --no-wait flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant