@@ -469,6 +469,71 @@ func TestReconcileAlreadyRunning(t *testing.T) {
469469 }
470470}
471471
472+ // TestReconcileRunningUpdatesMessage reproduces issue #289: once the Workspace
473+ // is ready the phase flips to Running, but the status message must no longer
474+ // claim it is "waiting for pods to be ready".
475+ func TestReconcileRunningUpdatesMessage (t * testing.T ) {
476+ scheme := newScheme ()
477+ md := newMDForController ("test" , "default" )
478+ md .UID = "test-uid"
479+ controllerutil .AddFinalizer (md , FinalizerName )
480+ // Simulate a prior reconcile loop that left the deploying-phase message.
481+ md .Status .Phase = airunwayv1alpha1 .DeploymentPhaseDeploying
482+ md .Status .Message = "Workspace created, waiting for pods to be ready"
483+
484+ ws := & unstructured.Unstructured {}
485+ setWorkspaceGVK (ws )
486+ ws .SetName ("test" )
487+ ws .SetNamespace ("default" )
488+ ws .SetOwnerReferences ([]metav1.OwnerReference {
489+ {UID : "test-uid" , APIVersion : "airunway.ai/v1alpha1" , Kind : "ModelDeployment" , Name : "test" },
490+ })
491+ ws .Object ["resource" ] = map [string ]interface {}{
492+ "count" : int64 (1 ),
493+ "labelSelector" : map [string ]interface {}{
494+ "matchLabels" : map [string ]interface {}{
495+ "kubernetes.io/os" : "linux" ,
496+ },
497+ },
498+ }
499+ ws .Object ["inference" ] = map [string ]interface {}{
500+ "preset" : map [string ]interface {}{
501+ "name" : "test-model" ,
502+ },
503+ }
504+ ws .Object ["status" ] = map [string ]interface {}{
505+ "conditions" : []interface {}{
506+ map [string ]interface {}{
507+ "type" : "WorkspaceSucceeded" ,
508+ "status" : "True" ,
509+ },
510+ },
511+ }
512+
513+ deploy := newReadyKaitoDeployment ()
514+ directC := probeClientBuilderWithWorkspace (t ).WithObjects (deploy ).Build ()
515+ c := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (md , ws ).WithStatusSubresource (md ).Build ()
516+ r := NewKaitoProviderReconciler (c , scheme , directC , record .NewFakeRecorder (10 ))
517+
518+ if _ , err := r .Reconcile (context .Background (), ctrl.Request {
519+ NamespacedName : types.NamespacedName {Name : "test" , Namespace : "default" },
520+ }); err != nil {
521+ t .Fatalf ("unexpected error: %v" , err )
522+ }
523+
524+ var updated airunwayv1alpha1.ModelDeployment
525+ _ = c .Get (context .Background (), types.NamespacedName {Name : "test" , Namespace : "default" }, & updated )
526+ if updated .Status .Phase != airunwayv1alpha1 .DeploymentPhaseRunning {
527+ t .Fatalf ("expected Running phase, got %s" , updated .Status .Phase )
528+ }
529+ if strings .Contains (updated .Status .Message , "waiting for pods" ) {
530+ t .Errorf ("status message still claims waiting for pods while Running: %q" , updated .Status .Message )
531+ }
532+ if updated .Status .Message == "" {
533+ t .Errorf ("expected a non-empty status message in Running phase" )
534+ }
535+ }
536+
472537func TestReconcileHandleDeletion (t * testing.T ) {
473538 scheme := newScheme ()
474539 md := newMDForController ("test" , "default" )
0 commit comments