Version: v3.11.1-0...-4446e78 Latest Latest

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

Go to latest
Published: Feb 4, 2019 License: Apache-2.0 Imports: 38 Imported by: 0




View Source
const (
	// CurrentMachineConfigAnnotationKey is used to fetch current MachineConfig for a machine
	CurrentMachineConfigAnnotationKey = "machineconfiguration.openshift.io/currentConfig"
	// DesiredMachineConfigAnnotationKey is used to specify the desired MachineConfig for a machine
	DesiredMachineConfigAnnotationKey = "machineconfiguration.openshift.io/desiredConfig"
	// MachineConfigDaemonStateAnnotationKey is used to fetch the state of the daemon on the machine.
	MachineConfigDaemonStateAnnotationKey = "machineconfiguration.openshift.io/state"
	// MachineConfigDaemonStateWorking is set by daemon when it is applying an update.
	MachineConfigDaemonStateWorking = "Working"
	// MachineConfigDaemonStateDone is set by daemon when it is done applying an update.
	MachineConfigDaemonStateDone = "Done"
	// MachineConfigDaemonStateDegraded is set by daemon when update cannot be applied.
	MachineConfigDaemonStateDegraded = "Degraded"

	// MachineConfigDaemonOSRHCOS denotes RHCOS
	MachineConfigDaemonOSRHCOS = "RHCOS"
	// MachineConfigDaemonOSRHEL denotes RHEL
	MachineConfigDaemonOSRHEL = "RHEL"
	// MachineConfigDaemonOSCENTOS denotes CENTOS
	MachineConfigDaemonOSCENTOS = "CENTOS"

	// MachineConfigMCFileType denotes when an MC config has been provided
	MachineConfigMCFileType = "MACHINECONFIG"
	// MachineConfigIgnitionFileType denotes when an Ignition config has provided
	MachineConfigIgnitionFileType = "IGNITION"

	// MachineConfigOnceFromRemoteConfig denotes that the config was pulled from a remote source
	MachineConfigOnceFromRemoteConfig = "REMOTE"
	// MachineConfigOnceFromLocalConfig denotes that the config was found locally
	MachineConfigOnceFromLocalConfig = "LOCAL"

	// MachineConfigSSHAccessAnnotationKey is used to mark a node after it has been accessed via SSH
	MachineConfigDaemonSSHAccessAnnotationKey = "machineconfiguration.openshift.io/ssh"
	// MachineConfigDaemonSSHAccessValue is the annotation value applied when ssh access is detected
	MachineConfigDaemonSSHAccessValue = "accessed"
View Source
const (
	// DefaultDirectoryPermissions houses the default mode to use when no directory permissions are provided
	DefaultDirectoryPermissions os.FileMode = 0755
	// DefaultFilePermissions houses the default mode to use when no file permissions are provided
	DefaultFilePermissions os.FileMode = 0644
View Source
const (
	// InitialNodeAnnotationsFilePath defines the path at which it will find the node annotations it needs to set on the node once it comes up for the first time.
	// The Machine Config Server writes the node annotations to this path.
	InitialNodeAnnotationsFilePath = "/etc/machine-config-daemon/node-annotations.json"


This section is empty.


func GetHostRunningOS

func GetHostRunningOS(rootFs string) (string, error)

GetHostRunningOS reads os-release from the rootFs prefix to return what OS variant the daemon is running on. If we are unable to read the os-release file OR the information doesn't match MCD supported OS's an error is returned.

func Run

func Run(command string, args ...string) error

Run executes a command, logging it.

func RunGetOut

func RunGetOut(command string, args ...string) ([]byte, error)

RunGetOut executes a command, logging it, and return the stdout output.

func ValidPath

func ValidPath(path string) bool

ValidPath attempts to see if the path provided is indeed an acceptable filesystem path. This function does not check if the path exists.


type Daemon

type Daemon struct {

	// OperatingSystem the operating system the MCD is running on
	OperatingSystem string

	// NodeUpdaterClient an instance of the client which interfaces with host content deployments
	NodeUpdaterClient NodeUpdaterClient
	// contains filtered or unexported fields

Daemon is the dispatch point for the functions of the agent on the machine. it keeps track of connections and the current state of the update process.

func New

func New(
	rootMount string,
	nodeName string,
	operatingSystem string,
	nodeUpdaterClient NodeUpdaterClient,
	fileSystemClient FileSystemClient,
	onceFrom string,
	kubeletHealthzEnabled bool,
	kubeletHealthzEndpoint string,
	nodeWriter *NodeWriter,
	exitCh chan<- error,
) (*Daemon, error)

New sets up the systemd and kubernetes connections needed to update the machine.

func NewClusterDrivenDaemon

func NewClusterDrivenDaemon(
	rootMount string,
	nodeName string,
	operatingSystem string,
	nodeUpdaterClient NodeUpdaterClient,
	client mcfgclientset.Interface,
	kubeClient kubernetes.Interface,
	fileSystemClient FileSystemClient,
	onceFrom string,
	nodeInformer coreinformersv1.NodeInformer,
	kubeletHealthzEnabled bool,
	kubeletHealthzEndpoint string,
	nodeWriter *NodeWriter,
	exitCh chan<- error,
) (*Daemon, error)

NewClusterDrivenDaemon sets up the systemd and kubernetes connections needed to update the machine.

func (*Daemon) CheckStateOnBoot

func (dn *Daemon) CheckStateOnBoot() error

CheckStateOnBoot is a core entrypoint for our state machine. It determines whether we're in our desired state, or if we're transitioning between states, and whether or not we need to update to a new state.

Some more background in this PR: https://github.com/openshift/machine-config-operator/pull/245

func (*Daemon) Close

func (dn *Daemon) Close()

Close closes all the connections the node agent has open for it's lifetime

func (*Daemon) EnterDegradedState

func (dn *Daemon) EnterDegradedState(err error)

EnterDegradedState causes the MCD to update the annotations to note that we're degraded, and sleep forever.

func (*Daemon) Run

func (dn *Daemon) Run(stopCh <-chan struct{}, exitCh <-chan error) error

Run finishes informer setup and then blocks, and the informer will be responsible for triggering callbacks to handle updates. Successful updates shouldn't return, and should just reboot the node.

func (*Daemon) SenseAndLoadOnceFrom

func (dn *Daemon) SenseAndLoadOnceFrom() (interface{}, string, string, error)

SenseAndLoadOnceFrom gets a hold of the content for supported onceFrom configurations, parses to verify the type, and returns back the genericInterface, the type description, if it was local or remote, and error.

type FileSystemClient

type FileSystemClient interface {
	Create(string) (*os.File, error)
	Remove(string) error
	RemoveAll(string) error
	MkdirAll(string, os.FileMode) error
	Stat(string) (os.FileInfo, error)
	Symlink(string, string) error
	Chmod(string, os.FileMode) error
	Chown(string, int, int) error
	WriteFile(filename string, data []byte, perm os.FileMode) error
	ReadAll(reader io.Reader) ([]byte, error)
	ReadFile(filename string) ([]byte, error)

FileSystemClient abstracts file/directory manipulation operations

func NewFileSystemClient

func NewFileSystemClient() FileSystemClient

NewFileSystemClient creates a new file system client using the default implementations provided by the os package.

type FsClient

type FsClient struct{}

FsClient is used to hang the FileSystemClient functions on.

func (FsClient) Chmod

func (f FsClient) Chmod(name string, mode os.FileMode) error

Chmod implements os.Chmod

func (FsClient) Chown

func (f FsClient) Chown(name string, uid, gid int) error

Chown implements os.Chown

func (FsClient) Create

func (f FsClient) Create(name string) (*os.File, error)

Create implements os.Create

func (FsClient) MkdirAll

func (f FsClient) MkdirAll(name string, perm os.FileMode) error

MkdirAll implements os.MkdirAll

func (FsClient) ReadAll

func (f FsClient) ReadAll(reader io.Reader) ([]byte, error)

ReadAll implements ioutil.ReadAll

func (FsClient) ReadFile

func (f FsClient) ReadFile(filename string) ([]byte, error)

ReadFile implements ioutil.WriteFile

func (FsClient) Remove

func (f FsClient) Remove(name string) error

Remove implements os.Remove

func (FsClient) RemoveAll

func (f FsClient) RemoveAll(path string) error

RemoveAll implements os.RemoveAll

func (FsClient) Stat

func (f FsClient) Stat(name string) (os.FileInfo, error)

Stat implements os.Stat

func (f FsClient) Symlink(oldname, newname string) error

Symlink implements os.Symlink

func (FsClient) WriteFile

func (f FsClient) WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile implements ioutil.WriteFile

type NodeUpdaterClient

type NodeUpdaterClient interface {
	GetBootedOSImageURL(string) (string, string, error)
	RunPivot(string) error

NodeUpdaterClient is an interface describing how to interact with the host around content deployment

func NewNodeUpdaterClient

func NewNodeUpdaterClient() NodeUpdaterClient

NewNodeUpdaterClient returns a new instance of the default DeploymentClient (RpmOstreeClient)

type NodeWriter

type NodeWriter struct {
	// contains filtered or unexported fields

NodeWriter A single writer to Kubernetes to prevent race conditions

func NewNodeWriter

func NewNodeWriter() *NodeWriter

NewNodeWriter Create a new NodeWriter

func (*NodeWriter) Run

func (nw *NodeWriter) Run(stop <-chan struct{})

Run reads from the writer channel and sets the node annotation. It will return if the stop channel is closed. Intended to be run via a goroutine.

func (*NodeWriter) SetSSHAccessed

func (nw *NodeWriter) SetSSHAccessed(client corev1.NodeInterface, node string) error

SetSSHAccessed sets the ssh annotation to accessed

func (*NodeWriter) SetUpdateDegraded

func (nw *NodeWriter) SetUpdateDegraded(err error, client corev1.NodeInterface, node string) error

SetUpdateDegraded logs the error and sets the state to UpdateDegraded. Returns an error if it couldn't set the annotation.

func (*NodeWriter) SetUpdateDegradedIgnoreErr

func (nw *NodeWriter) SetUpdateDegradedIgnoreErr(err error, client corev1.NodeInterface, node string) error

SetUpdateDegradedIgnoreErr logs the error and sets the state to UpdateDegraded. Logs an error if if couldn't set the annotation. Always returns the same error that it was passed. This is useful in situations where one just wants to return an error to its caller after having set the node to degraded due to that error.

func (*NodeWriter) SetUpdateDegradedMsgIgnoreErr

func (nw *NodeWriter) SetUpdateDegradedMsgIgnoreErr(msg string, client corev1.NodeInterface, node string) error

SetUpdateDegradedMsgIgnoreErr is like SetUpdateDegradedMsgIgnoreErr but takes a string and constructs the error object itself.

func (*NodeWriter) SetUpdateDone

func (nw *NodeWriter) SetUpdateDone(client corev1.NodeInterface, node string, dcAnnotation string) error

SetUpdateDone Sets the state to UpdateDone.

func (*NodeWriter) SetUpdateWorking

func (nw *NodeWriter) SetUpdateWorking(client corev1.NodeInterface, node string) error

SetUpdateWorking Sets the state to UpdateWorking.

type RpmOstreeClient

type RpmOstreeClient struct{}

RpmOstreeClient provides all RpmOstree related methods in one structure. This structure implements DeploymentClient

func (*RpmOstreeClient) GetBootedOSImageURL

func (r *RpmOstreeClient) GetBootedOSImageURL(rootMount string) (string, string, error)

GetBootedOSImageURL returns the image URL as well as the OSTree version (for logging)

func (*RpmOstreeClient) RunPivot

func (r *RpmOstreeClient) RunPivot(osImageURL string) error

RunPivot executes a pivot from one deployment to another as found in the referenced osImageURL. See https://github.com/openshift/pivot.

type RpmOstreeDeployment

type RpmOstreeDeployment struct {
	ID           string   `json:"id"`
	OSName       string   `json:"osname"`
	Serial       int32    `json:"serial"`
	Checksum     string   `json:"checksum"`
	Version      string   `json:"version"`
	Timestamp    uint64   `json:"timestamp"`
	Booted       bool     `json:"booted"`
	Origin       string   `json:"origin"`
	CustomOrigin []string `json:"custom-origin"`

RpmOstreeDeployment represents a single deployment on a node

type RpmOstreeState

type RpmOstreeState struct {
	Deployments []RpmOstreeDeployment

RpmOstreeState houses zero or more RpmOstreeDeployments Subset of `rpm-ostree status --json` https://github.com/projectatomic/rpm-ostree/blob/bce966a9812df141d38e3290f845171ec745aa4e/src/daemon/rpmostreed-deployment-utils.c#L227

Jump to

Keyboard shortcuts

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