lcmcommon

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// app names for disk-daemon and toolbox
	PelagiaToolBox    = "pelagia-ceph-toolbox"
	PelagiaDiskDaemon = "pelagia-disk-daemon"
	// csi plugin names
	CephCSIRBDPluginDaemonSetName    = "csi-rbdplugin"
	CephCSICephFSPluginDaemonSetName = "csi-cephfsplugin"
	// rook related vars
	RookCephOperatorName      = "rook-ceph-operator"
	RookDiscoverName          = "rook-discover"
	RookCephMonSecretName     = "rook-ceph-mon"
	RookOperatorConfigMapName = "rook-ceph-operator-config"
	MonMapConfigMapName       = "rook-ceph-mon-endpoints"
	// default data dir host path if not specified in spec
	DefaultDataDirHostPath = "/var/lib/rook"
	// lcm related vars
	RunCephCommandTimeout = 10
	// marker for stray osds
	StrayOsdNodeMarker = "__stray"
	// marker to detect lvm created by rook, since rook always create vg/lv with
	// prefix 'osd-' any manual lvm should not start with that prefix
	RookLVMarker = "osd-"
	//DeploymentRestartAnnotation indicates timestamp when deployment restart was requested
	DeploymentRestartAnnotation = "cephdeployment.lcm.mirantis.com/restartedAt"
)
View Source
const (
	// CephCSIRBDNodeClientName is the name of CSI RBD node client
	CephCSIRBDNodeClientName = "csi-rbd-node"
	// CephCSIRBDProvisionerClientName is the name of CSI RBD provisioner client
	CephCSIRBDProvisionerClientName = "csi-rbd-provisioner"
	// CephCSICephFSNodeClientName is the name of CSI CephFS node client
	CephCSICephFSNodeClientName = "csi-cephfs-node"
	// CephCSICephFSProvisionerClientName is the name of CSI CephFS provisioner client
	CephCSICephFSProvisionerClientName = "csi-cephfs-provisioner"
)
View Source
const LoggerObjectField = "object"

Variables

View Source
var (
	// pure pod command run with exec config
	RunPodCommand = runPodCommand
	// validate exec config and run pod command
	RunPodCommandWithValidation = runPodCommandWithValidation
)
View Source
var (
	Squid = &CephVersion{
		Name:            "Squid",
		MajorVersion:    "v19.2",
		Order:           19,
		SupportedMinors: []string{"3"},
	}
	Reef = &CephVersion{
		Name:            "Reef",
		MajorVersion:    "v18.2",
		Order:           18,
		SupportedMinors: []string{"3", "4", "7"},
	}
	LatestRelease = Squid
)
View Source
var AvailableCephVersions = []*CephVersion{Squid, Reef}
View Source
var GenerateSelfSignedCert = generateSelfSignedCert
View Source
var GetCurrentTimeString = getCurrentTimeString
View Source
var GetCurrentUnixTimeString = getCurrentUnixTimeString
View Source
var LookupEnv = os.LookupEnv

Functions

func CephVersionGreaterOrEqual

func CephVersionGreaterOrEqual(currentVersion, requiredVersion *CephVersion) bool

func Contains

func Contains(list []string, s string) bool

func FindDiskName

func FindDiskName(name string, diskReport *DiskDaemonDisksReport) (string, error)

func GetCephVersionFromImage

func GetCephVersionFromImage(cephImage string) string

func GetNode

func GetNode(ctx context.Context, kubeClient kubernetes.Interface, nodename string) (*corev1.Node, error)

func GetNodeList

func GetNodeList(ctx context.Context, kubeClient kubernetes.Interface, listOptions metav1.ListOptions) (*corev1.NodeList, error)

func GetObjectOwnerRef

func GetObjectOwnerRef(obj runtime.Object, scheme *runtime.Scheme) ([]metav1.OwnerReference, error)

func GetStringSha256

func GetStringSha256(s string) string

func InitLogger

func InitLogger(objectField bool) zerolog.Logger

func IsCephToolboxCLIAvailable

func IsCephToolboxCLIAvailable(ctx context.Context, kubeClient kubernetes.Interface, namespace string) bool

func IsClusterMaintenanceActing

func IsClusterMaintenanceActing(ctx context.Context, cephLcmclientset lcmclient.Interface, namespace, name string) (bool, error)

func IsDaemonSetReady

func IsDaemonSetReady(ds *appsv1.DaemonSet) bool

func IsDeploymentReady

func IsDeploymentReady(deploy *appsv1.Deployment) bool

func IsNodeAvailable

func IsNodeAvailable(node corev1.Node) (bool, string)

func IsNodeWithDiskDaemon

func IsNodeWithDiskDaemon(node corev1.Node, lcmDiskDaemonLabel string) bool

func IsOpenStackPoolsPresent

func IsOpenStackPoolsPresent(pools []cephlcmv1alpha1.CephPool) bool

func LookupEnvVar

func LookupEnvVar(varName string) (string, error)

func PathDevPrepended

func PathDevPrepended(name string) string

func RestartDeployment

func RestartDeployment(ctx context.Context, log zerolog.Logger, kubeclientset kubernetes.Interface, deploymentName, namespace string) error

func RunAndParseCephToolboxCLI

func RunAndParseCephToolboxCLI(ctx context.Context, kubeClient kubernetes.Interface, config *rest.Config, namespace, command string, data any) error

func RunAndParseDiskDaemonCLI

func RunAndParseDiskDaemonCLI(ctx context.Context, kubeClient kubernetes.Interface, config *rest.Config, namespace, nodeName, command string, data any) error

func RunCephToolboxCLI

func RunCephToolboxCLI(ctx context.Context, kubeClient kubernetes.Interface, config *rest.Config, namespace, command string) (string, error)

func RunFuncWithRetry

func RunFuncWithRetry(times int, interval time.Duration, funcToRun func() (interface{}, error)) (interface{}, error)

func RunPodCmdAndCheckError

func RunPodCmdAndCheckError(e ExecConfig) (string, string, error)

func ScaleDeployment

func ScaleDeployment(ctx context.Context, kubeClient kubernetes.Interface, deployName, namespace string, replicas int32) error

func ShowObjectDiff

func ShowObjectDiff(l zerolog.Logger, oldObject, newObject interface{})

func SortedMapKeys

func SortedMapKeys(m map[string]string) []string

func VerifyCertificateExpireDate

func VerifyCertificateExpireDate(cacert []byte) error

Types

type BlockDeviceInfo

type BlockDeviceInfo struct {
	// pkg kernel device name
	Kname string `json:"kname"`
	// device serial number
	Serial string `json:"serial,omitempty"`
	// device type: disk, part, lvm, raid
	Type string `json:"type"`
	// rotational device
	Rotational bool `json:"rota"`
	// major:minor device number
	MajMin string `json:"maj:min"`
	// aliases for block device by-{id,path,uuid}
	Symlinks []string `json:"symlinks"`
	// pkg parent kernel device name
	Parent []string `json:"parent,omitempty"`
	// childrens for device
	Childrens []string `json:"children,omitempty"`
}

type CSIKeyring

type CSIKeyring struct {
	NodeKey        string `json:"node_key"`
	ProvisionerKey string `json:"provisioner_key"`
}

type CephConnection

type CephConnection struct {
	ClientName    string `json:"client_name"`
	ClientKeyring string `json:"client_keyring"`
	FSID          string `json:"fsid"`
	MonEndpoints  string `json:"mon_endpoints_map"`
	// csi keyring info
	RBDKeyring    *CSIKeyring `json:"rbd_keyring_info,omitempty"`
	CephFSKeyring *CSIKeyring `json:"cephfs_keyring_info,omitempty"`
	// rgw admin ops user creds
	RgwAdminUserKeys *RgwUserKeys `json:"rgw_admin_keys,omitempty"`
}

type CephDetails

type CephDetails struct {
	StatsByClass map[string]ClassStats `json:"stats_by_class"`
	Pools        []PoolDetails         `json:"pools"`
}

type CephVersion

type CephVersion struct {
	// ceph release name
	Name string
	// ceph major version
	MajorVersion string
	// ceph minor version
	MinorVersion string
	// major version for simple compare with other versions
	Order int
	// minor versions supported and available to use
	SupportedMinors []string
}

func CheckExpectedCephVersion

func CheckExpectedCephVersion(expectedCephImage, expectedCephRelease string) (*CephVersion, error)

func ParseCephVersion

func ParseCephVersion(version string) (*CephVersion, error)

type ClassStats

type ClassStats struct {
	TotalBytes     uint64 `json:"total_bytes"`
	UsedBytes      uint64 `json:"total_used_bytes"`
	AvailableBytes uint64 `json:"total_avail_bytes"`
}

type DiskDaemonDisksReport

type DiskDaemonDisksReport struct {
	// parsed info from lsblk and udevadm cmds
	BlockInfo map[string]BlockDeviceInfo `json:"block_info"`
	// aliases map to block device name
	Aliases map[string]string `json:"aliases"`
	// Map for quick search disk -> osd on it
	DiskToOsd map[string][]string `json:"disk_to_osd_map,omitempty"`
}

type DiskDaemonOsdsReport

type DiskDaemonOsdsReport struct {
	// warnings faced during osd report prepare
	Warnings []string `json:"warnings,omitempty"`
	// regular osd devices info
	Osds map[string][]OsdDaemonInfo `json:"osds,omitempty"`
}

type DiskDaemonReport

type DiskDaemonReport struct {
	// current osd report state
	State DiskDaemonState `json:"state"`
	// current issues for node
	Issues []string `json:"issues,omitempty"`
	// current ready disk report
	DisksReport *DiskDaemonDisksReport `json:"disks_report,omitempty"`
	// current ready osd disk usage report
	OsdsReport *DiskDaemonOsdsReport `json:"osds_report,omitempty"`
}

type DiskDaemonState

type DiskDaemonState string
const (
	DiskDaemonStateOk         DiskDaemonState = "ok"
	DiskDaemonStateFailed     DiskDaemonState = "failed"
	DiskDaemonStateInProgress DiskDaemonState = "preparing"
	DiskDaemonStateSkipped    DiskDaemonState = "skipped"
)

type ExecConfig

type ExecConfig struct {
	Context       context.Context
	Kubeclient    kubernetes.Interface
	Config        *rest.Config
	Pod           *corev1.Pod
	Namespace     string
	Command       string
	Content       []byte
	ContainerName string
	Nodename      string
	Labels        []string
}

type MgrModuleLs

type MgrModuleLs struct {
	AlwaysOn []string `json:"always_on_modules"`
	Enabled  []string `json:"enabled_modules"`
}

type OsdDaemonInfo

type OsdDaemonInfo struct {
	OsdUUID     string         `json:"osd_uuid,omitempty"`
	ClusterFSID string         `json:"osd_fsid,omitempty"`
	Devices     []OsdDevice    `json:"osd_device,omitempty"`
	Partitions  []OsdPartition `json:"osd_partitions,omitempty"`
}

type OsdDevice

type OsdDevice struct {
	Name             string   `json:"name,omitempty"`
	DeviceID         string   `json:"device_id,omitempty"`
	DeviceSymlinks   []string `json:"device_pathes,omitempty"`
	Rotational       bool     `json:"rotational,omitempty"`
	RelatedPartition string   `json:"partition,omitempty"`
}

type OsdInfo

type OsdInfo struct {
	OsdID int    `json:"osd"`
	UUID  string `json:"uuid"`
	Up    int    `json:"up"`
	In    int    `json:"in"`
}

type OsdMetadataInfo

type OsdMetadataInfo struct {
	Devices             string `json:"devices"`
	DevicePathes        string `json:"device_paths"`
	DeviceIDs           string `json:"device_ids"`
	Hostname            string `json:"hostname"`
	BluestoreDevices    string `json:"bluestore_bdev_devices"`
	BluestoreDeviceType string `json:"bluestore_bdev_type"`
	BluestorePartition  string `json:"bluestore_bdev_partition_path"`
	MetadataDiskUsed    string `json:"bluefs_dedicated_db"`
	MetadataDevices     string `json:"bluefs_db_devices"`
	MetadataDeviceType  string `json:"bluefs_db_type"`
	MetadataPartition   string `json:"bluefs_db_partition_path"`
	OsdID               int    `json:"id"`
}

type OsdPartition

type OsdPartition struct {
	Partition         string   `json:"partition,omitempty"`
	PartitionSymlinks []string `json:"partition_symlinks,omitempty"`
	Type              string   `json:"type,omitempty"`
	Exists            bool     `json:"exists,omitempty"`
	Lvm               bool     `json:"lvm,omitempty"`
}

type OsdTree

type OsdTree struct {
	Nodes []struct {
		ID          int     `json:"id"`
		Name        string  `json:"name"`
		Type        string  `json:"type"`
		Children    []int   `json:"children,omitempty"`
		DeviceClass string  `json:"device_class"`
		Status      string  `json:"status"`
		Weight      float64 `json:"crush_weight"`
		Reweight    int     `json:"reweight"`
	} `json:"nodes"`
}

type PoolDetails

type PoolDetails struct {
	Name  string    `json:"name"`
	Stats PoolStats `json:"stats"`
}

type PoolStats

type PoolStats struct {
	TotalBytes  uint64  `json:"max_avail"`
	UsedBytes   uint64  `json:"bytes_used"`
	PercentUsed float64 `json:"percent_used"`
}

type RgwUserKeys

type RgwUserKeys struct {
	AccessKey string `json:"accessKey"`
	SecretKey string `json:"secretKey"`
}

type ZoneGroupInfo

type ZoneGroupInfo struct {
	Hostnames []string `json:"hostnames"`
}

Jump to

Keyboard shortcuts

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