Files
Eric Staples 5c095369f5 refactor(controller)!: remove control-plane controller flag and node-pool control plane path (#1608)
* refactor(controller)!: remove control-plane controller flag and node-pool control plane path

Control planes are always provisioned by the control-plane controller.
Remove PROVISION_CONTROL_PLANE_WITH_CONTROL_PLANE_CONTROLLER, the flag-off
node-pool provisioning branches, and the e2e plumbing that toggled it. Run the
control-plane migration unconditionally on worker boot.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* refactor(controller): remove unused NodePoolUpgradeConfig provider capability

The control-plane reconciler no longer resolves node-pool upgrades, so the
capability, its capi and nico implementations, and the factory that
GetProviderClient ran on every resolve have no callers.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* refactor(controller): count surge nodes from the in-memory control plane

reconcileNodesNeedingRollout re-listed the cluster's control-plane nodes to
count controller-managed ones, duplicating the list readControlPlane already
loaded for the same reconcile.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* fix(controller): guard nil controlPlaneConfig before reading desiredCount

Signed-off-by: Eric Staples <estaples@nvidia.com>

* docs(controller): tighten MigrateControlPlaneToController doc comment

Signed-off-by: Eric Staples <estaples@nvidia.com>

* fix(controller): skip clusters with no snapshot source in the migration leftover check

A non-deleting cluster with no configuration_id whose only control-plane
pools are deleting cannot be snapshotted, so its pooled nodes stayed pooled
and tripped the fail-closed check, blocking worker startup.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* test(controller): cover MigrateControlPlaneToController against Postgres

The re-parent, deprecated-generation and cleanup SQL is Postgres-only and had
no coverage. The test runs it on a fresh database named by
NVKE_TEST_POSTGRES_DSN and skips when that is unset.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* fix(controller): warn for each cluster the control-plane migration skips

A non-deleting cluster with pooled control-plane nodes, no configuration snapshot and no active control-plane pool has nothing to migrate from, so the leftover check skips it. Log a warning per skipped cluster with its ID, name and pooled node count so the skip is visible.

MigrateControlPlaneToController now takes a logger.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* test(controller): use the nvke name in control-plane test fixtures

name-check rejects the legacy product name in new lines.

Signed-off-by: Eric Staples <estaples@nvidia.com>

---------

Signed-off-by: Eric Staples <estaples@nvidia.com>
2026-10-14 18:38:29 -07:00

49 lines
1.4 KiB
Go

// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package controlplane_test
import (
"context"
"log/slog"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/dsx-ai-factory/nvke/controller/internal/config"
"github.com/dsx-ai-factory/nvke/controller/internal/controllers/controlplane"
"github.com/dsx-ai-factory/nvke/controller/internal/controllers/dbreconcile"
"github.com/dsx-ai-factory/nvke/controller/internal/controllers/dbreconcile/dbwrapper"
"github.com/dsx-ai-factory/nvke/controller/internal/db"
"github.com/dsx-ai-factory/nvke/controller/internal/testutil"
)
func TestUnit_ControllerReconcileSkipsMissingCluster(t *testing.T) {
t.Parallel()
clusterID := uuid.New()
mockTx := &testutil.MockTx{}
mockDB := &testutil.MockDB{MockTx: mockTx}
mockDB.On("RunInTx", mock.Anything, mock.Anything).Return(nil)
mockTx.On("GetClusterForUpdate", mock.Anything, clusterID).Return(db.Cluster{}, db.ErrNotFound)
controller := controlplane.NewController(
config.Config{},
slog.Default(),
dbwrapper.New(mockDB, slog.Default()),
nil,
nil,
nil,
nil,
)
result, err := controller.Reconcile(context.Background(), dbreconcile.ClusterKey(clusterID))
require.NoError(t, err)
assert.Empty(t, result)
mockDB.AssertExpectations(t)
mockTx.AssertExpectations(t)
}