common

package
v0.0.0-...-5a6eb71 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VarFolder       = "/var"
	BackupDir       = "/var/tmp/backup"
	BackupCertsDir  = "/var/tmp/backupCertsDir"
	BackupChecksDir = "/var/tmp/checks"

	// Workload partitioning annotation key and value
	WorkloadManagementAnnotationKey   = "target.workload.openshift.io/management"
	WorkloadManagementAnnotationValue = `{"effect": "PreferredDuringScheduling"}`

	// ImageRegistryAuthFile is the pull secret. Written by the machine-config-operator
	ImageRegistryAuthFile = "/var/lib/kubelet/config.json"
	KubeconfigFile        = "/etc/kubernetes/static-pod-resources/kube-apiserver-certs/secrets/node-kubeconfigs/lb-ext.kubeconfig"

	RecertImageEnvKey      = "RELATED_IMAGE_RECERT_IMAGE"
	DefaultRecertImage     = "quay.io/edge-infrastructure/recert:v0"
	EtcdStaticPodFile      = "/etc/kubernetes/manifests/etcd-pod.yaml"
	EtcdStaticPodContainer = "etcd"
	EtcdDefaultEndpoint    = "localhost:2379"

	OvnNodeCerts = "/var/lib/ovn-ic/etc/ovnkube-node-certs"
	MultusCerts  = "/etc/cni/multus/certs"

	InstallationConfigurationFilesDir = "/usr/local/installation_configuration_files"
	OptOpenshift                      = "/opt/openshift"
	SeedDataDir                       = "/var/seed_data"
	KubeconfigCryptoDir               = "kubeconfig-crypto"
	ClusterConfigDir                  = "cluster-configuration"
	SeedClusterInfoFileName           = "manifest.json"
	SeedReconfigurationFileName       = "manifest.json"
	ManifestsDir                      = "manifests"
	ExtraManifestsDir                 = "extra-manifests"
	EtcdContainerName                 = "recert_etcd"
	LvmConfigDir                      = "lvm-configuration"
	LvmDevicesPath                    = "/etc/lvm/devices/system.devices"
	CABundleFilePath                  = "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"

	LCAConfigDir                                    = "/var/lib/lca"
	IBUAutoRollbackConfigFile                       = LCAConfigDir + "/autorollback_config.json"
	IBUAutoRollbackInitMonitorTimeoutDefaultSeconds = 1800
	IBUInitMonitorService                           = "lca-init-monitor.service"
	IBUInitMonitorServiceFile                       = "/etc/systemd/system/" + IBUInitMonitorService
	// AutoRollbackOnFailurePostRebootConfigAnnotation configure automatic rollback when the reconfiguration of the cluster fails upon the first reboot.
	// Only acceptable value is AutoRollbackDisableValue. Any other value is treated as "Enabled".
	AutoRollbackOnFailurePostRebootConfigAnnotation = "auto-rollback-on-failure.lca.openshift.io/post-reboot-config"
	// AutoRollbackOnFailureUpgradeCompletionAnnotation configure automatic rollback after the Lifecycle Agent reports a failed upgrade upon completion.
	// Only acceptable value is AutoRollbackOnFailureDisableValue. Any other value is treated as "Enabled".
	AutoRollbackOnFailureUpgradeCompletionAnnotation = "auto-rollback-on-failure.lca.openshift.io/upgrade-completion"
	// AutoRollbackOnFailureInitMonitorAnnotation configure automatic rollback LCA Init Monitor watchdog, which triggers auto-rollback if timeout occurs before upgrade completion
	// Only acceptable value is AutoRollbackDisableValue. Any other value is treated as "Enabled".
	AutoRollbackOnFailureInitMonitorAnnotation = "auto-rollback-on-failure.lca.openshift.io/init-monitor"
	// AutoRollbackDisableValue value that decides if rollback is disabled
	AutoRollbackDisableValue = "Disabled"

	LcaNamespace = "openshift-lifecycle-agent"
	Host         = "/host"

	CsvDeploymentName      = "cluster-version-operator"
	CsvDeploymentNamespace = "openshift-cluster-version"
	// InstallConfigCM cm name
	InstallConfigCM = "cluster-config-v1"
	// InstallConfigCMNamespace cm namespace
	InstallConfigCMNamespace = "kube-system"
	// InstallConfigCMNamespace data key
	InstallConfigCMInstallConfigDataKey = "install-config"
	OpenshiftInfraCRName                = "cluster"
	OpenshiftProxyCRName                = "cluster"

	// Env var to configure auto rollback for post-reboot config failure
	IBUPostRebootConfigAutoRollbackOnFailureEnv = "LCA_IBU_AUTO_ROLLBACK_ON_CONFIG_FAILURE"

	// Bump this every time the seed format changes in a backwards incompatible way
	SeedFormatVersion  = 3
	SeedFormatOCILabel = "com.openshift.lifecycle-agent.seed_format_version"

	SeedClusterInfoOCILabel = "com.openshift.lifecycle-agent.seed_cluster_info"

	PullSecretName      = "pull-secret"
	PullSecretEmptyData = "" //nolint:gosec
	/* 138-byte string literal not displayed */
	OpenshiftConfigNamespace = "openshift-config"

	NMConnectionFolder = "/etc/NetworkManager/system-connections"
	NetworkDir         = "network-configuration"
	ApplyWaveAnn       = "lca.openshift.io/apply-wave"
)

Common constants mainly used by packages in lca-cli

Variables

View Source
var (
	BackupGvk  = schema.GroupVersionKind{Group: "velero.io", Kind: "Backup", Version: "v1"}
	RestoreGvk = schema.GroupVersionKind{Group: "velero.io", Kind: "Restore", Version: "v1"}
)
View Source
var CertPrefixes = []string{
	"loadbalancer-serving-signer",
	"localhost-serving-signer",
	"service-network-serving-signer",
}

CertPrefixes is the list of certificate prefixes to be backed up before creating the seed image

View Source
var OstreeDeployPathPrefix = ""

TODO: Need a better way to change this but will require relatively big refactoring

View Source
var RetryBackoffTwoMinutes = wait.Backoff{
	Steps:    120,
	Duration: time.Second,
	Factor:   1.0,
	Jitter:   0.1,
}

Functions

func CopyOutsideChroot

func CopyOutsideChroot(src, dest string) error

func ExtractResourcesFromConfigmaps

func ExtractResourcesFromConfigmaps[T metav1.Object](configmaps []corev1.ConfigMap, gvk schema.GroupVersionKind) ([]T, error)

func FuncTimer

func FuncTimer(start time.Time, name string, r logr.Logger)

FuncTimer check execution time

func GetConfigMap

func GetConfigMap(ctx context.Context, c client.Client, configMap v1alpha1.ConfigMapRef) (*corev1.ConfigMap, error)

GetConfigMap retrieves the configmap from cluster

func GetConfigMaps

func GetConfigMaps(ctx context.Context, c client.Client, configMaps []v1alpha1.ConfigMapRef) ([]corev1.ConfigMap, error)

GetConfigMaps retrieves a collection of configmaps from cluster

func GetDesiredStaterootName

func GetDesiredStaterootName(ibu *v1alpha1.ImageBasedUpgrade) string

func GetStaterootCertsDir

func GetStaterootCertsDir(ibu *v1alpha1.ImageBasedUpgrade) string

func GetStaterootName

func GetStaterootName(seedImageVersion string) string

func GetStaterootOptOpenshift

func GetStaterootOptOpenshift(staterootPath string) string

GetStaterootOptOpenshift returns the path to the `/opt/openshift` directory in a given stateroot. Note that since `/opt` in ostree systems is actually a symlink to `/var/opt`, and the `/var` directory of a stateroot is outside the stateroot deployment, we need to access it in this odd manner.

func GetStaterootPath

func GetStaterootPath(osname string) string

func IsRetriable

func IsRetriable(err error) bool

func PathInsideChroot

func PathInsideChroot(filename string) (string, error)

PathInsideChroot returns filepath removing host fs prefix

func PathOutsideChroot

func PathOutsideChroot(filename string) string

PathOutsideChroot returns filepath with host fs

func RemoveDuplicates

func RemoveDuplicates[T comparable](list []T) []T

func RetryOnConflictOrRetriable

func RetryOnConflictOrRetriable(backoff wait.Backoff, fn func() error) error

func RetryOnRetriable

func RetryOnRetriable(backoff wait.Backoff, fn func() error) error

func SortAndGroupByApplyWave

func SortAndGroupByApplyWave[T metav1.Object](objs []T) ([][]T, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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