Files
Anisha Gupta US 82c8b7e8a3 feat(cli): time each bootstrap phase with spans and log lines (#1979)
* feat(cli): time each bootstrap phase with spans and log lines

bootstrap site runs in five phases: preflight, bootstrap_cluster,
engine_deploy, site_cluster and finish. Each phase now has a child span
of the run's root span and logs one "phase finished" line with its
outcome and duration_ms, so phase durations are available without a
trace backend.

Every log line carries operation and, once the site spec is loaded,
cluster. While a phase runs, a line also carries phase, and its span_id is
the phase span's. The run tracks the current phase, because the component
loggers are built before a phase starts and are given no context. With
--json-logs the time is in UTC.

The Kind cluster's log attribute is now bootstrap_kind_cluster, so
cluster means the site cluster on every line.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* fix(cli): keep the site cluster name on the lines that already carried it

The handler adds cluster to every line, and a record that names cluster keeps its own value, so these lines carry it once.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* docs(cli): show the new log fields in the existing troubleshooting example

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* test(cli): let the bootstrap e2e allowlist accept the phase fields on its two log lines

The allowlist matches each of those lines from time= to its end, so the operation, cluster and phase fields now on every line made gitleaks flag both again.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* test(cli): cover an interrupted bootstrap and a masked phase error

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* fix(cli): give exported log records the phase span and fields

With OTLP export on, the tee handler put the root span into a record's
context before the log handler ran, so a context-free logger never got
its phase span, and the exported record never got phase, operation or
cluster. Resolve the span and fields once and use them for both the
stderr line and the exported record.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* fix(cli): log trace fields before the run fields again

The previous commit stamped trace_id and span_id after operation, cluster
and phase, which the e2e gitleaks allowlist does not match, so its etcd
key line was reported as a leak. Restore the order and pin it in a test.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* fix(cli): let a bound logger field win over the run's field

A logger made with With("cluster", ...) got the run's cluster field as
well, so the line had the key twice. Track the top-level keys a handler
has bound and skip those run fields.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* refactor(cli): name the phase tracker's error parameter previousErr

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* fix(cli): track a logger's bound fields per group

Attributes bound after WithGroup go in the same group as the record's
attributes, so the run's field collided with them and the line had the
key twice. Start a new set of bound keys at each group, and make the
test assert the group's one value.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* Revert "fix(cli): track a logger's bound fields per group"

This reverts commit 1841921b19.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* Revert "fix(cli): let a bound logger field win over the run's field"

This reverts commit 5669089a50.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* fix(cli): fail the finish phase when the Kind teardown fails

A failed teardown was only logged, so finish reported succeeded even
though the Kind cluster was left behind. Record the teardown error on the
finish phase, joined with any error finish already has, and leave the
command's own result unchanged.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* refactor(cli): drop the lowercase clone methods of the log handler

The tee asserts the logHandler its local handler's WithAttrs and
WithGroup return, so the handler needs one method for each, not two.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* test(cli): drop the teardown case that needs an untaint failure to tear down

On main a failure after the site cluster exists keeps the bootstrap Kind
cluster, so a failed untaint never reaches the teardown and the case
asserts an error that is not produced.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* docs(cli): document the bootstrap phases in the troubleshooting guide

Describe the phase finished line and the five phases, add the logged
phase to the failure table, and put each error under the phase that logs
it: the kubeconfig, SPIRE and encryption key errors are site_cluster, and
only the untaint is finish. The retained-cluster example now has the
fields in the order the log writes them.

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

* docs(cli): name the stack install as part of the finish phase

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>

---------

Signed-off-by: Anisha Gupta <anisgupta@nvidia.com>
2026-10-29 15:59:17 -05:00
..