Files
nvke/controller/hack/capd-kindest-node/scripts/cloud-init-status-shim
Ron Compos 4b7866bde7 fix(e2e): get amd64 tenant nodes to join on the site lane (#1358)
* fix(agent): report which cloud-init stage failed, not just that it did

`cloud-init status` prints one word. When a node fails it, the preflight
check reports "status: error" and the reason stays on the node.

Run 37745107586 is what that costs. A tenant node failed cloud-init two
minutes after the cluster was created; the check reported the same four
words 44 times over the next 90 minutes until the suite's provision wait
expired, and the node was released on teardown before anyone could log
in. The run produced 97KB of diagnostics and not one byte saying what
cloud-init had failed to do. The node was reachable throughout -- all 44
checks got a reply -- so the answer was sitting on a healthy machine the
whole time, unasked for.

`--long` adds the failing stage and its message after the status line.
evaluateCloudInitStatus matches on substrings, so the longer report
parses exactly as before and the extra lines ride along into the error
the controller logs.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(e2e): export the deploy assets the way the ref under test lays them out

The lane exports its deploy assets from the release tag being qualified,
but asked every tag for a top-level deploy/ that #1291 created on 8
October. Run 37830345659 died on `git archive controller/v0.1.1: fatal:
pathspec 'deploy' did not match any files`, so no existing controller
release could be qualified on main, and no dispatch input worked around
it: the ref is a config field with no workflow input.

Replace the one hardcoded asset list and executor with a Layout, holding
the four things that moved together -- the directories to export, the
executor's name, the customer deploy path, and the flag spelling that
executor takes. Two so far: deploy/nke-deploy.sh with --deploy-path from
#1291 onwards, and build/use-nke-sbom.sh with --sbom/--target on every
tag before it. What is inside a deploy path did not move, so both read
controller/release.yaml from the same place within it.

ResolveLayout probes for each executor rather than reading the version,
because the move is a property of the tree and a version string only
correlates with it: a backport, a branch or a hand-cut tag can carry
either shape. A ref older than both layouts now says which executors
were looked for and that a layout is owed, rather than failing in git
plumbing.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(e2e): take the controller's name from the deploy path that installs it

The deploy path decides the name the controller is installed under, and a
configured name is a second place to say the same thing. Nothing kept the
two in step: the suite default tracks main, the lane's job is qualifying
release tags, and since #1271 the default is nke-controller while every
tag cut before the rename installs cloud-workflow-engine. Run 37828716287
stopped before provisioning for exactly that reason, with neither
CWE_NAMESPACE nor CWE_SERVICE set in the repository.

Read the name out of the exported deploy path and point the suite at it.
An explicitly configured name still wins and still has to agree, which is
what the old check was worth -- someone who pins one has a reason, and a
wrong one costs an hour on a machine. What it no longer does is fail on a
name nobody chose.

The environment carries it rather than a package variable because that is
how the value already reaches subprocesses. It has to be set before
anything reads controller.Namespace(); nothing reads it at init and the
suite is serial, so newStack in BeforeAll is that point, and the doc
comment says so.

Also correct the workflow's own account of this. Its comment said an
empty cwe-name leaves the suite on "the older name", which stopped being
true at #1271 and is what makes leaving the field blank look safe.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* refactor(e2e): address review of the layout and controller-name fixes

Three things a reader would stop on.

ResolveLayout now runs ahead of ExportRef, which is where the "does this
ref exist" check lives, so a version with a typo in it reported that the
executor had moved and a layout was owed -- sending the reader to add an
entry for a ref that does not exist. Check the ref resolves first.

Stack.DeployPath was set by no caller and had become a second spelling of
Layout.DeployPath, and TargetArgs took the path as an argument purely to
support overriding it. Drop both, and the test that asserted the override,
which defended a capability nothing uses.

TestLayoutsMatchTheReleaseTags is the only test that checks the layout
table against the tags the lane exports from, and it skipped in CI
forever: the unit-test job checks out shallow with no tags, so it found
none and quietly passed. Fetch tags there, and tell a tag that is absent
from the clone apart from one that genuinely carries no executor, so the
test is honest in both places.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(e2e): decode node labels from controllers either side of #1306

#1306 changed nodeLabels from a list of "key=value" strings to an object.
The suite's API client is generated from the checkout and the controller
it talks to is the release under qualification, so across that change the
two disagree and no single generated client is right for both.

NodePool declares nodeLabels required, so a controller older than #1306
sends "nodeLabels": [] on every node-pool list and the whole response
fails to decode -- including on the readiness path, which reads nothing
but pool names. That is what stopped run 37854934923 after the site
controller came up and the tenant cluster provisioned.

Reshape the field at the transport instead of the model: the generated
code stays generated, the controller is untouched, and the whole
accommodation is one file to delete once the oldest release the lane
qualifies carries #1306. Responses only -- nothing here sends labels, and
the field is omitempty everywhere it would be sent.

Also stop polling a disagreement. A node becomes ready with time; a
client and a controller that disagree about a schema never do. The
readiness spec retried that decode once a second for 45 minutes on a
held GB200 and then reported a timeout rather than the mismatch.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(e2e): wait for a default route before tenant nodes download anything

Tenant pre-kubeadm commands opened with set -eu and then fetched the apt
key, with nothing waiting for the network. On a node whose default route
was not up yet the fetch failed at once, set -eu stopped the script, and
the node never installed what it needs to join. Run 37873467928 hit this
on an amd64 control plane, whose kernel line lacks the ip=dhcp the arm64
one carries; an arm64 worker running the same commands passed.

The site node already waited for a route in its own user data. Move that
bounded wait into the shared template, ahead of the first download, so
the site node and every tenant node get it from one place.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(e2e): count node milestones as provisioning progress

WaitForClusterReady called a cluster stuck when its provisioning message
had not changed for the stall window. That message reads "Waiting for a
control plane node to be ready to join" for the whole of the control
plane's boot, which on bare metal can outlast the window while the node
is still advancing. Run 37882425829 stopped an amd64 control plane
sixteen minutes into a 45-minute budget, after it had gained an address
and a reachable agent and while its setup script was running.

Progress is now the cluster message plus each node's milestones: an
address, agent ready, ready to join, joined, provisioned and Kubernetes
ready. Statuses, not messages, since a node's provisioning message
changes on every retry and would hide a node retrying forever.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(ci): keep a failed tenant's nodes when keep-site is set

-e2e.keep-site held only the site node. The tenant cleanup still
deleted a failed tenant's cluster, releasing the instances the site
was kept to inspect. When KEEP_SITE is true the generated e2e config
now also sets lifecycle.preserveOnFailure.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(e2e): address review of the stall check, schema check and route wait

A failed node list skipped the stall check for that poll, so repeated
failures could hide a stall until the deadline. It now reuses the last
nodes seen, which neither hides a stall nor looks like progress when the
next list succeeds.

SchemaMismatch matched JSON syntax errors as well as type errors, so a
truncated response stopped the readiness poll instead of being retried.
Only a type error means the client and controller will never agree.

The site node's user data relied on its node commands opening with the
route wait. It waits on its own again; the second wait returns at once.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(capd): answer cloud-init status --long in the container-node shim

The node agent now runs `cloud-init status --long`. The CAPD node
image's shim accepted only the bare form and exited 2 with a usage line,
which the agent treats as not done, so NodePreflight never passed on a
container node and the e2e clusters never provisioned.

The shim now accepts `status` and `status --long`, prints the status
line first, and with --long adds extended_status, boot_status_code and
detail lines. Anything else still exits 2. The shim test runs every
state through both forms and checks the rejections.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(agent): decide cloud-init status from the status line alone

The check searched the whole report for "status: done" before
"status: error". With --long the report carries free-text detail and
error lines, so a failed node whose detail contained "status: done"
would have been reported ready. The state now comes from the first line
that starts with "status:"; the rest is reported, not evaluated.

The proto comment for check_cloud_init_status said the agent runs
`cloud-init status` and matches anywhere in the output. Updated and
regenerated; node_agent.pb.go changes in comments only.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* refactor(e2e): name deploy layouts plainly and export assets in one constructor

Rename Layout to DeployLayout, LayoutDeploy/LayoutBuild to
CurrentLayout/LegacyLayout, and sbomStyleTarget to legacyTargetFlags.

Add ExportDeployAssets, which resolves the layout, exports the ref and
adopts the controller name, returning one DeployAssets value and a
cleanup. Stack carries that value instead of Assets, AssetPaths and
Layout. It is still called from BeforeAll so a conflicting controller
name fails before any machine is taken.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(ci): clear name-check and gitleaks on the site lane

name-check failed on the old deploy path names the site lane's layout
table has to carry, build/use-nke-sbom.sh and controller/deploy/nke-sbom,
because every controller release tag before #1291 ships them. Allowlist
the token with that reason, and reword the CurrentLayout comment so it no
longer names the old script.

gitleaks flagged the synthetic nats-io/nkeys module hash in the CLEAN
fixture of hack/test_name_check.py, which reaches this branch's scan
through the merge of main. Allow that one literal in that one file.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* fix(e2e): restore the controller name when the site lane cleans up

ExportDeployAssets adopts the qualified release's controller name into
NKE_CONTROLLER_NAMESPACE and NKE_CONTROLLER_SERVICE, and nothing put
them back, so in an unfiltered run every spec after the site container
read the qualified release's name instead of the suite's. Record both
before adopting and restore them, set or unset, in the cleanup that
already removes the export. The cleanup runs after the container's
AfterAll, so teardown diagnostics still see the adopted name.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

* refactor(e2e): drop support for controller releases before v0.2.0-rc.1

The site lane qualifies the latest controller tag, which is now
controller/v0.2.0-rc.1, and nothing pins an older one. Remove what only
older releases needed:

- the second deploy layout, for tags that keep the executor under build/.
  A tag without deploy/nvke-deploy.sh now fails before any machine is
  taken, saying the lane qualifies v0.2.0-rc.1 and later.
- the node-label shim for controllers older than #1306, and the
  fail-fast on a response schema mismatch that only it needed.
- controller-name adoption and the cleanup that restored it. The check
  main had, CheckControllerName, comes back: it reads the name the
  release installs and fails early when the suite is not looking for it.

Signed-off-by: Ron Compos <rcompos@nvidia.com>

---------

Signed-off-by: Ron Compos <rcompos@nvidia.com>
2026-10-13 08:46:55 -06:00

55 lines
1.6 KiB
Bash

#!/bin/sh
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# This mocks `cloud-init status` so the node agent can run the same
# checks it runs in production images.
# Since we don't actually run cloud-init in container backed nodes,
# cloud-init will never report done. Instead, we let the higher level
# orchestrator that simulates cloud-init (in our case, nico-containers)
# write a status file to track the progress of the simulated cloud-init
# process. From this script we just read that file and print it
# following the `cloud-init status` contract.
#
# The node agent runs `cloud-init status --long`, so that form has to be
# answered too: rejecting it fails NodePreflight on every container node.
set -eu
usage() {
echo "only 'cloud-init status [--long]' is supported" >&2
exit 2
}
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ] || [ "$1" != "status" ]; then
usage
fi
long=false
if [ "$#" -eq 2 ]; then
[ "$2" = "--long" ] || usage
long=true
fi
status_file="${NICO_CONTAINERS_CLOUD_INIT_STATUS_FILE:-/var/lib/nico-containers/cloud-init/status}"
if [ -e "$status_file" ]; then
state="$(cat "$status_file" 2>/dev/null)" || state=error
else
state=running
fi
case "$state" in
running|done|error) ;;
*)
# Fail closed through the same output contract consumed by node-agent.
state=error
;;
esac
printf 'status: %s\n' "$state"
if [ "$long" = true ]; then
printf 'extended_status: %s\n' "$state"
printf 'boot_status_code: enabled-by-generator\n'
printf 'detail: nico-containers cloud-init shim; no stage detail is simulated\n'
fi