Files
Miancheng Lin 3317737e1e refactor(api): rename the OS profile surface to releases (#1612)
* refactor(api): rename the OS profile surface to releases

/osProfiles becomes /releases and nico.osProfile becomes nico.release, so
the REST API uses the release vocabulary the rest of the management plane
already does. Internal db and workflow structs keep their field names.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* refactor(controller): rename the OS profile to the release

Nico payloads gain a release key. os_profile is still written alongside
it and still read as a fallback, so a CWE predating the rename keeps
reading and writing the value through a rolling upgrade or a rollback.
No stored data changes. A later release backfills release from
os_profile, then drops the mirror and the fallback.

The os_profile Prometheus label is deliberately unchanged.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* docs: follow the OS profile rename

The request YAML in the workload-cluster guides named a field the API no
longer accepts, and two troubleshooting entries quoted error text that no
longer appears. The dashboard panel descriptions in operate/observe.md
keep the old wording: the panels and the os_profile metric label they
read are unchanged.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

* fix(scripts): read cluster NICo fields from .nico and allow an absent configProfile

The cluster-level orgID, siteID and vpcID live under .nico in the API
response, as the node pool fields already corrected do, so the script
exited before generating anything. configProfile is optional in the same
schema, and requiring it skipped a valid node pool.

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>

---------

Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
2026-10-15 11:56:35 -07:00

83 lines
2.6 KiB
Go

// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// Package command holds the nvkectl subcommands that manage machine images and
// releases on a site's management cluster.
package command
import (
"errors"
"fmt"
"strings"
"github.com/spf13/cobra"
"github.com/dsx-ai-factory/nvke/cli/internal/operator"
"github.com/dsx-ai-factory/nvke/cli/internal/util"
)
// ClientFn builds the operator Client for the active site.
//
// Commands take this rather than a built client so the site is only looked up
// when a command actually runs, leaving --help, and a client-side --dry-run,
// working on a machine with no site configured at all.
type ClientFn func() (operator.Client, error)
// kindInfo is how one machine image or release kind appears on the command line.
type kindInfo struct {
kind operator.Kind
// use is the singular lower-case command name, such as "machineimage".
use string
// noun is how messages describe one resource of the kind.
noun string
// what is a short description of the kind for help text.
what string
// usedBy says what may still depend on a resource of the kind, for the
// note printed after a delete.
usedBy string
}
// kindInfos lists the kinds in the order their commands are registered.
var kindInfos = []kindInfo{
{
operator.KindMachineImage, "machineimage", "machine image",
"a machine image: an immutable node image and its NICo boot script",
"a cluster release or node pool release still names",
},
{
operator.KindClusterRelease, "clusterrelease", "cluster release",
"a cluster release: a control-plane release",
"a cluster still selects",
},
{
operator.KindNodePoolRelease, "nodepoolrelease", "node pool release",
"a node pool release: a worker release",
"a node pool still selects",
},
}
// plural returns the plural command name of the kind.
func (k kindInfo) plural() string { return k.use + "s" }
// readDocument reads a request document from path, or from stdin when path is "-".
func readDocument(cmd *cobra.Command, path string) ([]byte, error) {
return util.ReadFileOrStdin(cmd.InOrStdin(), path, "request")
}
// notFoundError reports the names that matched nothing, or returns nil.
func notFoundError(k kindInfo, missing []string) error {
switch len(missing) {
case 0:
return nil
case 1:
return fmt.Errorf("%s %q not found", k.noun, missing[0])
default:
return fmt.Errorf("%ss not found: %s", k.noun, strings.Join(missing, ", "))
}
}
// isNotFound reports whether err says the named resource does not exist.
func isNotFound(err error) bool {
return errors.Is(err, operator.ErrNotFound)
}