Skip to content

Commit b40a2e0

Browse files
ptalgulk01HarshwardhanPatil07
authored andcommitted
e2e: add eks test case for scaling node
Signed-off-by: Prachiti Talgulkar <ptalgulk01@users.noreply.github.com>
1 parent 1fe0faf commit b40a2e0

1 file changed

Lines changed: 176 additions & 0 deletions

File tree

‎test/e2e/bootcnode_test.go‎

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -1419,3 +1420,178 @@ func TestOperatorRestartResilience(t *testing.T) {
14191420
Should(poolAllUpdated(1, env.NodeImageUpdateDigest()))
14201421
t.Logf("Operator functioned normally after restart: rollout completed")
14211422
}
1423+
1424+
// TestMultiNodeRollout provisions a pool of multiple worker nodes
1425+
// (COS-5185: scale testing for bootc-operator) and verifies a rollout
1426+
// updates every node in the pool, respecting maxUnavailable, and that
1427+
// the pool status correctly reflects all nodes once the rollout
1428+
// completes. Unlike TestMidRolloutImageChange (bink-only, 2 nodes,
1429+
// exercises mid-rollout image switches), this test targets a larger
1430+
// pool and runs on EKS to validate behavior on real cloud nodes rather
1431+
// than the simulated bink provider, since upstream CI's GitHub runners
1432+
// cannot afford enough memory/CPU for multi-node scale testing.
1433+
func TestMultiNodeRollout(t *testing.T) {
1434+
e2eutil.Providers(t, "bink", "eks")
1435+
t.Parallel()
1436+
g := NewWithT(t)
1437+
g.SetDefaultEventuallyTimeout(pollTimeout)
1438+
g.SetDefaultEventuallyPollingInterval(pollInterval)
1439+
1440+
env := e2eutil.New(t)
1441+
1442+
const nodeCount = 3
1443+
nodes := make([]string, nodeCount)
1444+
for i := range nodes {
1445+
nodes[i] = env.AddNode(t)
1446+
}
1447+
1448+
ctx := context.Background()
1449+
1450+
// Phase 1: Create pool with original image and wait for all nodes Idle.
1451+
// maxUnavailable bounds how many nodes may be disrupted at once.
1452+
const maxUnavailable = 1
1453+
pool := env.NewPool("scale", env.NodeImageDigestedPullSpec(),
1454+
testutil.WithMaxUnavailable(intstr.FromInt(maxUnavailable)))
1455+
g.Expect(env.Client.Create(ctx, pool)).To(Succeed())
1456+
1457+
// Verify the daemon pod actually reaches Running on every node before
1458+
// waiting for Idle - a pod stuck in e.g. ImagePullBackOff would
1459+
// otherwise just show up as a confusing Idle-wait timeout below.
1460+
for _, nodeName := range nodes {
1461+
g.Eventually(func() ([]corev1.Pod, error) {
1462+
var pods corev1.PodList
1463+
err := env.Client.List(ctx, &pods,
1464+
client.InNamespace(testutil.OperatorNamespaceName),
1465+
client.MatchingFields{"spec.nodeName": nodeName},
1466+
client.MatchingLabels{
1467+
"app.kubernetes.io/name": "bootc-operator",
1468+
"app.kubernetes.io/component": "daemon",
1469+
},
1470+
)
1471+
return pods.Items, err
1472+
}).WithTimeout(3*time.Minute).Should(ConsistOf(And(
1473+
HaveField("Spec.NodeName", nodeName),
1474+
HaveField("Status.Phase", corev1.PodRunning),
1475+
)), "expected exactly one running daemon pod on %s", nodeName)
1476+
}
1477+
1478+
for _, nodeName := range nodes {
1479+
testutil.WaitForNodeIdle(t, g, ctx, env.Client, nodeName, 3*time.Minute)
1480+
}
1481+
1482+
t.Logf("All %d nodes are Idle with original image", nodeCount)
1483+
1484+
g.Eventually(fetchPoolStatus(ctx, env.Client, pool)).
1485+
Should(poolAllUpdated(nodeCount, env.NodeImageDigest()))
1486+
1487+
// Phase 2: Patch pool to the update image.
1488+
updateRef := env.NodeImageUpdateDigestedPullSpec()
1489+
1490+
modified := pool.DeepCopy()
1491+
modified.Spec.Image.Ref = updateRef
1492+
g.Expect(env.Client.Patch(ctx, modified, client.MergeFrom(pool))).To(Succeed())
1493+
*pool = *modified
1494+
1495+
t.Logf("Patched pool to update image %s", updateRef)
1496+
1497+
// Phase 3: Wait for every node to be Idle on the update digest - proves
1498+
// the rollout reached the full pool, not just a subset - while
1499+
// continuously enforcing maxUnavailable. Both checks share one polling
1500+
// loop so the invariant is sampled throughout the rollout rather than
1501+
// once before it starts, and so the wait ends as soon as the rollout
1502+
// does. Asserting the invariant once up front would pass trivially,
1503+
// since nothing is disrupted yet at that point.
1504+
//
1505+
// A node that stays Degraded aborts the wait early and reports the
1506+
// daemon's own error message. The daemon clears Degraded on the next
1507+
// successful reconcile, so a retried transient error must not fail the
1508+
// test; only a node degraded for longer than degradedGrace does.
1509+
const degradedGrace = 90 * time.Second
1510+
degradedSince := make(map[string]time.Time)
1511+
1512+
g.Eventually(func(g Gomega) {
1513+
// Snapshot the whole pool in a single List. The assertions below
1514+
// abort the iteration at the first node that is behind, so the
1515+
// invariant has to be evaluated across every node before any of
1516+
// them run. It must also be one List rather than a Get per node:
1517+
// a List is a consistent snapshot at one resourceVersion, whereas
1518+
// sequential Gets can straddle a slot handoff and assemble a view
1519+
// in which two nodes hold a slot, a state that never existed.
1520+
var bnList bootcv1alpha1.BootcNodeList
1521+
g.Expect(env.Client.List(ctx, &bnList)).To(Succeed())
1522+
1523+
inPool := make(map[string]bool, len(nodes))
1524+
for _, nodeName := range nodes {
1525+
inPool[nodeName] = true
1526+
}
1527+
bns := make([]bootcv1alpha1.BootcNode, 0, len(nodes))
1528+
for i := range bnList.Items {
1529+
if inPool[bnList.Items[i].Name] {
1530+
bns = append(bns, bnList.Items[i])
1531+
}
1532+
}
1533+
g.Expect(bns).To(HaveLen(len(nodes)), "expected a BootcNode per pool node")
1534+
1535+
// maxUnavailable bounds reboot slots, not staging. Staging only
1536+
// downloads the image and disrupts nothing, so the controller lets
1537+
// the whole pool stage at once and gates cordon/drain/reboot. A
1538+
// node holds a slot exactly while it carries the in-reboot-slot
1539+
// annotation, which is also how the controller counts them.
1540+
//
1541+
// Exceeding the bound is a violated invariant rather than a state
1542+
// to wait out - retrying would let a later poll mask it.
1543+
inRebootSlot := 0
1544+
for i := range bns {
1545+
if metav1.HasAnnotation(bns[i].ObjectMeta, bootcv1alpha1.AnnotationInRebootSlot) {
1546+
inRebootSlot++
1547+
}
1548+
}
1549+
if inRebootSlot > maxUnavailable {
1550+
StopTrying(fmt.Sprintf(
1551+
"maxUnavailable=%d violated: %d nodes hold a reboot slot at once",
1552+
maxUnavailable, inRebootSlot,
1553+
)).Now()
1554+
}
1555+
1556+
for i := range bns {
1557+
bn := &bns[i]
1558+
if cond := meta.FindStatusCondition(
1559+
bn.Status.Conditions, bootcv1alpha1.NodeDegraded,
1560+
); cond != nil && cond.Status == metav1.ConditionTrue {
1561+
first, seen := degradedSince[bn.Name]
1562+
switch {
1563+
case !seen:
1564+
degradedSince[bn.Name] = time.Now()
1565+
case time.Since(first) > degradedGrace:
1566+
StopTrying(fmt.Sprintf(
1567+
"node %s degraded for over %s during rollout: %s: %s",
1568+
bn.Name, degradedGrace, cond.Reason, cond.Message,
1569+
)).Now()
1570+
}
1571+
} else {
1572+
delete(degradedSince, bn.Name)
1573+
}
1574+
}
1575+
1576+
for i := range bns {
1577+
bn := &bns[i]
1578+
g.Expect(bn.Status.Conditions).To(ContainElement(And(
1579+
HaveField("Type", bootcv1alpha1.NodeIdle),
1580+
HaveField("Status", metav1.ConditionTrue),
1581+
HaveField("Reason", bootcv1alpha1.NodeReasonIdle),
1582+
)), "node %s is not Idle yet", bn.Name)
1583+
1584+
g.Expect(bn.Status.Booted).NotTo(BeNil())
1585+
g.Expect(bn.Status.Booted).To(
1586+
imageMatchesDigest(env.NodeImageUpdateDigest()),
1587+
"node %s has not booted the update digest yet", bn.Name,
1588+
)
1589+
}
1590+
}).WithTimeout(20 * time.Minute).Should(Succeed())
1591+
1592+
t.Logf("All %d nodes are Idle with update image", nodeCount)
1593+
1594+
// Phase 4: Verify final pool status reflects all nodes updated.
1595+
g.Eventually(fetchPoolStatus(ctx, env.Client, pool)).
1596+
Should(poolAllUpdated(nodeCount, env.NodeImageUpdateDigest()))
1597+
}

0 commit comments

Comments
 (0)