Skip to content

Revert FlinkBlueGreenDeployment lastReconciledSpec back to old spec during abort workflow - #26

Merged
jennifer-xiong25 merged 3 commits into
mainfrom
03-20-new_fixes
Mar 27, 2026
Merged

Revert FlinkBlueGreenDeployment lastReconciledSpec back to old spec during abort workflow#26
jennifer-xiong25 merged 3 commits into
mainfrom
03-20-new_fixes

Conversation

@jennifer-xiong25

@jennifer-xiong25 jennifer-xiong25 commented Mar 23, 2026

Copy link
Copy Markdown

Simply setting the lastReconciledSpec after calling startTransition wasn't enough, because the workflow could still abort after that, so add the reverting logic in the abort workflow.

Fixes Shopify/streaming-compute#882

// Read the active child's spec and write it back to the B/G CR so
// lastReconciledSpec stays consistent and the next reconciliation sees the
// correct diff.
BlueGreenDeploymentType activeType =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

thinking out loud here, what if users modified the child spec prior to the abort, the B/G CR now holds something slightly different than the true lastreconciledSpec right? I guess does that matter?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hmm if the B/G controller overwrites the child spec on every reconciliation, that manual spec change would be overwritten anyway, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Actually, you're right - the period of time before the next deploy and when this code runs, if someone changed the child spec manually, then there would be drift.
Two options:

  1. we could save the previous lastReconciledSpec before overwriting it
  2. we could only revert lastReconciledSpec (from the in-memory map), which means lastReconciledSpec (good) differs from CR spec (bad) → operator detects a diff → tries the transition again → fails → aborts → retries. The user sees the error on every cycle and needs to fix their spec manually.

Maybe we should go with 1?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we discussed offline but option 1!

: BlueGreenDeploymentType.GREEN;
FlinkDeployment activeChild = context.getDeploymentByType(activeType);
if (activeChild != null) {
context.getBgDeployment().getSpec().getTemplate().setSpec(activeChild.getSpec());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we've confirmed that this will reflect the correct value in the spec?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yep!

@jennifer-xiong25
jennifer-xiong25 force-pushed the 03-20-new_fixes branch 2 times, most recently from be62410 to 7e9ebe9 Compare March 25, 2026 19:23

// Restore lastReconciledSpec and the B/G CR spec to the pre-transition state
// so they stay consistent with the active child that is still running.
String namespace = context.getBgDeployment().getMetadata().getNamespace();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

call out: if the BG gets deleted or we exit somewhere during the transition after failure, or without failure we don't seem to remove the entry in the previousReconciledSpecs at that point. Is that a risk? it's only of size 1 per namespace but do we want to keep it around, is there any chance we could inadvertently end up using the value in there resulting in an improper restore somehow? (i.e. we end up using the stale one to restore)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

it's not a risk because savePreTransitionSpec always overwrites the entry for that namespace before each transition. By the time abortDeployment runs, the map has the correct pre-transition spec for the current transition, not a stale one from a previous transition.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

right beginning of each round will wipe it out. okay perfect, thanks for talking through these with me!

@james-kan-shopify

Copy link
Copy Markdown

Prior to merging, please make sure to run through a few more edge case scenarios in staging! also release this on monday! as friday isn't a good time for these to roll out , we want users to be around and be aware of these patches rolling out!

@jennifer-xiong25
jennifer-xiong25 merged commit c7b38d0 into main Mar 27, 2026
118 checks passed
@jennifer-xiong25
jennifer-xiong25 deleted the 03-20-new_fixes branch March 27, 2026 17:53
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.

2 participants