@@ -21,6 +21,7 @@ import (
2121 meta "k8s.io/apimachinery/pkg/api/meta"
2222 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323 k8stypes "k8s.io/apimachinery/pkg/types"
24+ "k8s.io/apimachinery/pkg/util/intstr"
2425 "sigs.k8s.io/controller-runtime/pkg/client"
2526
2627 bootcv1alpha1 "github.com/bootc-dev/bootc-operator/api/v1alpha1"
@@ -1293,3 +1294,144 @@ func TestOperatorRestartResilience(t *testing.T) {
12931294 Should (poolAllUpdated (1 , env .NodeImageUpdateDigest ()))
12941295 t .Logf ("Operator functioned normally after restart: rollout completed" )
12951296}
1297+
1298+ // TestMultiNodeRollout provisions a pool of multiple worker nodes
1299+ // (COS-5185: scale testing for bootc-operator) and verifies a rollout
1300+ // updates every node in the pool, respecting maxUnavailable, and that
1301+ // the pool status correctly reflects all nodes once the rollout
1302+ // completes. Unlike TestMidRolloutImageChange (bink-only, 2 nodes,
1303+ // exercises mid-rollout image switches), this test targets a larger
1304+ // pool and runs on EKS to validate behavior on real cloud nodes rather
1305+ // than the simulated bink provider, since upstream CI's GitHub runners
1306+ // cannot afford enough memory/CPU for multi-node scale testing.
1307+ func TestMultiNodeRollout (t * testing.T ) {
1308+ e2eutil .Providers (t , "bink" , "eks" )
1309+ t .Parallel ()
1310+ g := NewWithT (t )
1311+ g .SetDefaultEventuallyTimeout (pollTimeout )
1312+ g .SetDefaultEventuallyPollingInterval (pollInterval )
1313+
1314+ env := e2eutil .New (t )
1315+
1316+ const nodeCount = 3
1317+ nodes := make ([]string , nodeCount )
1318+ for i := range nodes {
1319+ nodes [i ] = env .AddNode (t )
1320+ }
1321+
1322+ ctx := context .Background ()
1323+
1324+ // Phase 1: Create pool with original image and wait for all nodes Idle.
1325+ // maxUnavailable=1 means rollout must proceed one node at a time.
1326+ pool := env .NewPool ("scale" , env .NodeImageDigestedPullSpec (),
1327+ testutil .WithMaxUnavailable (intstr .FromInt (1 )))
1328+ g .Expect (env .Client .Create (ctx , pool )).To (Succeed ())
1329+
1330+ // Verify the daemon pod actually reaches Running on every node before
1331+ // waiting for Idle - a pod stuck in e.g. ImagePullBackOff would
1332+ // otherwise just show up as a confusing Idle-wait timeout below.
1333+ for _ , nodeName := range nodes {
1334+ g .Eventually (func () ([]corev1.Pod , error ) {
1335+ var pods corev1.PodList
1336+ err := env .Client .List (ctx , & pods ,
1337+ client .InNamespace (testutil .OperatorNamespaceName ),
1338+ client.MatchingFields {"spec.nodeName" : nodeName },
1339+ client.MatchingLabels {
1340+ "app.kubernetes.io/name" : "bootc-operator" ,
1341+ "app.kubernetes.io/component" : "daemon" ,
1342+ },
1343+ )
1344+ return pods .Items , err
1345+ }).WithTimeout (3 * time .Minute ).Should (ConsistOf (And (
1346+ HaveField ("Spec.NodeName" , nodeName ),
1347+ HaveField ("Status.Phase" , corev1 .PodRunning ),
1348+ )), "expected exactly one running daemon pod on %s" , nodeName )
1349+ }
1350+
1351+ for _ , nodeName := range nodes {
1352+ testutil .WaitForNodeIdle (t , g , ctx , env .Client , nodeName , 3 * time .Minute )
1353+ }
1354+
1355+ t .Logf ("All %d nodes are Idle with original image" , nodeCount )
1356+
1357+ g .Eventually (fetchPoolStatus (ctx , env .Client , pool )).
1358+ Should (poolAllUpdated (nodeCount , env .NodeImageDigest ()))
1359+
1360+ // Phase 2: Patch pool to the update image.
1361+ updateRef := env .NodeImageUpdateDigestedPullSpec ()
1362+
1363+ modified := pool .DeepCopy ()
1364+ modified .Spec .Image .Ref = updateRef
1365+ g .Expect (env .Client .Patch (ctx , modified , client .MergeFrom (pool ))).To (Succeed ())
1366+ * pool = * modified
1367+
1368+ t .Logf ("Patched pool to update image %s" , updateRef )
1369+
1370+ // Phase 3: Wait for every node to be Idle on the update digest - proves
1371+ // the rollout reached the full pool, not just a subset - while
1372+ // continuously enforcing maxUnavailable. Both checks share one polling
1373+ // loop so the invariant is sampled throughout the rollout rather than
1374+ // once before it starts, and so the wait ends as soon as the rollout
1375+ // does.
1376+ //
1377+ // A node that stays Degraded aborts the wait early and reports the
1378+ // daemon's own error message. The daemon clears Degraded on the next
1379+ // successful reconcile, so a retried transient error must not fail the
1380+ // test; only a node degraded for longer than degradedGrace does.
1381+ const degradedGrace = 90 * time .Second
1382+ degradedSince := make (map [string ]time.Time )
1383+
1384+ g .Eventually (func (g Gomega ) {
1385+ var p bootcv1alpha1.BootcNodePool
1386+ g .Expect (env .Client .Get (ctx , client .ObjectKeyFromObject (pool ), & p )).To (Succeed ())
1387+
1388+ // An exceeded maxUnavailable is a violated invariant, not a state
1389+ // to wait out - retrying would let a later poll mask it.
1390+ if p .Status .UpdatingCount > 1 {
1391+ StopTrying (fmt .Sprintf (
1392+ "maxUnavailable=1 violated: %d nodes updating simultaneously" ,
1393+ p .Status .UpdatingCount ,
1394+ )).Now ()
1395+ }
1396+
1397+ for _ , nodeName := range nodes {
1398+ var bn bootcv1alpha1.BootcNode
1399+ g .Expect (env .Client .Get (ctx , client.ObjectKey {Name : nodeName }, & bn )).To (Succeed ())
1400+
1401+ if cond := meta .FindStatusCondition (
1402+ bn .Status .Conditions , bootcv1alpha1 .NodeDegraded ,
1403+ ); cond != nil && cond .Status == metav1 .ConditionTrue {
1404+ first , seen := degradedSince [nodeName ]
1405+ switch {
1406+ case ! seen :
1407+ degradedSince [nodeName ] = time .Now ()
1408+ case time .Since (first ) > degradedGrace :
1409+ StopTrying (fmt .Sprintf (
1410+ "node %s degraded for over %s during rollout: %s: %s" ,
1411+ nodeName , degradedGrace , cond .Reason , cond .Message ,
1412+ )).Now ()
1413+ }
1414+ } else {
1415+ delete (degradedSince , nodeName )
1416+ }
1417+
1418+ g .Expect (bn .Status .Conditions ).To (ContainElement (And (
1419+ HaveField ("Type" , bootcv1alpha1 .NodeIdle ),
1420+ HaveField ("Status" , metav1 .ConditionTrue ),
1421+ HaveField ("Reason" , bootcv1alpha1 .NodeReasonIdle ),
1422+ )), "node %s is not Idle yet" , nodeName )
1423+
1424+ g .Expect (bn .Status .Booted ).NotTo (BeNil ())
1425+ g .Expect (bn .Status .Booted ).To (
1426+ imageMatchesDigest (env .NodeImageUpdateDigest ()),
1427+ "node %s has not booted the update digest yet" , nodeName ,
1428+ )
1429+ }
1430+ }).WithTimeout (20 * time .Minute ).Should (Succeed ())
1431+
1432+ t .Logf ("All %d nodes are Idle with update image" , nodeCount )
1433+
1434+ // Phase 4: Verify final pool status reflects all nodes updated.
1435+ g .Eventually (fetchPoolStatus (ctx , env .Client , pool )).
1436+ Should (poolAllUpdated (nodeCount , env .NodeImageUpdateDigest ()))
1437+ }
0 commit comments