Documentation
¶
Overview ¶
Package phase is all the various phases used for bootstrapping a cluster. The phase files are named in a rough order used during an install; - 0x are for preconnection resources, along with ssh-ing into the node - 1x are used to gather information about the nodes in the cluster - 2x are for modifying host services, like firewalls, host files, and enabling kernel level modules - 5x are for staging files for the distro engine, e.i. rpm's, apt's, or binary files - 6x are for starting the engine or for upgrading an existing install - 8x are for resetting the engine from the nodes - 9x are last minute things and finally disconnecting from a node - ext are files that are currently not used but may be incorporated later
Index ¶
- Constants
- Variables
- func CheckTargetHosts(hosts cluster.Hosts, targets []string) error
- func DryRunNote(p Phase) string
- func Titles(results []PhaseResult) []string
- type APTUploadFiles
- type ApplyManifests
- type BINUploadFiles
- type ConfigureEngine
- type ConfigureFirewall
- type Connect
- type DaemonReload
- type DeleteCommon
- type DeleteControllers
- type DeleteWorkers
- type DetectOS
- type DetectRemovedHosts
- func (p *DetectRemovedHosts) Explanation() string
- func (p *DetectRemovedHosts) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
- func (p *DetectRemovedHosts) ReadOnly() string
- func (p *DetectRemovedHosts) Run(ctx context.Context) error
- func (p *DetectRemovedHosts) ShouldRun() bool
- func (p *DetectRemovedHosts) Title() string
- type Disconnect
- type DryRunBehavior
- type EngineConfigSyncController
- type EngineConfigSyncHosts
- type EngineConfigSyncWorker
- type GatherFacts
- type GatherFactsDistro
- func (p *GatherFactsDistro) Explanation() string
- func (p *GatherFactsDistro) Prepare(_ context.Context, _ *cluster.Cluster, d *distro.Distro) error
- func (p *GatherFactsDistro) ReadOnly() string
- func (p *GatherFactsDistro) Run(ctx context.Context) (err error)
- func (p *GatherFactsDistro) Title() string
- type GenericPhase
- func (p *GenericPhase) GetDistro() *distro.Distro
- func (p *GenericPhase) Prepare(c *cluster.Cluster, d *distro.Distro) error
- func (p *GenericPhase) SetManager(m *Manager)
- func (p *GenericPhase) VersionGreater(host *cluster.Host, version string) bool
- func (p *GenericPhase) VersionLess(host *cluster.Host, version string) bool
- func (p *GenericPhase) VersionSkewTooGreat(host *cluster.Host, target string) bool
- func (p *GenericPhase) Wet(f errorfunc) error
- type HostChange
- type HostChangeDetail
- type HostSummary
- type ImportImages
- type InitializeControllers
- func (p *InitializeControllers) Explanation() string
- func (p *InitializeControllers) Prepare(ctx context.Context, c *cluster.Cluster, _ *distro.Distro) error
- func (p *InitializeControllers) Run(ctx context.Context) error
- func (p *InitializeControllers) ShouldRun() bool
- func (p *InitializeControllers) Title() string
- type InitializeWorkers
- type InstallStagedFiles
- type KubeConfig
- func (p *KubeConfig) Bytes() ([]byte, error)
- func (p *KubeConfig) Config() *clientcmdapi.Config
- func (p *KubeConfig) Explanation() string
- func (p *KubeConfig) Prepare(ctx context.Context, c *cluster.Cluster, _ *distro.Distro) error
- func (p *KubeConfig) Run(_ context.Context) error
- func (p *KubeConfig) ShouldRun() bool
- func (p *KubeConfig) Title() string
- type LabelNodes
- type Lock
- func (p *Lock) Cancel(_ context.Context)
- func (p *Lock) CleanUp()
- func (p *Lock) Explanation() string
- func (p *Lock) Prepare(ctx context.Context, c *cluster.Cluster, _ *distro.Distro) error
- func (p *Lock) Run(ctx context.Context) error
- func (p *Lock) Title() string
- func (p *Lock) UnlockPhase() Phase
- type Manager
- type ManifestEntry
- type ModifyHosts
- func (c *ModifyHosts) Changed() bool
- func (p *ModifyHosts) Explanation() string
- func (c *ModifyHosts) HostsChanged() []HostChange
- func (p *ModifyHosts) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
- func (p *ModifyHosts) Run(ctx context.Context) error
- func (p *ModifyHosts) ShouldRun() bool
- func (p *ModifyHosts) Title() string
- type Phase
- type PhaseResult
- type Phases
- type PrepareFapolicy
- func (c *PrepareFapolicy) Changed() bool
- func (p *PrepareFapolicy) Explanation() string
- func (c *PrepareFapolicy) HostsChanged() []HostChange
- func (p *PrepareFapolicy) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
- func (p *PrepareFapolicy) Run(ctx context.Context) error
- func (p *PrepareFapolicy) ShouldRun() bool
- func (p *PrepareFapolicy) Title() string
- type PrepareHosts
- func (c *PrepareHosts) Changed() bool
- func (p *PrepareHosts) Explanation() string
- func (c *PrepareHosts) HostsChanged() []HostChange
- func (p *PrepareHosts) Prepare(_ context.Context, _ *cluster.Cluster, d *distro.Distro) error
- func (p *PrepareHosts) Run(ctx context.Context) error
- func (p *PrepareHosts) Title() string
- type PrepareKernelModules
- func (c *PrepareKernelModules) Changed() bool
- func (p *PrepareKernelModules) Explanation() string
- func (c *PrepareKernelModules) HostsChanged() []HostChange
- func (p *PrepareKernelModules) Prepare(_ context.Context, _ *cluster.Cluster, _ *distro.Distro) error
- func (p *PrepareKernelModules) Run(ctx context.Context) error
- func (p *PrepareKernelModules) ShouldRun() bool
- func (p *PrepareKernelModules) Title() string
- type PrepareSelinux
- type PrepareSelinuxPolicy
- func (c *PrepareSelinuxPolicy) Changed() bool
- func (p *PrepareSelinuxPolicy) Explanation() string
- func (c *PrepareSelinuxPolicy) HostsChanged() []HostChange
- func (p *PrepareSelinuxPolicy) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
- func (p *PrepareSelinuxPolicy) Run(ctx context.Context) error
- func (p *PrepareSelinuxPolicy) ShouldRun() bool
- func (p *PrepareSelinuxPolicy) Title() string
- type RPMUploadFiles
- type ReconfigureSurvivors
- func (c *ReconfigureSurvivors) Changed() bool
- func (p *ReconfigureSurvivors) Explanation() string
- func (c *ReconfigureSurvivors) HostsChanged() []HostChange
- func (p *ReconfigureSurvivors) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
- func (p *ReconfigureSurvivors) Run(ctx context.Context) error
- func (p *ReconfigureSurvivors) ShouldRun() bool
- func (p *ReconfigureSurvivors) Title() string
- type RemoveSelinuxPolicy
- func (p *RemoveSelinuxPolicy) Explanation() string
- func (p *RemoveSelinuxPolicy) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
- func (p *RemoveSelinuxPolicy) Run(ctx context.Context) error
- func (p *RemoveSelinuxPolicy) ShouldRun() bool
- func (p *RemoveSelinuxPolicy) Title() string
- type ResultSink
- type RunResult
- type UninstallEngine
- type Unlock
- type UpgradeController
- type UpgradeHosts
- type UpgradeWorkers
- type UploadFiles
- type UploadFilesCommon
- type ValidateHosts
Constants ¶
const ( // SignalUnknown means no phase reported whether it changed anything, so the changed answer // beside it is a convention rather than an observation. SignalUnknown = "unknown" // SignalPartial means some phases reported and some did not. The ones that did not are // named by Undeclared. SignalPartial = "partial" // SignalComplete means every phase the run reached reported whether it changed anything. SignalComplete = "complete" )
Changed signal values, naming how much a reported Changed is worth.
They live here rather than with any one caller because more than one reports them: the Ansible module's changedSignal and the CLI run receipt are the same claim about the same RunResult, and a second copy of the vocabulary is a second thing to keep in step.
const ( // FAPolicydRuleFile path on the host FAPolicydRuleFile = "/etc/fapolicyd/rules.d/31-cargoship.rules" // FAPolicydExecutableRuleFile path for automatically generated executable rules on the host FAPolicydExecutableRuleFile = "/etc/fapolicyd/rules.d/32-cargoship-executable.rules" // FAPOLICYD name of the service for fapolicyd FAPOLICYD = "fapolicyd" )
const ( // SELinuxPolicyDir is the directory on the host holding cargoship's CIL policy modules SELinuxPolicyDir = "/var/lib/cargoship/selinux" // SELinuxStateFile records the settings cargoship changed, so a reset can restore them SELinuxStateFile = SELinuxPolicyDir + "/cargoship-state.json" // SEModule name of the binary that installs a policy module SEModule = "semodule" // DefaultSELinuxModulePriority is the semodule priority a module installs at when it sets // none. It sits above the distribution policy's 100 so a package module overrides rather // than conflicts with the shipped policy. DefaultSELinuxModulePriority = 400 // DefaultSELinuxFileType is the semanage fcontext file type used when a mapping sets none DefaultSELinuxFileType = "all" )
const (
// ContainerSELinux package name
ContainerSELinux = "container-selinux"
)
const (
// UnknownVersion for when the version is not set
UnknownVersion = "v0.0.0"
)
Variables ¶
var ErrControllersNotOneAtATime = errors.New("more than one running controller is being removed in a single run: " +
"remove them one run at a time, so each removal starts from a cluster that still has every member")
ErrControllersNotOneAtATime is returned when a run that keeps the cluster removes more than one running controller.
Each removal is a raft reconfiguration that needs a majority of the membership it starts from, and cargoship takes the engine down on a controller before deleting its node so the member cannot vote or re-register behind the run. Two removals in one run therefore pass through a state the second one cannot commit from: three members, one already stopped, is a majority of two out of three; the next stop leaves one of two, and the removal hangs with the cluster unavailable rather than failing cleanly.
Removing them in separate runs is safe because the cluster is whole again at the start of each.
var ErrNoControllers = errors.New("no controllers are running")
ErrNoControllers an error for when no controllers are running
var ErrNoKubeConfig = errors.New("kubeconfig has not been built")
ErrNoKubeConfig is returned when the config is asked for before the phase has run
var ErrNoRunningController = errors.New("no controller is running the engine this reset was told to remove: " +
"removing a subset of the hosts needs a controller that stays, to drain and delete their nodes through. " +
"Check that --distro, or distro.type in the cargoship config file, names the engine the fleet actually " +
"runs, or reset the whole cluster rather than a subset")
ErrNoRunningController is returned when a reset of part of a cluster finds no controller running the engine it was told to remove.
The deletions are kubectl commands run on a controller that stays, so with none answering there is nothing to drive them with. Skipping them instead -- which is what used to happen -- leaves the targeted host with its files removed, its engine still running and its node still in the cluster, and the run reports success over it.
The usual cause is a run pointed at the wrong engine: the controller service it looks for is the one `--distro` named, not the one the fleet runs, so a k3s cluster reset as rke2 looks exactly like a cluster whose control plane is down.
var ErrNoSurvivingController = errors.New("every running controller is being removed, but not every host is: " +
"target the whole cluster to tear it down, or leave a controller out of the target list to remove a subset through it")
ErrNoSurvivingController is returned when every running controller is being removed, but some host is not. Tearing a subset down works by driving kubectl through a controller that stays, so a run with no controller left to drive is a whole-cluster teardown wearing a subset's clothes: it would drain and delete nodes through a machine it is about to uninstall, and whether that finished would depend on the order the hosts happened to be in.
Removing every host is still allowed. That is a reset, and reset is what it is for.
var ErrUnmanagedNodes = errors.New("the cluster holds nodes the config does not: add the host back to the config, run `cargoship reset` against it, or pass --allow-unmanaged-nodes to apply anyway")
ErrUnmanagedNodes is returned when the cluster holds a node no host in the config accounts for. Apply removes nothing, so continuing would report success over a machine that is still running the engine and still joined.
var ErrWillNotDowngrade = errors.New("will not downgrade the cluster: raise the package version, or pass --allow-downgrade to continue anyway")
ErrWillNotDowngrade is returned when a host already runs a version newer than the one the package carries. An engine does not support moving backwards, so the run stops here rather than uninstalling a newer version part way through.
var ErrWillNotUpgradeVersionSkewTooGreat = errors.New("will not upgrade the cluster more than one minor version at a time")
ErrWillNotUpgradeVersionSkewTooGreat is returned when a package is trying to upgrade the cluster more then 1 minor version at a time; v1.33.x to v1.34.x is allowed, but v1.33.x to v1.35.x is not.
var ( // Interval is the time to wait between retry attempts Interval = 10 * time.Second )
Functions ¶
func CheckTargetHosts ¶ added in v0.32.0
CheckTargetHosts reports a target that names no host in the configuration.
A target nobody matches is the quiet failure this whole feature could have: the filter returns an empty set, every phase reports nothing to do, and the run succeeds having removed nothing. A typo in a hostname is the ordinary way to get there.
func DryRunNote ¶
DryRunNote returns the phase's own account of why a dry run runs it, or "" for a phase that gives none. Only read-only phases carry one: they are the phases a dry run runs against live hosts, so they are the ones a reader is entitled to an argument about.
func Titles ¶
func Titles(results []PhaseResult) []string
Titles names the phases in a slice, for a caller that reports a list of names rather than the detail behind them.
Types ¶
type APTUploadFiles ¶
type APTUploadFiles struct {
UploadFilesCommon
}
APTUploadFiles implements a phase which upload files to hosts
func (*APTUploadFiles) Explanation ¶
func (p *APTUploadFiles) Explanation() string
Explanation about the current phase, used for documentation generation
type ApplyManifests ¶ added in v0.30.0
type ApplyManifests struct {
GenericPhase
Distro distrocfg.Distro
// contains filtered or unexported fields
}
ApplyManifests kubectl-applies the raw manifests a distro's package declares -- typically a CNI -- from the leader, once it has bootstrapped and before workers are expected to join.
func (*ApplyManifests) Explanation ¶ added in v0.30.0
func (p *ApplyManifests) Explanation() string
Explanation about the current phase, used for documentation generation
func (*ApplyManifests) Run ¶ added in v0.30.0
func (p *ApplyManifests) Run(ctx context.Context) error
Run the phase
func (*ApplyManifests) ShouldRun ¶ added in v0.30.0
func (p *ApplyManifests) ShouldRun() bool
ShouldRun is true when there is a leader to apply from and the package declares manifests.
func (*ApplyManifests) Title ¶ added in v0.30.0
func (p *ApplyManifests) Title() string
Title for the phase
type BINUploadFiles ¶
type BINUploadFiles struct {
UploadFilesCommon
Distro distrocfg.Distro
}
BINUploadFiles implements a phase which upload files to hosts
func (*BINUploadFiles) Explanation ¶
func (p *BINUploadFiles) Explanation() string
Explanation about the current phase, used for documentation generation
type ConfigureEngine ¶
type ConfigureEngine struct {
GenericPhase
Distro distrocfg.Distro
// Keyring decrypts encrypted registry credentials, in either supported format. If it holds
// nothing that reads a given value, Prepare errors.
Keyring *clustercfg.Keyring
// contains filtered or unexported fields
}
ConfigureEngine writes the engine configuration to host engine config dir
func (*ConfigureEngine) Explanation ¶
func (p *ConfigureEngine) Explanation() string
Explanation about the current phase, used for documentation generation
func (*ConfigureEngine) Run ¶
func (p *ConfigureEngine) Run(ctx context.Context) error
Run the phase title
func (*ConfigureEngine) Title ¶
func (p *ConfigureEngine) Title() string
Title returns the phase title
type ConfigureFirewall ¶
type ConfigureFirewall struct {
GenericPhase
Distro distrocfg.Distro
Enabled bool
// contains filtered or unexported fields
}
ConfigureFirewall state
func (*ConfigureFirewall) Explanation ¶
func (p *ConfigureFirewall) Explanation() string
Explanation about the current phase, used for documentation generation
func (*ConfigureFirewall) Prepare ¶
func (p *ConfigureFirewall) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
Prepare the phase
func (*ConfigureFirewall) Run ¶
func (p *ConfigureFirewall) Run(ctx context.Context) error
Run the phase
func (*ConfigureFirewall) ShouldRun ¶
func (p *ConfigureFirewall) ShouldRun() bool
ShouldRun is true when the firewall is being managed and at least one node runs one
type Connect ¶
type Connect struct {
GenericPhase
}
Connect connects to each of the hosts
func (*Connect) Explanation ¶
Explanation about the current phase, used for documentation generation
type DaemonReload ¶
type DaemonReload struct {
GenericPhase
TargetHosts []string
}
DaemonReload phase runs `systemctl daemon-reload` or equivalent on all hosts.
func (*DaemonReload) Explanation ¶
func (p *DaemonReload) Explanation() string
Explanation about the current phase, used for documentation generation
func (*DaemonReload) ShouldRun ¶
func (p *DaemonReload) ShouldRun() bool
ShouldRun is true when there are controllers that needs to be reset
type DeleteCommon ¶
type DeleteCommon struct {
GenericPhase
Distro distrocfg.Distro
TargetHosts []string
// contains filtered or unexported fields
}
DeleteCommon phase state
type DeleteControllers ¶
type DeleteControllers struct {
DeleteCommon
NoDrain bool
// contains filtered or unexported fields
}
DeleteControllers phase state
func (*DeleteControllers) Explanation ¶
func (p *DeleteControllers) Explanation() string
Explanation about the current phase, used for documentation generation
func (*DeleteControllers) Prepare ¶
func (p *DeleteControllers) Prepare(ctx context.Context, c *cluster.Cluster, d *distro.Distro) error
Prepare the phase
func (*DeleteControllers) Run ¶
func (p *DeleteControllers) Run(ctx context.Context) error
Run the phase
func (*DeleteControllers) ShouldRun ¶
func (p *DeleteControllers) ShouldRun() bool
ShouldRun is true when this phase is enabled
type DeleteWorkers ¶
type DeleteWorkers struct {
DeleteCommon
NoDrain bool
WorkerConcurrent string
// contains filtered or unexported fields
}
DeleteWorkers phase state
func (*DeleteWorkers) Explanation ¶
func (p *DeleteWorkers) Explanation() string
Explanation about the current phase, used for documentation generation
func (*DeleteWorkers) ShouldRun ¶
func (p *DeleteWorkers) ShouldRun() bool
ShouldRun is true when this phase is enabled
type DetectOS ¶
type DetectOS struct {
GenericPhase
}
DetectOS performs remote OS detection
func (*DetectOS) Explanation ¶
Explanation about the current phase, used for documentation generation
type DetectRemovedHosts ¶
type DetectRemovedHosts struct {
GenericPhase
Distro distrocfg.Distro
// AllowUnmanaged downgrades the refusal to a warning. A cluster can hold nodes cargoship
// never joined, and refusing on those would block every apply on a working setup, so the
// operator needs a way to say the extra nodes are deliberate.
AllowUnmanaged bool
// contains filtered or unexported fields
}
DetectRemovedHosts state.
Apply drives the cluster towards the config, but only ever forwards: every phase after this one reads Spec.Hosts and acts on what it finds there. A host deleted from the config is therefore invisible to all of them, and the machine keeps running the engine and stays joined to the cluster while apply reports success. This phase is what stops that from being silent.
It detects and refuses. It does not reconcile, and the reason is not effort: apply cannot reach the machine it would have to clean up. Draining a node and deleting its Node object needs only the name, which the API gives us. Uninstalling the engine needs an SSH connection, and the address, user and key for that lived in the host block that was just deleted. Deleting the Node object without the uninstall is worse than doing nothing, because it looks like the removal worked while the machine keeps its certificates and tries to rejoin -- and for a controller it stays an etcd member, so the quorum arithmetic silently moves against a member nobody can reach.
The layer that does hold the connection details for a removed host is the OpenTofu provider, which still has the old host block in its state file when it plans the destroy. That is where a real removal path belongs, and it can call reset against exactly that host. Until then this phase makes the gap loud instead of invisible.
func (*DetectRemovedHosts) Explanation ¶
func (p *DetectRemovedHosts) Explanation() string
Explanation about the current phase, used for documentation generation
func (*DetectRemovedHosts) Prepare ¶
func (p *DetectRemovedHosts) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
Prepare the phase.
The leader is any host in the config already running the controller service, which is the same way the label and delete phases find one. Nothing is running on a first install, so there is no leader, and ShouldRun turns the phase off: a cluster that does not exist yet cannot have had a host removed from it.
func (*DetectRemovedHosts) ReadOnly ¶
func (p *DetectRemovedHosts) ReadOnly() string
ReadOnly marks this phase safe under a dry run, and returns the reason for the phase docs.
func (*DetectRemovedHosts) Run ¶
func (p *DetectRemovedHosts) Run(ctx context.Context) error
Run the phase.
Only positive evidence stops the apply. Failing to reach the cluster says nothing about whether a host was removed, and this phase runs before every phase that does the real work, so treating an unreachable cluster as a refusal would turn a transient failure into a failed apply that had nothing to do with removals. Those cases warn and continue.
func (*DetectRemovedHosts) ShouldRun ¶
func (p *DetectRemovedHosts) ShouldRun() bool
ShouldRun is true once there is a running controller to ask
type Disconnect ¶
type Disconnect struct {
GenericPhase
}
Disconnect disconnects from the hosts
func (*Disconnect) DryRun ¶
func (p *Disconnect) DryRun() error
DryRun cleans up the temporary binary from the hosts
func (*Disconnect) Explanation ¶
func (p *Disconnect) Explanation() string
Explanation about the current phase, used for documentation generation
type DryRunBehavior ¶
type DryRunBehavior int
DryRunBehavior is what a dry run does with a phase. It is derived from the interfaces the phase implements, and it is exported so magefiles/pkg/gen/docs/phase.go can label each phase in docs/phases/<name>.md with the same classification Run() gates on. The docs and the gate cannot disagree, because there is only one classifier.
const ( // DryRunSkip is the default: the phase declares nothing, so a dry run reports it and // does not run it. DryRunSkip DryRunBehavior = iota // DryRunReadOnly is a phase implementing readOnly. It reads hosts and changes nothing, // so a dry run runs it as itself. DryRunReadOnly // DryRunOwnPath is a phase implementing withDryRun. A dry run calls DryRun() instead of // Run(). DryRunOwnPath )
func ClassifyDryRun ¶
func ClassifyDryRun(p Phase) DryRunBehavior
ClassifyDryRun reports what a dry run does with p.
func (DryRunBehavior) String ¶
func (b DryRunBehavior) String() string
String is the label written into the phase docs.
type EngineConfigSyncController ¶
type EngineConfigSyncController struct {
EngineConfigSyncHosts
}
EngineConfigSyncController phase state
func (*EngineConfigSyncController) Explanation ¶
func (p *EngineConfigSyncController) Explanation() string
Explanation about the current phase, used for documentation generation
func (*EngineConfigSyncController) Prepare ¶
func (p *EngineConfigSyncController) Prepare(ctx context.Context, c *cluster.Cluster, d *distro.Distro) error
Prepare the phase
func (*EngineConfigSyncController) Run ¶
func (p *EngineConfigSyncController) Run(ctx context.Context) error
Run the phase
func (*EngineConfigSyncController) Title ¶
func (p *EngineConfigSyncController) Title() string
Title for the phase
type EngineConfigSyncHosts ¶
type EngineConfigSyncHosts struct {
GenericPhase
Distro distrocfg.Distro
// Keyring decrypts encrypted registry credentials, in either supported format.
Keyring *clustercfg.Keyring
// contains filtered or unexported fields
}
EngineConfigSyncHosts phase state
func (*EngineConfigSyncHosts) Changed ¶
func (p *EngineConfigSyncHosts) Changed() bool
Changed reports whether this phase altered any host, which is what Ansible's changed is built from. See changedReporter in 05_manager.go.
There are two ways this phase changes a host and both count. The obvious one is the sync itself. The other is the file a host carries that the engine re-reads without a restart: that is written while Prepare is deciding which hosts have drifted, and the host is then not listed as needing a sync, so a run that changed only those files would otherwise read as a run that did nothing.
func (*EngineConfigSyncHosts) HostsChanged ¶ added in v0.33.0
func (p *EngineConfigSyncHosts) HostsChanged() []HostChange
HostsChanged reports what this phase did to each host it looked at. See hostChangedReporter in 05_manager.go.
Every host Prepare checked is reported, including the ones that turned out to be in sync. A host that was checked and found correct is a different answer from a host nothing looked at, and only one of them means the fleet was fully assessed.
The order is by address rather than by the order the hosts were reached, which is whatever the parallel sweep happened to finish in and would differ between two identical runs.
func (*EngineConfigSyncHosts) ShouldRun ¶
func (p *EngineConfigSyncHosts) ShouldRun() bool
ShouldRun is true when there are hosts to sync
type EngineConfigSyncWorker ¶
type EngineConfigSyncWorker struct {
EngineConfigSyncHosts
WorkerConcurrent string
}
EngineConfigSyncWorker phase state
func (*EngineConfigSyncWorker) Explanation ¶
func (p *EngineConfigSyncWorker) Explanation() string
Explanation about the current phase, used for documentation generation
func (*EngineConfigSyncWorker) Prepare ¶
func (p *EngineConfigSyncWorker) Prepare(ctx context.Context, c *cluster.Cluster, d *distro.Distro) error
Prepare the phase
func (*EngineConfigSyncWorker) Run ¶
func (p *EngineConfigSyncWorker) Run(ctx context.Context) error
Run the phase
func (*EngineConfigSyncWorker) Title ¶
func (p *EngineConfigSyncWorker) Title() string
Title for the phase
type GatherFacts ¶
type GatherFacts struct {
GenericPhase
// contains filtered or unexported fields
}
GatherFacts gathers information about hosts
func (*GatherFacts) Explanation ¶
func (p *GatherFacts) Explanation() string
Explanation about the current phase, used for documentation generation
func (*GatherFacts) ReadOnly ¶
func (p *GatherFacts) ReadOnly() string
ReadOnly marks this phase safe under a dry run, and returns the reason for the phase docs.
type GatherFactsDistro ¶
type GatherFactsDistro struct {
GenericPhase
Distro distrocfg.Distro
// AllowDowngrade turns the refusal below into a warning. A downgrade is refused by default
// because an engine does not support being moved backwards and the data directory it leaves
// behind was written by the newer version, so the operator has to say that they mean it.
AllowDowngrade bool
// contains filtered or unexported fields
}
GatherFactsDistro state
func (*GatherFactsDistro) Explanation ¶
func (p *GatherFactsDistro) Explanation() string
Explanation about the current phase, used for documentation generation
func (*GatherFactsDistro) ReadOnly ¶
func (p *GatherFactsDistro) ReadOnly() string
ReadOnly marks this phase safe under a dry run, and returns the reason for the phase docs.
type GenericPhase ¶
type GenericPhase struct {
// contains filtered or unexported fields
}
GenericPhase state
func (*GenericPhase) GetDistro ¶
func (p *GenericPhase) GetDistro() *distro.Distro
GetDistro is an accessor to phase Distro
func (*GenericPhase) SetManager ¶
func (p *GenericPhase) SetManager(m *Manager)
SetManager adds a reference to the phase manager
func (*GenericPhase) VersionGreater ¶
func (p *GenericPhase) VersionGreater(host *cluster.Host, version string) bool
VersionGreater if host version is greater then the distro version
func (*GenericPhase) VersionLess ¶
func (p *GenericPhase) VersionLess(host *cluster.Host, version string) bool
VersionLess if host version is less then the distro version
func (*GenericPhase) VersionSkewTooGreat ¶ added in v0.30.0
func (p *GenericPhase) VersionSkewTooGreat(host *cluster.Host, target string) bool
VersionSkewTooGreat reports whether host's running version is more than one minor version behind target. kubeadm's own upgrade path refuses to skip a minor version, and a two-minor jump fails partway through the control plane rather than up front, so this catches it before a real run starts one. UnknownVersion (no engine detected yet, a fresh install) never counts as skew.
func (*GenericPhase) Wet ¶
func (p *GenericPhase) Wet(f errorfunc) error
Wet is a shorthand for manager.Wet
type HostChange ¶ added in v0.33.0
type HostChange struct {
// Host identifies the host as the cluster configuration would: the address from its host
// block, with the port when it is not the default. A hostname is not enough on its own,
// because Host.Hostname is an optional override that is empty on most hosts.
Host string
Changed bool
// Details names what moved on this host, one entry per file or setting. It is empty when
// the phase knows the host changed but not what in it, which is a weaker answer than a
// populated list rather than a claim that nothing in particular happened.
Details []HostChangeDetail
}
HostChange is what one phase did to one host.
type HostChangeDetail ¶ added in v0.33.0
type HostChangeDetail struct {
// Path is the file this is about, absolute as the host sees it.
Path string
// Reason is why the phase touched it, in the vocabulary the phases already log: "missing",
// "out of sync", "wrong mode", "stale".
Reason string
// Diff is a unified diff of the change. It is empty when the phase never read the prior
// content -- several phases compare by checksum or write unconditionally, and an empty Diff
// says the content was not compared rather than that it did not differ.
//
// It can carry anything the file carried, which for an engine configuration includes join
// tokens and registry credentials. Anything rendering a receipt outside the management node
// is expected to drop it.
Diff string
}
HostChangeDetail is one thing a phase did to one host.
type HostSummary ¶ added in v0.33.0
type HostSummary struct {
Host string
Changed bool
// Named is how many phases named this host, and Reporting how many declared per host at
// all. They are reported as a pair because Named alone cannot be read: a host named by two
// of two reporting phases has been fully accounted for, and a host named by two of fifteen
// has not, and the two look identical without the denominator.
Named int
Reporting int
}
HostSummary is one host's line in a run summary.
type ImportImages ¶ added in v0.29.0
type ImportImages struct {
GenericPhase
Distro distrocfg.Distro
// contains filtered or unexported fields
}
ImportImages imports uploaded image tarballs into a distro's engine, for a distro whose engine does not do this on its own. rke2 and k3s's own agents import automatically, so most applies skip this phase entirely -- ShouldRun is false unless the distro opts in.
func (*ImportImages) Explanation ¶ added in v0.29.0
func (p *ImportImages) Explanation() string
Explanation about the current phase, used for documentation generation
func (*ImportImages) Run ¶ added in v0.29.0
func (p *ImportImages) Run(ctx context.Context) error
Run the phase
func (*ImportImages) ShouldRun ¶ added in v0.29.0
func (p *ImportImages) ShouldRun() bool
ShouldRun is true when the distro needs images imported for it and there is somewhere to import them from.
func (*ImportImages) Title ¶ added in v0.29.0
func (p *ImportImages) Title() string
Title for the phase
type InitializeControllers ¶
type InitializeControllers struct {
GenericPhase
Distro distrocfg.Distro
// contains filtered or unexported fields
}
InitializeControllers phase state
func (*InitializeControllers) Explanation ¶
func (p *InitializeControllers) Explanation() string
Explanation about the current phase, used for documentation generation
func (*InitializeControllers) Prepare ¶
func (p *InitializeControllers) Prepare(ctx context.Context, c *cluster.Cluster, _ *distro.Distro) error
Prepare the phase
func (*InitializeControllers) Run ¶
func (p *InitializeControllers) Run(ctx context.Context) error
Run the phase
func (*InitializeControllers) ShouldRun ¶
func (p *InitializeControllers) ShouldRun() bool
ShouldRun is true when there are workers
func (*InitializeControllers) Title ¶
func (p *InitializeControllers) Title() string
Title for the phase
type InitializeWorkers ¶
type InitializeWorkers struct {
GenericPhase
Distro distrocfg.Distro
WorkerConcurrent string
// contains filtered or unexported fields
}
InitializeWorkers phase state
func (*InitializeWorkers) Explanation ¶
func (p *InitializeWorkers) Explanation() string
Explanation about the current phase, used for documentation generation
func (*InitializeWorkers) Prepare ¶
func (p *InitializeWorkers) Prepare(ctx context.Context, c *cluster.Cluster, _ *distro.Distro) error
Prepare the phase
func (*InitializeWorkers) Run ¶
func (p *InitializeWorkers) Run(ctx context.Context) error
Run the phase
func (*InitializeWorkers) ShouldRun ¶
func (p *InitializeWorkers) ShouldRun() bool
ShouldRun is true when there are workers
type InstallStagedFiles ¶ added in v0.36.0
type InstallStagedFiles struct {
GenericPhase
}
InstallStagedFiles runs the install the upload phases staged on any host where nothing else ran it.
The upload phases do not install what they upload. They hand each host a closure -- see BINUploadFiles, RPMUploadFiles and APTUploadFiles -- and the initialize and upgrade phases call it, which is deliberate: an executable is uploaded to "<target>.tmp.<nonce>" and the closure is what moves it into place, so a rolling upgrade replaces a running engine binary on one host at a time, immediately before that host restarts onto it.
What that leaves is a host no phase acts on. InitializeControllers, InitializeWorkers and UpgradeHosts are each gated on having a host to initialize or upgrade, so a converge of a cluster already running the package's version calls none of them -- while the upload phases have no such gate and stage regardless. The host was left with the new engine binary under its .tmp.<nonce> name and nothing at the path its unit file names: a cluster that keeps running, because the engine was already exec'd, and that cannot be restarted. Nothing reported it.
This phase closes that gap without moving the install earlier. It runs last of the install phases, so every host the initialize and upgrade phases claimed has already consumed its closure (installPackages clears it), and only a host nothing else installed is left to act on.
func (*InstallStagedFiles) Explanation ¶ added in v0.36.0
func (p *InstallStagedFiles) Explanation() string
Explanation about the current phase, used for documentation generation
func (*InstallStagedFiles) Run ¶ added in v0.36.0
func (p *InstallStagedFiles) Run(ctx context.Context) error
Run the phase
func (*InstallStagedFiles) ShouldRun ¶ added in v0.36.0
func (p *InstallStagedFiles) ShouldRun() bool
ShouldRun is true when a host is still carrying an install nothing has run.
func (*InstallStagedFiles) Title ¶ added in v0.36.0
func (p *InstallStagedFiles) Title() string
Title for the phase
type KubeConfig ¶
type KubeConfig struct {
GenericPhase
Distro distrocfg.Distro
ClusterID string
ClusterLB string
Enabled bool
// Write merges the config into the operator's local kubeconfig once it is built. The
// CLI sets it. A caller that only wants the value -- a provider holding it as an
// attribute, say -- leaves it false and reads Config after the run, so nobody's
// ~/.kube/config is touched as a side effect.
Write bool
// Path is the kubeconfig file Write merges into. Empty means the standard location:
// KUBECONFIG when set, otherwise ~/.kube/config. A path that does not exist is created,
// and one that does keeps every cluster already in it.
Path string
// contains filtered or unexported fields
}
KubeConfig phase state
func (*KubeConfig) Bytes ¶
func (p *KubeConfig) Bytes() ([]byte, error)
Bytes is Config serialized as a kubeconfig file, which is the form a caller storing it elsewhere wants.
func (*KubeConfig) Config ¶
func (p *KubeConfig) Config() *clientcmdapi.Config
Config is the kubeconfig for this cluster, built during Run from the admin credentials on the leader. It is nil until the phase has run.
func (*KubeConfig) Explanation ¶
func (p *KubeConfig) Explanation() string
Explanation about the current phase, used for documentation generation
func (*KubeConfig) ShouldRun ¶
func (p *KubeConfig) ShouldRun() bool
ShouldRun is true when enabled by flags
type LabelNodes ¶
type LabelNodes struct {
GenericPhase
Distro distrocfg.Distro
ClusterLB string
Enabled bool
// contains filtered or unexported fields
}
LabelNodes phase state
func (*LabelNodes) Explanation ¶
func (p *LabelNodes) Explanation() string
Explanation about the current phase, used for documentation generation
func (*LabelNodes) ShouldRun ¶
func (p *LabelNodes) ShouldRun() bool
ShouldRun is true when enabled by flags
type Lock ¶
type Lock struct {
GenericPhase
// contains filtered or unexported fields
}
Lock phase state
func (*Lock) Explanation ¶
Explanation about the current phase, used for documentation generation
func (*Lock) UnlockPhase ¶
UnlockPhase returns an unlock phase for this lock phase
type Manager ¶
type Manager struct {
Config *cluster.Cluster
Distro *distro.Distro
// Values is the configuration the package ships with, merged with the
// overrides in the cluster inventory and checked against the package's
// values schema. Phases read it instead of re-reading either source, so
// every phase sees the same values.
Values map[string]any
DistroID string
Concurrency int
ConcurrentUploads int
DryRun bool
Writer io.Writer
TempDirectory string
Timeout time.Duration
// Result is what the last Run did, phase by phase. Run fills it in whether it succeeded or
// failed, so a caller reading it after an error sees the phases the run got through. It is
// a field rather than a return value because Run has five call sites and one caller that
// wants this.
Result RunResult
// contains filtered or unexported fields
}
Manager executes phases to construct the cluster
func (*Manager) RetryTimeout ¶
RetryTimeout wraps retry Timeout logic
func (*Manager) SetTimeout ¶ added in v0.29.0
SetTimeout sets the timeout for the manager
func (*Manager) Wet ¶
Wet runs f unless this is a dry run, where it does nothing and reports no error. It is how a phase that changes a host declares which part of itself is the change.
It used to take a host and a message as well, and a second function to run instead during a dry run. Neither parameter was ever read -- the signature named them `_` -- and no caller ever passed the second function, so a dry run's account of a phase came from nowhere. What reports a dry run now is the DryRunBehavior classification above: a phase says what it would do through ClassifyDryRun and DryRunNote, once per phase, rather than per operation through a message that was built with fmt.Sprintf on every uploaded file and then discarded.
type ManifestEntry ¶
type ManifestEntry struct {
// Category labels why the file was uploaded, e.g. "engine", "image", "file", "data".
Category string
// Path is the absolute path of the file on the remote host.
Path string
}
ManifestEntry is a single file cargoship uploaded to a host, recorded so it can be found and removed later during an upgrade or uninstall.
func ParseManifest ¶
func ParseManifest(content string) []ManifestEntry
ParseManifest reads manifest file content back into entries. Malformed lines are skipped.
type ModifyHosts ¶
type ModifyHosts struct {
GenericPhase
Enabled bool
// contains filtered or unexported fields
}
ModifyHosts state
func (*ModifyHosts) Changed ¶ added in v0.33.0
func (c *ModifyHosts) Changed() bool
Changed reports whether the phase changed any host. See changedReporter in 05_manager.go.
func (*ModifyHosts) Explanation ¶
func (p *ModifyHosts) Explanation() string
Explanation about the current phase, used for documentation generation
func (*ModifyHosts) HostsChanged ¶ added in v0.33.0
func (c *ModifyHosts) HostsChanged() []HostChange
HostsChanged reports what the phase did to each host it touched. See hostChangedReporter in 05_manager.go.
The order is by address rather than by the order the hosts were reached, which is whatever the parallel sweep happened to finish in and would differ between two identical runs.
func (*ModifyHosts) ShouldRun ¶
func (p *ModifyHosts) ShouldRun() bool
ShouldRun is true when this phase is enabled
type PhaseResult ¶
type PhaseResult struct {
Title string
Explanation string
// DryRun is what a dry run does with this phase, whether or not this run was one.
DryRun DryRunBehavior
// Declared is whether the phase implements changedReporter. When it is false, Changed is
// false because nothing was asked, not because nothing happened.
Declared bool
Changed bool
// HostsDeclared is whether the phase implements hostChangedReporter, and stands to Hosts as
// Declared stands to Changed.
HostsDeclared bool
Hosts []HostChange
// Duration is how long the phase's Run -- or its DryRun, under a dry run -- took. It
// excludes the phase's Prepare, ShouldRun and in-phase Before/After hooks, so two phases'
// durations are comparable to each other rather than to the run's wall clock.
Duration time.Duration
}
PhaseResult is what a single phase did during a run.
type PrepareFapolicy ¶
type PrepareFapolicy struct {
GenericPhase
// contains filtered or unexported fields
}
PrepareFapolicy installs required packages and so on on the hosts.
func (*PrepareFapolicy) Changed ¶ added in v0.33.0
func (c *PrepareFapolicy) Changed() bool
Changed reports whether the phase changed any host. See changedReporter in 05_manager.go.
func (*PrepareFapolicy) Explanation ¶
func (p *PrepareFapolicy) Explanation() string
Explanation about the current phase, used for documentation generation
func (*PrepareFapolicy) HostsChanged ¶ added in v0.33.0
func (c *PrepareFapolicy) HostsChanged() []HostChange
HostsChanged reports what the phase did to each host it touched. See hostChangedReporter in 05_manager.go.
The order is by address rather than by the order the hosts were reached, which is whatever the parallel sweep happened to finish in and would differ between two identical runs.
func (*PrepareFapolicy) Run ¶
func (p *PrepareFapolicy) Run(ctx context.Context) error
Run the phase
func (*PrepareFapolicy) ShouldRun ¶
func (p *PrepareFapolicy) ShouldRun() bool
ShouldRun is true when there is a host with selinux or fapolicyd on the hosts
type PrepareHosts ¶
type PrepareHosts struct {
GenericPhase
// contains filtered or unexported fields
}
PrepareHosts installs required packages and so on on the hosts.
func (*PrepareHosts) Changed ¶ added in v0.33.0
func (c *PrepareHosts) Changed() bool
Changed reports whether the phase changed any host. See changedReporter in 05_manager.go.
func (*PrepareHosts) Explanation ¶
func (p *PrepareHosts) Explanation() string
Explanation about the current phase, used for documentation generation
func (*PrepareHosts) HostsChanged ¶ added in v0.33.0
func (c *PrepareHosts) HostsChanged() []HostChange
HostsChanged reports what the phase did to each host it touched. See hostChangedReporter in 05_manager.go.
The order is by address rather than by the order the hosts were reached, which is whatever the parallel sweep happened to finish in and would differ between two identical runs.
type PrepareKernelModules ¶
type PrepareKernelModules struct {
GenericPhase
Enabled bool
// contains filtered or unexported fields
}
PrepareKernelModules enables the list of requested modules on the host, then reboots the box if modules are added
func (*PrepareKernelModules) Changed ¶ added in v0.33.0
func (c *PrepareKernelModules) Changed() bool
Changed reports whether the phase changed any host. See changedReporter in 05_manager.go.
func (*PrepareKernelModules) Explanation ¶
func (p *PrepareKernelModules) Explanation() string
Explanation about the current phase, used for documentation generation
func (*PrepareKernelModules) HostsChanged ¶ added in v0.33.0
func (c *PrepareKernelModules) HostsChanged() []HostChange
HostsChanged reports what the phase did to each host it touched. See hostChangedReporter in 05_manager.go.
The order is by address rather than by the order the hosts were reached, which is whatever the parallel sweep happened to finish in and would differ between two identical runs.
func (*PrepareKernelModules) Prepare ¶
func (p *PrepareKernelModules) Prepare(_ context.Context, _ *cluster.Cluster, _ *distro.Distro) error
Prepare the phase
func (*PrepareKernelModules) Run ¶
func (p *PrepareKernelModules) Run(ctx context.Context) error
Run the phase
func (*PrepareKernelModules) ShouldRun ¶
func (p *PrepareKernelModules) ShouldRun() bool
ShouldRun is true when we need to enable kernel modules
func (*PrepareKernelModules) Title ¶
func (p *PrepareKernelModules) Title() string
Title for the phase
type PrepareSelinux ¶
type PrepareSelinux struct {
GenericPhase
// contains filtered or unexported fields
}
PrepareSelinux installs required packages and so on on the hosts.
func (*PrepareSelinux) Explanation ¶
func (p *PrepareSelinux) Explanation() string
Explanation about the current phase, used for documentation generation
func (*PrepareSelinux) ShouldRun ¶
func (p *PrepareSelinux) ShouldRun() bool
ShouldRun is true when there is a host with selinux on the hosts
type PrepareSelinuxPolicy ¶ added in v0.32.0
type PrepareSelinuxPolicy struct {
GenericPhase
// contains filtered or unexported fields
}
PrepareSelinuxPolicy installs the distro-supplied SELinux policy on the hosts.
func (*PrepareSelinuxPolicy) Changed ¶ added in v0.33.0
func (c *PrepareSelinuxPolicy) Changed() bool
Changed reports whether the phase changed any host. See changedReporter in 05_manager.go.
func (*PrepareSelinuxPolicy) Explanation ¶ added in v0.32.0
func (p *PrepareSelinuxPolicy) Explanation() string
Explanation about the current phase, used for documentation generation
func (*PrepareSelinuxPolicy) HostsChanged ¶ added in v0.33.0
func (c *PrepareSelinuxPolicy) HostsChanged() []HostChange
HostsChanged reports what the phase did to each host it touched. See hostChangedReporter in 05_manager.go.
The order is by address rather than by the order the hosts were reached, which is whatever the parallel sweep happened to finish in and would differ between two identical runs.
func (*PrepareSelinuxPolicy) Prepare ¶ added in v0.32.0
func (p *PrepareSelinuxPolicy) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
Prepare the phase
func (*PrepareSelinuxPolicy) Run ¶ added in v0.32.0
func (p *PrepareSelinuxPolicy) Run(ctx context.Context) error
Run the phase
func (*PrepareSelinuxPolicy) ShouldRun ¶ added in v0.32.0
func (p *PrepareSelinuxPolicy) ShouldRun() bool
ShouldRun is true when a host can take a policy and the distro package supplies one
func (*PrepareSelinuxPolicy) Title ¶ added in v0.32.0
func (p *PrepareSelinuxPolicy) Title() string
Title for the phase
type RPMUploadFiles ¶
type RPMUploadFiles struct {
UploadFilesCommon
}
RPMUploadFiles implements a phase which upload files to hosts
func (*RPMUploadFiles) Explanation ¶
func (p *RPMUploadFiles) Explanation() string
Explanation about the current phase, used for documentation generation
type ReconfigureSurvivors ¶ added in v0.32.0
type ReconfigureSurvivors struct {
GenericPhase
Distro distrocfg.Distro
TargetHosts []string
// contains filtered or unexported fields
}
ReconfigureSurvivors repoints the controllers a removal kept at a controller it did not remove.
A controller that is not the first one carries `server:` naming the first, written when it joined. That value is read at startup, so removing the first controller leaves a cluster that keeps working and cannot come back: every survivor names a machine that is gone, and the next restart or reboot of any of them fails to rejoin.
cargoship apply already fixes this -- it re-elects the first controller from the hosts that are left and rewrites `server:` on the rest -- and the documented procedure is to run one after a removal. The trouble with leaving it there is that a reset reports success having created that state, so the safety of the operation rests on the operator remembering a second command. This phase converges the survivors itself, and says so when it cannot.
It edits the file in place rather than rendering a fresh one, because a reset loads no package and so has nothing to render from. Only `server:` is touched.
func (*ReconfigureSurvivors) Changed ¶ added in v0.33.0
func (c *ReconfigureSurvivors) Changed() bool
Changed reports whether the phase changed any host. See changedReporter in 05_manager.go.
func (*ReconfigureSurvivors) Explanation ¶ added in v0.32.0
func (p *ReconfigureSurvivors) Explanation() string
Explanation about the current phase, used for documentation generation
func (*ReconfigureSurvivors) HostsChanged ¶ added in v0.33.0
func (c *ReconfigureSurvivors) HostsChanged() []HostChange
HostsChanged reports what the phase did to each host it touched. See hostChangedReporter in 05_manager.go.
The order is by address rather than by the order the hosts were reached, which is whatever the parallel sweep happened to finish in and would differ between two identical runs.
func (*ReconfigureSurvivors) Prepare ¶ added in v0.32.0
func (p *ReconfigureSurvivors) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
Prepare the phase
func (*ReconfigureSurvivors) Run ¶ added in v0.32.0
func (p *ReconfigureSurvivors) Run(ctx context.Context) error
Run the phase
func (*ReconfigureSurvivors) ShouldRun ¶ added in v0.32.0
func (p *ReconfigureSurvivors) ShouldRun() bool
ShouldRun is true when the run removed a controller and kept at least one, on a distro this phase knows how to repoint.
Removing every controller is a whole-cluster teardown, where there is nothing to repoint. An empty target list means every host, which is that same case.
func (*ReconfigureSurvivors) Title ¶ added in v0.32.0
func (p *ReconfigureSurvivors) Title() string
Title for the phase
type RemoveSelinuxPolicy ¶ added in v0.32.0
type RemoveSelinuxPolicy struct {
GenericPhase
// TargetHosts names the hosts being removed, empty for a whole-cluster reset. A reset of a
// subset is driven through hosts that stay, so the configuration holds every host and the
// target list is the only thing that says which of them this phase may touch.
TargetHosts []string
// contains filtered or unexported fields
}
RemoveSelinuxPolicy takes the SELinux policy cargoship applied back off the hosts.
func (*RemoveSelinuxPolicy) Explanation ¶ added in v0.32.0
func (p *RemoveSelinuxPolicy) Explanation() string
Explanation about the current phase, used for documentation generation
func (*RemoveSelinuxPolicy) Prepare ¶ added in v0.32.0
func (p *RemoveSelinuxPolicy) Prepare(ctx context.Context, _ *cluster.Cluster, _ *distro.Distro) error
Prepare the phase
func (*RemoveSelinuxPolicy) Run ¶ added in v0.32.0
func (p *RemoveSelinuxPolicy) Run(ctx context.Context) error
Run the phase
func (*RemoveSelinuxPolicy) ShouldRun ¶ added in v0.32.0
func (p *RemoveSelinuxPolicy) ShouldRun() bool
ShouldRun is true when a host carries a policy cargoship recorded
func (*RemoveSelinuxPolicy) Title ¶ added in v0.32.0
func (p *RemoveSelinuxPolicy) Title() string
Title for the phase
type ResultSink ¶
type ResultSink struct {
// contains filtered or unexported fields
}
ResultSink collects the RunResult of every Manager.Run that happens on a context.
It exists because the Ansible module mode runs cargoship by building an argument vector and calling the ordinary command, which returns an error and nothing else -- see src/cmd.ExecuteArgs. Threading a return value back through cobra, the action and the manager would change five call sites to serve one caller. A sink on the context that nobody else installs does not, and a run with no sink on its context pays nothing for this.
func WithResultSink ¶
func WithResultSink(ctx context.Context) (context.Context, *ResultSink)
WithResultSink returns a context carrying a sink, and the sink itself.
func (*ResultSink) Observed ¶
func (s *ResultSink) Observed() bool
Observed reports whether any run reached its phases at all. A command that failed before that -- an unreadable package, a configuration that does not validate -- publishes nothing, and that is a different thing from a run in which no phase changed anything.
func (*ResultSink) Result ¶
func (s *ResultSink) Result() RunResult
Result is every run that reached its phases on this context, flattened into one.
type RunResult ¶
type RunResult struct {
// Ran are the phases that executed, in order. That includes the read-only phases a dry run
// runs as themselves and the phases that took their own dry-run path. Running is not
// changing: Connect, DetectOS, GatherFacts and ValidateHosts all land here and change
// nothing, which is why Changed is asked separately.
Ran []PhaseResult
// Planned are the phases a dry run reported instead of running.
Planned []PhaseResult
// Skipped are the phases ShouldRun filtered out. They are kept because a phase can finish
// its work in Prepare and then have nothing left to run: EngineConfigSyncHosts writes the
// files the engine re-reads without a restart while it is deciding which hosts have
// drifted, and then reports no hosts to sync.
Skipped []PhaseResult
}
RunResult is what a whole Manager.Run did, phase by phase. Manager.Run fills it in on the way through, so a run that returned an error still carries the phases it got through first.
func (RunResult) Changed ¶
Changed reports whether any phase said it changed something on the fleet. Phases that declared nothing do not contribute; read Complete to find out whether that leaves the answer partial.
func (RunResult) Complete ¶
Complete reports whether every phase the run reached declared whether it changed anything.
func (RunResult) HostSummaries ¶ added in v0.33.0
func (r RunResult) HostSummaries() []HostSummary
HostSummaries rolls the per-host answers up across every phase of the run, in the order the hosts were first named.
A host appears here only if some phase named it, so this is not a roster of the fleet: a caller wanting every host, including the ones no phase spoke for, is expected to start from the cluster configuration and look each one up.
func (RunResult) HostsUndeclared ¶ added in v0.33.0
HostsUndeclared names the phases that did not say which hosts they changed, in the order the run reached them. It stands to the per-host answer as Undeclared stands to the fleet-wide one: a caller rendering a per-host summary is expected to report these alongside it, because a host missing from the summary may simply never have been spoken for.
func (RunResult) Outstanding ¶
Outstanding is the dry-run counterpart of Changed: it reports whether any phase that can report a change was reported rather than run. A phase reaches Planned only after its ShouldRun said there was work to do, so this answers "would a real run change anything" for the phases that have said how to tell.
func (RunResult) Signal ¶ added in v0.33.0
Signal reports how much Changed is worth, as one of SignalComplete or SignalPartial.
SignalUnknown is deliberately not among the answers. It means no run reached its phases at all, which is a property of the sink rather than of a result -- an empty RunResult and a run in which nothing was declared are the same value here. See ResultSink.Observed.
func (RunResult) Undeclared ¶
Undeclared names the phases that did not say whether they changed anything, in the order the run reached them. A caller reporting Changed is expected to report these alongside it.
type UninstallEngine ¶
type UninstallEngine struct {
GenericPhase
Distro distrocfg.Distro
WorkerConcurrent string
TargetHosts []string
// contains filtered or unexported fields
}
UninstallEngine state
func (*UninstallEngine) Explanation ¶
func (p *UninstallEngine) Explanation() string
Explanation about the current phase, used for documentation generation
type Unlock ¶
type Unlock struct {
GenericPhase
Cancel func(context.Context)
}
Unlock phase state
func (*Unlock) Explanation ¶
Explanation about the current phase, used for documentation generation
type UpgradeController ¶
type UpgradeController struct {
UpgradeHosts
}
UpgradeController phase state
func (*UpgradeController) Explanation ¶
func (p *UpgradeController) Explanation() string
Explanation about the current phase, used for documentation generation
func (*UpgradeController) Prepare ¶
func (p *UpgradeController) Prepare(ctx context.Context, _ *cluster.Cluster, d *distro.Distro) error
Prepare the phase
type UpgradeHosts ¶
type UpgradeHosts struct {
GenericPhase
Distro distrocfg.Distro
// contains filtered or unexported fields
}
UpgradeHosts phase state
func (*UpgradeHosts) ShouldRun ¶
func (p *UpgradeHosts) ShouldRun() bool
ShouldRun is true when there are workers
type UpgradeWorkers ¶
type UpgradeWorkers struct {
UpgradeHosts
WorkerConcurrent string
}
UpgradeWorkers phase state
func (*UpgradeWorkers) Explanation ¶
func (p *UpgradeWorkers) Explanation() string
Explanation about the current phase, used for documentation generation
type UploadFiles ¶
type UploadFiles struct {
GenericPhase
// contains filtered or unexported fields
}
UploadFiles implements a phase which upload files to hosts
func (*UploadFiles) Explanation ¶
func (p *UploadFiles) Explanation() string
Explanation about the current phase, used for documentation generation
func (*UploadFiles) ShouldRun ¶
func (p *UploadFiles) ShouldRun() bool
ShouldRun is true when there are workers
type UploadFilesCommon ¶
type UploadFilesCommon struct {
GenericPhase
// contains filtered or unexported fields
}
UploadFilesCommon implements a phase which upload files to hosts
func (*UploadFilesCommon) CleanUp ¶
func (p *UploadFilesCommon) CleanUp(ctx context.Context)
CleanUp the phase
func (*UploadFilesCommon) Run ¶
func (p *UploadFilesCommon) Run(ctx context.Context) (err error)
Run the phase
func (*UploadFilesCommon) ShouldRun ¶
func (p *UploadFilesCommon) ShouldRun() bool
ShouldRun is true when there are workers
type ValidateHosts ¶
type ValidateHosts struct {
GenericPhase
// contains filtered or unexported fields
}
ValidateHosts performs remote OS detection
func (*ValidateHosts) Explanation ¶
func (p *ValidateHosts) Explanation() string
Explanation about the current phase, used for documentation generation
func (*ValidateHosts) ReadOnly ¶
func (p *ValidateHosts) ReadOnly() string
ReadOnly marks this phase safe under a dry run, and returns the reason for the phase docs.
Source Files
¶
- 00_generic_phase.go
- 00_host_changes.go
- 01_generic_phase_file.go
- 02_imagecompress.go
- 03_manifest.go
- 04_node_names.go
- 04_node_restart.go
- 05_manager.go
- 06_service_logs.go
- 07_connect.go
- 09_detect_os.go
- 10_gather_facts.go
- 11_validate_hosts.go
- 12_gather_facts_distro.go
- 13_detect_removed_hosts.go
- 20_prepare_host.go
- 21_prepare_selinux.go
- 22_prepare_fapolicyd.go
- 23_prepare_kernel_modules.go
- 24_prepare_selinux_policy.go
- 25_modify_hosts_file.go
- 26_configure_firewall.go
- 50_uploadfiles.go
- 51_package_pin.go
- 55_files_common.go
- 57_rpm_install.go
- 58_apt_install.go
- 59_bin_install.go
- 60_configure_engine.go
- 61_initialize_controller.go
- 62_initialize_worker.go
- 63_import_images.go
- 64_apply_manifests.go
- 65_upgrade_common.go
- 66_install_staged_files.go
- 66_upgrade_controller.go
- 67_upgrade_worker.go
- 70_engine_config_diff.go
- 70_engine_config_sync_common.go
- 71_engine_config_sync_controller.go
- 72_engine_config_sync_worker.go
- 80_kubeconfig.go
- 81_label_nodes.go
- 85_delete_common.go
- 86_delete_worker.go
- 87_delete_controller.go
- 88_uninstall_engine.go
- 89_reconfigure_survivors.go
- 89_remove_selinux_policy.go
- 91_lock.go
- 92_unlock.go
- 95_daemon_reload.go
- 99_disconnect.go