mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
* feat(deploy)!: move the greenfield overlays and the release namespace to nvke-controller This moves them, and with them the persisted identifiers a site carries: the Helm release and its namespace, the database, and the Temporal namespace and task queue. In the three greenfield stacks: nameOverride, fullnameOverride, namespaceOverride, serviceAccount.name, serviceMonitor.name, appDb.dbName, the Temporal namespace and queue, the field managers and the managed-by values, tracing.serviceName, and the objects the stacks render around them -- the Namespace manifest, the Postgres CREATE DATABASE, the SPIRE admin ID and ClusterSPIFFEID namespace selectors, the auth-dev ConfigMap's namespace, the CAPD RBAC ClusterRole and its subject, and the spire-client probe URL. Consumers that move with it: controller/Tiltfile (release name, namespace, SPIRE admin path and the string-matched resource names), deploy/check-site.sh, the e2e site helpers and their collect script, cli/internal/bootstrap/controllerdeploy (including the NodePort Service nvke-controller-external), cli/internal/deploypath's admin path, management-engine/hack/nvke-controller.sh, and the CI lane scripts. The discovery paths search the new name first and keep the old one: nvkectl's authConfigNamespaces, nvke-token.sh, nvke-auth-demo.sh and dev-env-spire.sh now try nvke-controller, then nke-controller, then cloud-workflow-engine. The reference health dashboard matches all three workload names, and Tilt's preflight refuses to take over a cluster that still runs the nke-controller release rather than failing later. The published image keeps its name per #1554 decision 2, as do the nke-controller-config ConfigMap and the nke-controller-chart release artifact; hack/name-check-allowlist.txt now carries one entry per reason rather than one blanket token. Refs #1861, #1554, #1496, #1818 Signed-off-by: Terry Howe <thowe@nvidia.com> * fix: address review feedback Name nke-controller as the intermediate namespace in the authentication docs, matching authConfigNamespaces, and restore the legacy node-agent audience in the exchange mock's test. Signed-off-by: Terry Howe <thowe@nvidia.com> * fix: address review feedback Signed-off-by: Terry Howe <thowe@nvidia.com> * fix(e2e): point the nico bootstrap lane at the nvke-controller namespace The nico lane still asserted the tenant credentials Secret landed in nke-controller, so both e2e (nico) jobs failed after the rename. Signed-off-by: Terry Howe <thowe@nvidia.com> * fix(deploy): carry the nvke-controller rename into the rebased files The rebase onto main replayed the rename over two files that gained nke-controller references after the branch was cut: the management-engine dev overlay, which succeeds the hack script this branch had edited and was removed in #1918, and an API-authentication example added in #1935. Refs #1861 Signed-off-by: Terry Howe <thowe@nvidia.com> * fix: address review feedback Continue namespace discovery past a Forbidden lookup in nvke-token.sh and nvke-auth-demo.sh. --ignore-not-found suppresses absence, not denial, so a kubeconfig scoped to nke-controller alone died on the nvke-controller probe before reaching the namespace it can read -- the migration case this branch adds. Keep the first denial, try the remaining candidates, and fail with it only when none was readable, since falling back to cloud-workflow-engine needs a confirmed absence. Refs #1861 Signed-off-by: Terry Howe <thowe@nvidia.com> --------- Signed-off-by: Terry Howe <thowe@nvidia.com>
66 lines
2.2 KiB
Go
66 lines
2.2 KiB
Go
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package controllerdeploy
|
|
|
|
import (
|
|
"context"
|
|
"encoding/base64"
|
|
"errors"
|
|
"log/slog"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func TestEtcdEncryptionKey(t *testing.T) {
|
|
id := uuid.New()
|
|
active := base64.StdEncoding.EncodeToString([]byte("key-bytes"))
|
|
runner := &fakeRunner{outputs: []fakeOutput{{
|
|
output: `{"apiVersion":"v1","kind":"Secret","data":{"active":"` + active + `","active-since":"MQ=="}}`,
|
|
}}}
|
|
|
|
data, err := New(runner, slog.Default()).EtcdEncryptionKey(context.Background(), "/kube.conf", id)
|
|
if err != nil {
|
|
t.Fatalf("EtcdEncryptionKey: %v", err)
|
|
}
|
|
if string(data["active"]) != "key-bytes" {
|
|
t.Errorf("active = %q, want decoded key bytes", data["active"])
|
|
}
|
|
if string(data["active-since"]) != "1" {
|
|
t.Errorf("active-since = %q, want %q", data["active-since"], "1")
|
|
}
|
|
|
|
if len(runner.calls) != 1 {
|
|
t.Fatalf("calls = %d, want 1", len(runner.calls))
|
|
}
|
|
args := strings.Join(runner.calls[0].args, " ")
|
|
for _, want := range []string{"--kubeconfig /kube.conf", "-n nvke-controller", "get secret etcd-encryption-key-" + id.String(), "-o json"} {
|
|
if !strings.Contains(args, want) {
|
|
t.Errorf("kubectl args %q do not contain %q", args, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestEtcdEncryptionKeyErrorsCarryNoOutput: this read's output is the key, so
|
|
// unlike the package's other kubectl reads, a failure must not quote it.
|
|
func TestEtcdEncryptionKeyErrorsCarryNoOutput(t *testing.T) {
|
|
const leaked = "OUTPUT-THAT-MUST-NOT-APPEAR"
|
|
for name, out := range map[string]fakeOutput{
|
|
"command failed": {output: leaked, err: errors.New("exit status 1")},
|
|
"not json": {output: leaked},
|
|
"no active field": {output: `{"data":{"pending":"` + base64.StdEncoding.EncodeToString([]byte(leaked)) + `"}}`},
|
|
} {
|
|
runner := &fakeRunner{outputs: []fakeOutput{out}}
|
|
_, err := New(runner, slog.Default()).EtcdEncryptionKey(context.Background(), "/kube.conf", uuid.New())
|
|
if err == nil {
|
|
t.Errorf("%s: expected an error", name)
|
|
continue
|
|
}
|
|
if strings.Contains(err.Error(), leaked) {
|
|
t.Errorf("%s: error %q carries the command output", name, err)
|
|
}
|
|
}
|
|
}
|