utils

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 40 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultReleaseName constant
	DefaultReleaseName = "<DriverDefaultReleaseName>"
	// DefaultReleaseNamespace constant
	DefaultReleaseNamespace = "<DriverDefaultReleaseNamespace>"
	// DefaultImagePullPolicy constant
	DefaultImagePullPolicy = "IfNotPresent"
	// KubeletConfigDir path
	KubeletConfigDir = "<KUBELET_CONFIG_DIR>"
	// ReplicationControllerNameSpace -
	ReplicationControllerNameSpace = "dell-replication-controller"
	// ReplicationControllerManager -
	ReplicationControllerManager = "dell-replication-controller-manager"
	// ReplicationControllerInit -
	ReplicationControllerInit = "dell-replication-controller-init"
	// ReplicationSideCarName -
	ReplicationSideCarName = "dell-csi-replicator"
	// ResiliencySideCarName -
	ResiliencySideCarName = "podmon"
	// DefaultSourceClusterID -
	DefaultSourceClusterID = "default-source-cluster"
	// ObservabilityNamespace - karavi
	ObservabilityNamespace = "karavi"
	// AuthorizationNamespace - authorization
	AuthorizationNamespace = "authorization"
	// PodmonControllerComponent - podmon-controller
	PodmonControllerComponent = "podmon-controller"
	// PodmonNodeComponent - podmon-node
	PodmonNodeComponent = "podmon-node"
	// ApplicationMobilityNamespace - application-mobility
	ApplicationMobilityNamespace = "application-mobility"
	// ExistingNamespace - existing namespace
	ExistingNamespace = "<ExistingNameSpace>"
	// ClientNamespace - client namespace
	ClientNamespace = "<ClientNameSpace>"
	// BrownfieldManifest - brownfield-onboard.yaml
	BrownfieldManifest = "brownfield-onboard.yaml"
	// DefaultKubeletConfigDir - default kubelet config directory
	DefaultKubeletConfigDir = "/var/lib/kubelet"
)

Variables

View Source
var NewControllerRuntimeClientWrapper = func(clusterConfigData []byte) (crclient.Client, error) {
	return k8sClient.NewControllerRuntimeClient(clusterConfigData)
}

NewControllerRuntimeClientWrapper -

View Source
var NewK8sClientWrapper = func(clusterConfigData []byte) (*kubernetes.Clientset, error) {
	restConfig, err := clientcmd.RESTConfigFromKubeConfig(clusterConfigData)
	if err != nil {
		return nil, err
	}

	return kubernetes.NewForConfig(restConfig)
}

NewK8sClientWrapper -

Functions

func AddModuleComponent added in v1.7.0

func AddModuleComponent(instance *csmv1.ContainerStorageModule, mod csmv1.ModuleType, component csmv1.ContainerTemplate)

AddModuleComponent - add a module component in the cr

func ApplyCTRLObject added in v1.0.0

func ApplyCTRLObject(ctx context.Context, obj crclient.Object, ctrlClient crclient.Client) error

ApplyCTRLObject - TODO: Refactor to make use of ApplyObject. There's no need for so much repeated code.

func ApplyObject added in v0.2.0

func ApplyObject(ctx context.Context, obj crclient.Object, ctrlClient crclient.Client) error

ApplyObject -

func Contains added in v1.0.0

func Contains(slice []string, str string) bool

Contains - check if slice contains the specified string

func DeleteObject added in v0.2.0

func DeleteObject(ctx context.Context, obj crclient.Object, ctrlClient crclient.Client) error

DeleteObject -

func DetermineUnitTestRun added in v1.4.3

func DetermineUnitTestRun(ctx context.Context) bool

DetermineUnitTestRun will determine if this reconcile call is part of unit test run

func GetBackupStorageLocation added in v1.4.0

func GetBackupStorageLocation(ctx context.Context, name, namespace string, ctrlClient crclient.Client) (*velerov1.BackupStorageLocation, error)

GetBackupStorageLocation - check if the Backup Storage Location is present

func GetCSMNamespaces added in v1.8.0

func GetCSMNamespaces(ctx context.Context, ctrlClient crclient.Client) ([]string, error)

GetCSMNamespaces returns the list of namespaces in the cluster that currently contain a CSM object

func GetCTRLObject added in v0.2.0

func GetCTRLObject(CtrlBuf []byte) ([]crclient.Object, error)

GetCTRLObject - get controller object

func GetDriverYaml

func GetDriverYaml(YamlString, kind string) (interface{}, error)

GetDriverYaml -

func GetModuleComponentObj added in v1.0.0

func GetModuleComponentObj(CtrlBuf []byte) ([]crclient.Object, error)

GetModuleComponentObj - get module component object from config yaml string

func GetModuleDefaultVersion

func GetModuleDefaultVersion(driverConfigVersion string, driverType csmv1.DriverType, moduleType csmv1.ModuleType, path string) (string, error)

GetModuleDefaultVersion -

func GetSecret added in v1.0.0

func GetSecret(ctx context.Context, name, namespace string, ctrlClient crclient.Client) (*corev1.Secret, error)

GetSecret - check if the secret is present

func GetVolumeSnapshotLocation added in v1.4.0

func GetVolumeSnapshotLocation(ctx context.Context, name, namespace string, ctrlClient crclient.Client) (*velerov1.VolumeSnapshotLocation, error)

GetVolumeSnapshotLocation - check if the Volume Snapshot Location is present

func HandleSuccess

func HandleSuccess(ctx context.Context, instance *csmv1.ContainerStorageModule, r ReconcileCSM, newStatus, oldStatus *csmv1.ContainerStorageModuleStatus) reconcile.Result

HandleSuccess for csm

func HandleValidationError

func HandleValidationError(ctx context.Context, instance *csmv1.ContainerStorageModule, r ReconcileCSM,
	validationError error,
) (reconcile.Result, error)

HandleValidationError for csm

func HasModuleComponent added in v1.7.0

func HasModuleComponent(instance csmv1.ContainerStorageModule, mod csmv1.ModuleType, componentType string) bool

HasModuleComponent - check if module component is present

func IsAppMobilityComponentEnabled added in v1.4.0

func IsAppMobilityComponentEnabled(ctx context.Context, instance csmv1.ContainerStorageModule, _ ReconcileCSM, mod csmv1.ModuleType, componentType string) bool

IsAppMobilityComponentEnabled - check if Application Mobility componenets are enabled

func IsModuleComponentEnabled added in v1.3.0

func IsModuleComponentEnabled(ctx context.Context, instance csmv1.ContainerStorageModule, mod csmv1.ModuleType, componentType string) bool

IsModuleComponentEnabled - check if module components are enabled

func IsModuleEnabled added in v1.0.0

func IsModuleEnabled(_ context.Context, instance csmv1.ContainerStorageModule, mod csmv1.ModuleType) (bool, csmv1.Module)

IsModuleEnabled - check if the module is enabled

func IsResiliencyModuleEnabled added in v1.2.0

func IsResiliencyModuleEnabled(_ context.Context, instance csmv1.ContainerStorageModule, _ ReconcileCSM) bool

IsResiliencyModuleEnabled - check if resiliency module is enabled or not

func IsValidUpgrade added in v1.6.0

func IsValidUpgrade[T CSMComponentType](ctx context.Context, oldVersion, newVersion string, csmComponentType T, operatorConfig OperatorConfig) (bool, error)

IsValidUpgrade will check if upgrade of module/driver is allowed

func LoadDefaultComponents added in v1.7.0

func LoadDefaultComponents(ctx context.Context, cr *csmv1.ContainerStorageModule, op OperatorConfig) error

LoadDefaultComponents loads the default module components into cr

func LogEndReconcile added in v1.8.0

func LogEndReconcile()

LogEndReconcile - Print the 'ending reconcile' message

func MinVersionCheck added in v0.2.0

func MinVersionCheck(minVersion string, version string) (bool, error)

MinVersionCheck takes a driver name and a version of the form "vA.B.C" and checks it against the minimum version for the specified driver

func ModifyCommonCR

func ModifyCommonCR(YamlString string, cr csmv1.ContainerStorageModule) string

ModifyCommonCR -

func ReplaceAllApplyCustomEnvs

func ReplaceAllApplyCustomEnvs(driverEnv []acorev1.EnvVarApplyConfiguration,
	commonEnv []corev1.EnvVar,
	nrEnv []corev1.EnvVar,
) []acorev1.EnvVarApplyConfiguration

ReplaceAllApplyCustomEnvs - TODO: It seems like this function only acts on envs that are shared between the new and the old, with any that aren't on the new being left alone (instead of deleted) and any that aren't on the old being ignored (instead of added). Unknown if this is intentional.

func ReplaceAllArgs

func ReplaceAllArgs(defaultArgs, crArgs []string) []string

ReplaceAllArgs -

func ReplaceAllContainerImageApply

func ReplaceAllContainerImageApply(img K8sImagesConfig, c *acorev1.ContainerApplyConfiguration)

ReplaceAllContainerImageApply -

func SetContainerImage added in v1.7.0

func SetContainerImage(objects []crclient.Object, deploymentName, containerName, image string)

SetContainerImage loops through objects to find deployment and set the image for container

func SetStatus

SetStatus of csm

func SplitYaml

func SplitYaml(gaintYAML []byte) ([][]byte, error)

SplitYaml divides a big bytes of yaml files in individual yaml files.

func UpdateContainerApply added in v1.8.0

func UpdateContainerApply(toBeApplied []csmv1.ContainerTemplate, c *acorev1.ContainerApplyConfiguration)

TODO: It seems like this function only acts on envs that are shared between the new and the old, with any that aren't on the new being left alone (instead of deleted) and any that aren't on the old being ignored (instead of added). Unknown if this is intentional.

func UpdateInitContainerApply added in v1.8.0

func UpdateInitContainerApply(initContainers []csmv1.ContainerTemplate, c *acorev1.ContainerApplyConfiguration)

UpdateInitContainerApply -

func UpdateSideCarApply

func UpdateSideCarApply(sideCars []csmv1.ContainerTemplate, c *acorev1.ContainerApplyConfiguration)

UpdateSideCarApply -

func UpdateStatus

UpdateStatus of csm

func WaitForNginxController added in v1.0.0

func WaitForNginxController(ctx context.Context, instance csmv1.ContainerStorageModule, r ReconcileCSM, timeout time.Duration) error

WaitForNginxController - polls deployment status

Types

type CSMComponentType added in v1.6.0

type CSMComponentType interface {
	csmv1.ModuleType | csmv1.DriverType
}

CSMComponentType - type constraint for DriverType and ModuleType

type ControllerYAML

type ControllerYAML struct {
	Deployment confv1.DeploymentApplyConfiguration
	Rbac       RbacYAML
}

ControllerYAML -

type FakeReconcileCSM added in v0.2.0

type FakeReconcileCSM struct {
	reconcile.Reconciler
	crclient.Client
	K8sClient kubernetes.Interface
	// contains filtered or unexported fields
}

FakeReconcileCSM -

func (*FakeReconcileCSM) GetClient added in v0.2.0

func (r *FakeReconcileCSM) GetClient() crclient.Client

GetClient -

func (*FakeReconcileCSM) GetK8sClient added in v0.2.0

func (r *FakeReconcileCSM) GetK8sClient() kubernetes.Interface

GetK8sClient - Returns the current update count

func (*FakeReconcileCSM) GetUpdateCount added in v0.2.0

func (r *FakeReconcileCSM) GetUpdateCount() int32

GetUpdateCount - Returns the current update count

func (*FakeReconcileCSM) IncrUpdateCount added in v0.2.0

func (r *FakeReconcileCSM) IncrUpdateCount()

IncrUpdateCount - Increments the update count

type K8sImagesConfig

type K8sImagesConfig struct {
	K8sVersion string `json:"kubeversion" yaml:"kubeversion"`
	Images     struct {
		Attacher              string `json:"attacher" yaml:"attacher"`
		Provisioner           string `json:"provisioner" yaml:"provisioner"`
		Snapshotter           string `json:"snapshotter" yaml:"snapshotter"`
		Registrar             string `json:"registrar" yaml:"registrar"`
		Resizer               string `json:"resizer" yaml:"resizer"`
		Externalhealthmonitor string `json:"externalhealthmonitorcontroller" yaml:"externalhealthmonitorcontroller"`
		Sdc                   string `json:"sdc" yaml:"sdc"`
		Sdcmonitor            string `json:"sdcmonitor" yaml:"sdcmonitor"`
		Podmon                string `json:"podmon" yaml:"podmon"`
		CSIRevProxy           string `json:"csiReverseProxy" yaml:"csiReverseProxy"`
	} `json:"images" yaml:"images"`
}

K8sImagesConfig -

type LatestVersion added in v1.7.0

type LatestVersion struct {
	Version string `yaml:"version"`
}

LatestVersion - used in minimal manifests for CSM

type MockClient added in v1.8.0

type MockClient struct {
	crclient.Client
	GetFunc    func(ctx context.Context, key crclient.ObjectKey, obj crclient.Object, opts ...crclient.GetOption) error
	CreateFunc func(ctx context.Context, obj crclient.Object, opts ...crclient.CreateOption) error
	UpdateFunc func(ctx context.Context, obj crclient.Object, opts ...crclient.UpdateOption) error
}

MockClient is a mock implementation of the client.Client interface for testing purposes.

func (*MockClient) Create added in v1.8.0

func (m *MockClient) Create(ctx context.Context, obj crclient.Object, opts ...crclient.CreateOption) error

func (*MockClient) Get added in v1.8.0

func (*MockClient) Update added in v1.8.0

func (m *MockClient) Update(ctx context.Context, obj crclient.Object, opts ...crclient.UpdateOption) error

type NodeYAML

type NodeYAML struct {
	DaemonSetApplyConfig confv1.DaemonSetApplyConfiguration
	Rbac                 RbacYAML
}

NodeYAML -

type OperatorConfig

type OperatorConfig struct {
	IsOpenShift     bool
	K8sVersion      K8sImagesConfig
	ConfigDirectory string
}

OperatorConfig -

type RbacYAML

type RbacYAML struct {
	ServiceAccount     corev1.ServiceAccount
	ClusterRole        rbacv1.ClusterRole
	ClusterRoleBinding rbacv1.ClusterRoleBinding
}

RbacYAML -

type ReconcileCSM

type ReconcileCSM interface {
	reconcile.Reconciler
	GetClient() crclient.Client
	GetK8sClient() kubernetes.Interface
	GetUpdateCount() int32
	IncrUpdateCount()
}

ReconcileCSM is the interface which extends each of the respective Reconcile interfaces for drivers

type ReplicaCluster added in v0.2.0

type ReplicaCluster struct {
	ClusterID         string
	ClusterCTRLClient crclient.Client
	ClusterK8sClient  kubernetes.Interface
}

ReplicaCluster -

func GetDefaultClusters added in v0.2.0

func GetDefaultClusters(ctx context.Context, instance csmv1.ContainerStorageModule, r ReconcileCSM) (bool, []ReplicaCluster, error)

GetDefaultClusters -

type StatefulControllerYAML added in v1.6.0

type StatefulControllerYAML struct {
	StatefulSet confv1.StatefulSetApplyConfiguration
	Rbac        RbacYAML
}

StatefulControllerYAML -

type UpgradePaths added in v0.2.0

type UpgradePaths struct {
	MinUpgradePath string `json:"minUpgradePath" yaml:"minUpgradePath"`
}

UpgradePaths a list of versions eligible to upgrade the current version

Jump to

Keyboard shortcuts

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