util

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// SuccessfulLaunchBlockCSIReason is added in an event when Block CSI is successfully launched.
	SuccessfulLaunchBlockCSIReason      = "SuccessfulLaunchBlockCSI"
	FailedLaunchBlockCSIReason          = "FailedLaunchBlockCSI"
	SuccessfulDetectBlockCSIReason      = "SuccessfulDetectBlockCSI"
	FailedLaunchBlockExporterReason     = "FailedLaunchBlockExporter"
	FailedEnsureSecretOwnershipReason   = "FailedEnsureSecretOwnership"
	FailedCreateServiceReason           = "FailedCreateService"
	FailedScPoolConfigMapReason         = "FailedEnsureScPoolConfigMap"
	FailedCreateServiceMonitorReason    = "FailedCreateServiceMonitor"
	FailedCreateStorageClassReason      = "FailedCreateStorageClass"
	DeletedDuplicatedStorageClassReason = "DeletedDuplicatedStorageClass"
	FailedCreatePromRuleReason          = "FailedCreatePromRule"
)

Reasons for ibm storage odf events

View Source
const (
	PoolConfigmapName     = "ibm-flashsystem-pools"
	PoolsKey              = "pools"
	FSCConfigmapMountPath = "/config"

	TopologySecretDataKey        = "config"
	TopologyStorageClassByMgmtId = "by_management_id"

	PVMgmtAddrKey = "array_address"

	CsiIBMBlockDriver = "block.csi.ibm.com"
	CsiIBMBlockScPool = "pool"

	PersistentVolumeClaimKind = "PersistentVolumeClaim"

	DefaultSecretNameKey      = "csi.storage.k8s.io/secret-name"      // #nosec G101 - false positive
	DefaultSecretNamespaceKey = "csi.storage.k8s.io/secret-namespace" // #nosec G101 - false positive

	ProvisionerSecretNameKey      = "csi.storage.k8s.io/provisioner-secret-name"      // #nosec G101 - false positive
	ProvisionerSecretNamespaceKey = "csi.storage.k8s.io/provisioner-secret-namespace" // #nosec G101 - false positive

	SecretManagementAddressKey = "management_address" // #nosec G101 - false positive
)
View Source
const ExporterImageEnvVar = "EXPORTER_IMAGE"
View Source
const OdfFsStorageSystemLabelKey = "odf-fs-storage-system"
View Source
const WatchNamespaceEnvVar = "RESOURCES_NAMESPACE"

WatchNamespaceEnvVar is the constant for env variable RESOURCES_NAMESPACE which is the namespace where the watch activity happens. this value is empty if the operator is running with clusterScope.

Variables

View Source
var (
	// PhaseIgnored is used when a resource is ignored
	PhaseIgnored = "Ignored"
	// PhaseProgressing is used when SetProgressingCondition is called
	PhaseProgressing = "Progressing"
	// PhaseError is used when SetErrorCondition is called
	PhaseError = "Error"
	// PhaseReady is used when SetCompleteCondition is called
	PhaseReady = "Ready"
	// PhaseNotReady is used when waiting for system to be ready after reconcile is successful
	PhaseNotReady = "Not Ready"
)
View Source
var ComponentLabel = Label{"app.kubernetes.io/component", "ibm-storage-odf-operator"}
View Source
var IgnoreUpdateAndGenericPredicate = predicate.Funcs{
	CreateFunc: func(e event.CreateEvent) bool {
		return true
	},
	DeleteFunc: func(e event.DeleteEvent) bool {
		return true
	},
	UpdateFunc: func(e event.UpdateEvent) bool {
		return false
	},
	GenericFunc: func(e event.GenericEvent) bool {
		return false
	},
}
View Source
var OdfFsLabel = Label{"odf-fs", "odf-fs-workspace"}
View Source
var OdfLabel = Label{"odf", "storage.ibm.com"}
View Source
var RunDeletePredicate = predicate.Funcs{
	CreateFunc: func(e event.CreateEvent) bool {
		return false
	},
	DeleteFunc: func(e event.DeleteEvent) bool {
		return true
	},
	UpdateFunc: func(e event.UpdateEvent) bool {
		return false
	},
	GenericFunc: func(e event.GenericEvent) bool {
		return false
	},
}
View Source
var SecretMgmtAddrPredicate = predicate.Funcs{
	CreateFunc: func(e event.CreateEvent) bool {
		secret, ok := e.Object.(*corev1.Secret)
		if !ok {
			return false
		}
		_, isTopology := secret.Data[TopologySecretDataKey]
		if isTopology {
			return isTopologySecretHasMgmtAddr(secret)
		}
		_, exist := secret.Data[SecretManagementAddressKey]
		return exist
	},
	DeleteFunc: func(e event.DeleteEvent) bool {
		secret, ok := e.Object.(*corev1.Secret)
		if !ok {
			return false
		}
		_, isTopology := secret.Data[TopologySecretDataKey]
		if isTopology {
			return isTopologySecretHasMgmtAddr(secret)
		}
		_, exist := secret.Data[SecretManagementAddressKey]
		return exist
	},
	UpdateFunc: func(e event.UpdateEvent) bool {
		oldSecret, ok := e.ObjectOld.(*corev1.Secret)
		newSecret := e.ObjectNew.(*corev1.Secret)
		if !ok {
			return false
		}
		_, isTopology := oldSecret.Data[TopologySecretDataKey]
		if isTopology {
			return isTopologySecretUpdated(oldSecret, newSecret)
		}

		oldMgmtAddr, exist1 := oldSecret.Data[SecretManagementAddressKey]
		newMgmtAddr, exist2 := newSecret.Data[SecretManagementAddressKey]

		return exist1 && exist2 && (string(oldMgmtAddr) != string(newMgmtAddr))
	},
	GenericFunc: func(e event.GenericEvent) bool {
		return false
	},
}

Functions

func CalculateDataHash

func CalculateDataHash(dataObject interface{}) (string, error)

CalculateDataHash generates a sha256 hex-digest for a data object

func DetermineOpenShiftVersion added in v1.0.0

func DetermineOpenShiftVersion(client client.Client) (string, error)

func FindStatusCondition

func FindStatusCondition(conditions []odfv1alpha1.Condition, conditionType odfv1alpha1.ConditionType) *odfv1alpha1.Condition

FindStatusCondition finds the conditionType in conditions.

func GetCreateConfigmap added in v1.3.0

func GetCreateConfigmap(client client.Client, log logr.Logger, ns string, createIfMissing bool) (*corev1.ConfigMap, error)

func GetExporterImage

func GetExporterImage() (string, error)

GetExporterImage returns the exporter image from operator env by OLM bundle

func GetLabels

func GetLabels() map[string]string

GetLabels returns the labels with cluster name

func GetStorageClassSecret added in v1.3.0

func GetStorageClassSecret(client client.Client, sc *storagev1.StorageClass) (corev1.Secret, error)

func GetStorageClassSecretNamespacedName added in v1.3.0

func GetStorageClassSecretNamespacedName(sc *storagev1.StorageClass) (string, string, error)

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func InitK8sEvent added in v1.0.0

func InitK8sEvent(instance *odfv1alpha1.FlashSystemCluster, eventType, reason, message string) *corev1.Event

func IsContain

func IsContain(slice []string, s string) bool

func IsStatusConditionFalse

func IsStatusConditionFalse(conditions []odfv1alpha1.Condition, conditionType odfv1alpha1.ConditionType) bool

IsStatusConditionFalse returns true when the conditionType is present and set to `corev1.ConditionFalse`

func IsStatusConditionPresentAndEqual

func IsStatusConditionPresentAndEqual(conditions []odfv1alpha1.Condition, conditionType odfv1alpha1.ConditionType, status corev1.ConditionStatus) bool

IsStatusConditionPresentAndEqual returns true when conditionType is present and equal to status.

func IsStatusConditionTrue

func IsStatusConditionTrue(conditions []odfv1alpha1.Condition, conditionType odfv1alpha1.ConditionType) bool

IsStatusConditionTrue returns true when the conditionType is present and set to `corev1.ConditionTrue`

func MapClustersByMgmtAddress added in v1.3.0

func MapClustersByMgmtAddress(client client.Client, logger logr.Logger) (map[string]v1alpha1.FlashSystemCluster, error)

func ReadPoolConfigMapFile added in v1.3.0

func ReadPoolConfigMapFile() (map[string]FlashSystemClusterMapContent, error)

func Remove

func Remove(slice []string, s string) (result []string)

func RemoveStatusCondition

func RemoveStatusCondition(conditions *[]odfv1alpha1.Condition, conditionType odfv1alpha1.ConditionType)

RemoveStatusCondition removes the corresponding conditionType from conditions.

func SetReconcileCompleteCondition

func SetReconcileCompleteCondition(conditions *[]odfv1alpha1.Condition, reason string, message string)

SetReconcileCompleteCondition sets the ConditionReconcileComplete to True and other Conditions to indicate that the reconciliation process has completed successfully.

func SetReconcileErrorCondition

func SetReconcileErrorCondition(conditions *[]odfv1alpha1.Condition, reason string, message string)

SetReconcileErrorCondition sets the ConditionReconcileComplete to False in case of any errors during the reconciliation process.

func SetReconcileProgressingCondition

func SetReconcileProgressingCondition(conditions *[]odfv1alpha1.Condition, reason string, message string)

SetReconcileProgressingCondition sets the ProgressingCondition to True and other conditions to false or Unknown. Used when we are just starting to reconcile, and there are no existing conditions.

func SetReconcileProvisionerErrorCondition added in v1.3.0

func SetReconcileProvisionerErrorCondition(conditions *[]odfv1alpha1.Condition, reason string, message string)

SetReconcileProvisionerErrorCondition sets the ProvisionerReady to False in case CSI driver fails to start

func SetStatusCondition

func SetStatusCondition(conditions *[]odfv1alpha1.Condition, newCondition odfv1alpha1.Condition)

SetStatusCondition sets the corresponding condition in conditions to newCondition.

Types

type FSCConfigMapData added in v1.3.0

type FSCConfigMapData struct {
	FlashSystemClusterMap map[string]FlashSystemClusterMapContent
}

type FSCMatchNotFoundError added in v1.3.0

type FSCMatchNotFoundError struct{}

func (*FSCMatchNotFoundError) Error added in v1.3.0

func (m *FSCMatchNotFoundError) Error() string

type FlashSystemClusterMapContent added in v1.3.0

type FlashSystemClusterMapContent struct {
	ScPoolMap map[string]string `json:"storageclass"`
	Secret    string            `json:"secret"`
}

type Label added in v1.3.0

type Label struct {
	Name  string
	Value string
}

type UniqueFSCMatchError added in v1.3.0

type UniqueFSCMatchError struct{}

func (*UniqueFSCMatchError) Error added in v1.3.0

func (m *UniqueFSCMatchError) Error() string

Jump to

Keyboard shortcuts

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