@@ -381,6 +381,44 @@ var _ = Describe("AgentDeployment Controller", func() {
381381 return dep .Spec .Template .Spec .Containers [0 ].Image
382382 }, testTimeout , testInterval ).Should (Equal ("nginx:1.25" ), "child Deployment image should be updated" )
383383 })
384+
385+ It ("does not advance StableVersion during a partial rollout" , func () {
386+ // Record the StableVersion before the image change. In envtest no pods
387+ // run, so the initial StableVersion is empty (rollout never completes).
388+ // After updating the image the Deployment generation advances but
389+ // ObservedGeneration / UpdatedReplicas / AvailableReplicas never satisfy
390+ // the rollout-complete gate — so StableVersion must stay empty.
391+ ad := & agentraxv1alpha1.AgentDeployment {}
392+ Expect (k8sClient .Get (ctx , key , ad )).To (Succeed ())
393+ stableVersionBefore := ad .Status .StableVersion
394+
395+ ad .Spec .Image = "nginx:1.25"
396+ Expect (k8sClient .Update (ctx , ad )).To (Succeed ())
397+
398+ // Wait for the Deployment spec to reflect the new image so we know the
399+ // reconciler has processed the update.
400+ Eventually (func () string {
401+ dep := & appsv1.Deployment {}
402+ if err := k8sClient .Get (ctx , key , dep ); err != nil {
403+ return ""
404+ }
405+ if len (dep .Spec .Template .Spec .Containers ) == 0 {
406+ return ""
407+ }
408+ return dep .Spec .Template .Spec .Containers [0 ].Image
409+ }, testTimeout , testInterval ).Should (Equal ("nginx:1.25" ), "Deployment spec image should be updated" )
410+
411+ // Give the reconciler a moment to run and potentially update status,
412+ // then assert StableVersion has not advanced beyond its pre-update value.
413+ Consistently (func () string {
414+ current := & agentraxv1alpha1.AgentDeployment {}
415+ if err := k8sClient .Get (ctx , key , current ); err != nil {
416+ return ""
417+ }
418+ return current .Status .StableVersion
419+ }, 2 * time .Second , testInterval ).Should (Equal (stableVersionBefore ),
420+ "StableVersion must not advance while rollout is incomplete" )
421+ })
384422 })
385423
386424 Describe ("Self-healing" , func () {
0 commit comments