update

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package update owns the `mcp-runtime update` command, which moves an installed MCP Runtime platform to a release by patching only the images of platform services whose versions changed.

Index

Constants

View Source
const (
	StatusUpdated        = "updated"
	StatusSkipped        = "skipped"
	StatusFailed         = "failed"
	StatusRolledBack     = "rolled-back"
	StatusRollbackFailed = "rollback-failed"
	StatusNotAttempted   = "not-attempted"
)

Workload outcome states.

View Source
const (
	ImageActionBuild = "build"
	ImageActionReuse = "reuse"
)
View Source
const (
	ActionUpdate    = "update"
	ActionUnchanged = "unchanged"
	ActionSkip      = "skip"
	ActionBlocked   = "blocked"
)

Plan actions.

View Source
const (
	CRDActionSkipped = "skipped"
)

Variables

This section is empty.

Functions

func New

func New(_ *core.Runtime) *cobra.Command

New returns the update command.

Types

type ApplyOptions

type ApplyOptions struct {
	Timeout           time.Duration
	RollbackOnFailure bool
	Waiter            RolloutWaiter
	// Clients applies CRD YAML when the plan sets ApplyCRDs. Required only then.
	Clients *k8sclient.Clients
	// Progress receives human-readable progress lines (may be nil).
	Progress func(string)
}

ApplyOptions controls rollout behaviour.

type BuildOptions

type BuildOptions struct {
	Enabled       bool
	Source        string
	ImagePlatform string
	Parallelism   int
	Retries       int // extra attempts after the first failure (default 1)
	// SkipRegistryProbe forces every Built candidate to Action=build without
	// contacting the registry (used for --dry-run without Docker).
	SkipRegistryProbe bool
	// Progress receives human-readable lines (may be nil).
	Progress func(string)
	// Out receives docker/make stdout/stderr (may be nil).
	Out io.Writer

	// Injectable for tests.
	RegistryHasImage func(ctx context.Context, image string) (bool, error)
	BuildImage       func(ctx context.Context, source, platform string, spec imageBuildSpec, image string) error
	PushImage        func(ctx context.Context, image string) error
}

BuildOptions controls optional local image build/push during update.

type CRDResult

type CRDResult struct {
	Name   string `json:"name"`
	Action string `json:"action,omitempty"`
	Error  string `json:"error,omitempty"`
}

CRDResult reports one CustomResourceDefinition apply outcome.

type ClusterInfo

type ClusterInfo struct {
	Context   string `json:"context"`
	Server    string `json:"server"`
	ClusterID string `json:"clusterID"`
}

ClusterInfo identifies the target cluster shown before any change.

type ImageBuildAction

type ImageBuildAction struct {
	Component string `json:"component"`
	Image     string `json:"image"`
	Action    string `json:"action"` // build | reuse
	Reason    string `json:"reason,omitempty"`
}

ImageBuildAction is one unique image the update may build or reuse.

type Options

type Options struct {
	To                 string
	ReleaseManifest    string
	CRDs               string
	DryRun             bool
	Yes                bool
	Only               []string
	IncludeAuth        bool
	IncludeCertManager bool
	AllowDowngrade     bool
	RollbackOnFailure  bool
	Timeout            time.Duration
	Output             string
	Kubeconfig         string
	Context            string
	Build              bool
	Source             string
	ImagePlatform      string
	BuildParallelism   int
}

Options holds parsed update flags.

type Plan

type Plan struct {
	Cluster          ClusterInfo `json:"cluster"`
	ManifestSource   string      `json:"manifestSource"`
	TargetVersion    string      `json:"targetVersion"`
	InstalledVersion string      `json:"installedVersion,omitempty"`
	// ApplyCRDs is true when this release embeds CustomResourceDefinitions
	// that must be applied before image rollouts.
	ApplyCRDs bool `json:"applyCRDs,omitempty"`
	// CRDNames lists CustomResourceDefinition metadata.name values to apply.
	CRDNames []string `json:"crdNames,omitempty"`
	// CRDPreview lists per-CRD create/update/skipped intents after live compare.
	CRDPreview []CRDResult `json:"crdPreview,omitempty"`
	// ImageBuilds lists unique Built images to build or reuse when --build is set.
	ImageBuilds []ImageBuildAction `json:"imageBuilds,omitempty"`

	Rows      []Row    `json:"components"`
	Preserved []string `json:"preservedResources"`
	Warnings  []string `json:"warnings,omitempty"`
	// contains filtered or unexported fields
}

Plan is the full update plan.

func BuildPlan

BuildPlan reads the installed inventory and diffs it with the manifest. It only reads: namespaces, deployments, and pods. When the manifest marks a CRD change, CRD YAML must already be present on the Manifest (embedded, --crds, or fetched platform-crds.yaml).

func (*Plan) Blocked

func (p *Plan) Blocked() []Row

Blocked returns rows blocked by a safety rule.

func (*Plan) Changed

func (p *Plan) Changed() []Row

Changed returns the rows that will be updated.

func (*Plan) NeedsApply

func (p *Plan) NeedsApply() bool

NeedsApply reports whether the plan would mutate the cluster (CRDs and/or images).

type Result

type Result struct {
	CRDs      []CRDResult      `json:"crds,omitempty"`
	Workloads []WorkloadResult `json:"workloads"`
	Failed    bool             `json:"failed"`
}

Result is the outcome of applying a plan.

func Apply

func Apply(ctx context.Context, cs kubernetes.Interface, plan *Plan, opts ApplyOptions) *Result

Apply applies release CRDs (when planned) then patches only the changed workloads, one at a time, waiting for each rollout. On image-rollout failure it stops and, when enabled, restores previous images of every workload touched in this run in reverse order. CRD applies are not rolled back (Kubernetes CRD downgrades are unsafe).

type RolloutWaiter

type RolloutWaiter func(ctx context.Context, namespace, name string, timeout time.Duration) error

RolloutWaiter waits for a Deployment rollout to complete.

func DefaultWaiter

func DefaultWaiter(cs kubernetes.Interface) RolloutWaiter

DefaultWaiter waits using k8sclient rollout semantics.

type Row

type Row struct {
	Component      string   `json:"component"`
	Namespace      string   `json:"namespace,omitempty"`
	Deployment     string   `json:"deployment,omitempty"`
	Container      string   `json:"container,omitempty"`
	EnvVar         string   `json:"envVar,omitempty"`
	CurrentImage   string   `json:"currentImage,omitempty"`
	CurrentDigest  string   `json:"currentDigest,omitempty"`
	TargetImage    string   `json:"targetImage,omitempty"`
	CurrentVersion string   `json:"currentVersion,omitempty"`
	TargetVersion  string   `json:"targetVersion,omitempty"`
	Action         string   `json:"action"`
	Reason         string   `json:"reason,omitempty"`
	Notes          []string `json:"notes,omitempty"`
	// contains filtered or unexported fields
}

Row is one component line in the plan.

type Selection

type Selection struct {
	Only               []string
	IncludeAuth        bool
	IncludeCertManager bool
	AllowDowngrade     bool
}

Selection controls which components are considered.

type WorkloadResult

type WorkloadResult struct {
	Namespace  string   `json:"namespace"`
	Deployment string   `json:"deployment"`
	Components []string `json:"components"`
	Status     string   `json:"status"`
	Error      string   `json:"error,omitempty"`
	// Recovery lists manual commands to restore the previous images.
	Recovery []string `json:"recovery,omitempty"`
	// contains filtered or unexported fields
}

WorkloadResult reports what happened to one Deployment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL