Skip to content

Show progress while simulate renders and plans composites - #565

Open
haarchri wants to merge 1 commit into
crossplane:mainfrom
haarchri:feat/simulate-progress
Open

haarchri wants to merge 1 commit into
crossplane:mainfrom
haarchri:feat/simulate-progress

Conversation

@haarchri

Copy link
Copy Markdown
Member

Description of your changes

After the last setup step (starting diff servers), simulate rendered every composite and planned its managed resources with nothing on screen; to the user the CLI looked hung. Show a 'Simulating changes' spinner for that stretch, updated with which composite of how many is being processed, resolving to a checkmark before the plan output so it matches the setup step style.

Progress lines need their text to change over time, which the event model keyed by text could not express: events gain an optional Name that identifies an operation across text changes, an Updated status, and the multi-spinner keys its lines accordingly. Plain (non-TTY) output prints the started and resolved lines and drops the in-place updates.

✓ Pulling provider package xpkg.upbound.io/upbound/provider-aws-ec2:v2.9.5
✓ Starting diff server for xpkg.upbound.io/upbound/provider-aws-ec2:v2.9.5
<nothing, possibly for minutes>

Now that stretch shows a spinner updated with which composite of how many is being processed, and resolves to a checkmark before the plan output, matching the setup step style:

✓ Starting diff server for xpkg.upbound.io/upbound/provider-aws-ec2:v2.9.5
⠋ Simulating changes (3/14 composites: ec2.aws.m.upbound.io/v1beta1, Kind=Network/prod-network)
...
✓ Simulating changes
[~] Composition.apiextensions.crossplane.io networks.aws.platform.upbound.io (update)

Fixes #545

I have:

  • Read and followed Crossplane's contribution process.
  • Read and followed Crossplane's AI policy and confirmed a human stands behind this PR.
  • Run ./nix.sh flake check to ensure this PR is ready for review.
  • Added or updated unit tests.
  • Linked a PR or a docs tracking issue to document this change.
  • Added backport release-x.y labels to auto-backport this PR.

Need help with this checklist? See the cheat sheet.

After the last setup step (starting diff servers), simulate rendered
every composite and planned its managed resources with nothing on
screen; to the user the CLI looked hung. Show a 'Simulating changes'
spinner for that stretch, updated with which composite of how many is
being processed, resolving to a checkmark before the plan output so it
matches the setup step style.

Progress lines need their text to change over time, which the event
model keyed by text could not express: events gain an optional Name
that identifies an operation across text changes, an Updated status,
and the multi-spinner keys its lines accordingly. Plain (non-TTY)
output prints the started and resolved lines and drops the in-place
updates.

Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
@haarchri
haarchri requested review from a team, jcogilvie and tampakrap as code owners November 19, 2026 21:26
@haarchri
haarchri requested review from negz and removed request for a team November 19, 2026 21:26
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.79381% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.95%. Comparing base (cd703a0) to head (30105d2).
⚠️ Report is 23 commits behind head on main.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jcogilvie jcogilvie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving with one comment:

The new keyed and updated path isn't tested yet. TestSimulateWithProgress runs the plain printer, which drops Updated events by design, so AddKeyed, UpdateKeyed and SuccessKeyed and the processors' Report calls are never exercised. I'd like to see:

  • table-driven tests for MultiSpinner
  • tests that give PerformDiff and collectXRDiffs a Progress and check the (done, total, detail) sequence they report.

@@ -254,6 +258,13 @@ func WithIncludeManual(includeManual bool) ProcessorOption {
}

// WithAdvisories sets the collector advisories are raised on and drained from for structured output.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WithProgress insertion happened between this doc comment and its function below. Please fix

if !ran {
t.Fatal("simulateWithProgress did not run the wrapped function")
}
if progressFn := progress; progressFn == nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How would you lose this if progress is a local?

for _, xr := range xrs {
for i, xr := range xrs {
resourceID := dt.MakeDiffKeyFromResource(xr)
p.config.Progress.Report(i, len(xrs), resourceID)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Is it worth prefixing this with the composition being processed?

@adamwg adamwg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the update, I like this overall. Couple of notes inline.

Comment thread internal/simulate/run.go
// exits 3; one that fails only schema validation returns one that exits 2.
// ctx must not be cancelled by its owner until simulate returns, so a
// cancellation reads as an interrupt.
// simulatingMsg is the progress line shown while composites render and their

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this was added between the simulate fucntion's comment and its implementation :-).

for update := range updateChan {
switch update.Status {
case async.EventStatusStarted:
multi.Add(update.Text)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think these are the only callers of the MultiSpinner's Add/Success/Fail. Can we just update the signatures to be keyed rather than introducing the new Keyed variants?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simulate: show a spinner while the simulation is running after the diff server starts

3 participants