Skip to content

ObserveGeneration and lastStableGeneration for FlinkBlueGreenDeployment - #30

Merged
james-kan-shopify merged 2 commits into
mainfrom
observed-generation-blue-green
Jul 21, 2026
Merged

ObserveGeneration and lastStableGeneration for FlinkBlueGreenDeployment#30
james-kan-shopify merged 2 commits into
mainfrom
observed-generation-blue-green

Conversation

@james-kan-shopify

@james-kan-shopify james-kan-shopify commented Jul 14, 2026

Copy link
Copy Markdown

What is the purpose of the change

This pull request makes FlinkBlueGreenDeployment status generation-aware so external deploy tooling can
distinguish stale parent status from status that belongs to the currently applied spec generation.

Before this change, a BlueGreen parent could still report ACTIVE_BLUE / ACTIVE_GREEN and RUNNING from the
previous generation after Kubernetes had already accepted a new spec/image. This could allow kapp to mark a
deploy successful before the new BlueGreen generation had actually completed, especially around savepoint
handoff where the parent can temporarily return to ACTIVE_* / RUNNING before the new color is live.

The change adds two parent status fields with separate semantics:

  • observedGeneration: the latest metadata.generation observed by the operator.
  • lastStableGeneration: the latest metadata.generation that reached a stable BlueGreen terminal state.

observedGeneration provides the standard Kubernetes freshness signal used by kapp’s supportsObservedGeneration
behavior. lastStableGeneration provides the BlueGreen-specific completion signal needed because ACTIVE_* /
RUNNING alone is not always proof that the current parent generation is complete.

Brief change log

  • Added status.observedGeneration to FlinkBlueGreenDeploymentStatus.
  • Added status.lastStableGeneration to FlinkBlueGreenDeploymentStatus.
  • Updated the BlueGreen CRD schema and generated custom-resource reference docs.
  • Centralized generation stamping in BlueGreenDeploymentService.patchStatusUpdateControl(...).
    • Every status patch records observedGeneration = metadata.generation.
    • lastStableGeneration advances only when the parent status is written as stable terminal status (RUNNING
      or SUSPENDED).
  • Added controller no-op backfill for existing stable BlueGreen resources missing the new fields.
  • Added tests covering stale generation, stable generation, savepoint handoff, failure, existing-resource
    backfill, initial suspended deploys, and final active stability.

Verifying this change

This change added tests and can be verified as follows:

  • Added focused controller tests for:
    • observedGeneration updating when a new spec generation is observed.
    • Existing stable resources backfilling missing generation status fields.
    • lastStableGeneration not advancing when a transition fails before start.
    • lastStableGeneration not advancing during savepoint handoff while parent status is ACTIVE_* / RUNNING.
    • Initial suspended BlueGreen deploys being marked stable for the current generation.
    • Final active BlueGreen deployments being marked stable for the current generation.

Verified locally with:

  mvn -pl flink-kubernetes-operator -am \                                                                      
    -DskipITs -DskipE2E -DskipRat \                                                                            
    -Dcheckstyle.skip -Dspotless.check.skip=true -Dspotless.apply.skip=true \                                  
    -DfailIfNoTests=false \                                                                                    
    -Dtest=FlinkBlueGreenDeploymentControllerTest test                                                         

Result:

  Tests run: 76, Failures: 0, Errors: 0, Skipped: 0                                                            

Also verified formatting with Spotless check for the touched module.

###Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changes to the CustomResourceDescriptors: yes
  • Core observer or reconciler logic that is regularly executed: yes

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? docs

@james-kan-shopify
james-kan-shopify force-pushed the observed-generation-blue-green branch from c8865cd to 1d1c9f6 Compare July 14, 2026 18:10

@drossos drossos 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.

Ok wrapped my head around things and seems to make sense. Have some structure changes and a q.

We also need to tophat to ensure would work as expected in deployed env

@james-kan-shopify
james-kan-shopify force-pushed the observed-generation-blue-green branch 2 times, most recently from f98cafc to a2caf1b Compare July 16, 2026 21:13
@james-kan-shopify
james-kan-shopify force-pushed the observed-generation-blue-green branch from a2caf1b to a418cc9 Compare July 16, 2026 21:58
@james-kan-shopify
james-kan-shopify marked this pull request as ready for review July 16, 2026 23:01

@drossos drossos 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.

LGTM after review + discussions. Will merge in after summit and roll-out 👍

@james-kan-shopify
james-kan-shopify merged commit 18670fd into main Jul 21, 2026
119 checks passed
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