utils

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Overview

Copyright 2023 The Fluid Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	PlatformDefault      = "Default"
	PlatformUnprivileged = "Unprivileged"
)

---- Utils functions to decide serverless platform ----

View Source
const (
	KiB = 1024
	MiB = 1024 * KiB
	GiB = 1024 * MiB
	TiB = 1024 * GiB
	PiB = 1024 * TiB
	EiB = 1024 * PiB
)
View Source
const (
	PVCStorageAnnotation   = "pvc.fluid.io/resources.requests.storage"
	DefaultStorageCapacity = "100Pi"
)
View Source
const MountRoot string = "MOUNT_ROOT"

Variables

View Source
var (
	ServerlessPlatformKey string = ""
	ServerlessPlatformVal string = ""
)

Functions

func AddRuntimesIfNotExist

func AddRuntimesIfNotExist(runtimes []datav1alpha1.Runtime, newRuntime datav1alpha1.Runtime) (updatedRuntimes []datav1alpha1.Runtime)

AddRuntimesIfNotExist adds newRuntime to runtimes and return the updated runtime slice

func AppContainerPostStartInjectEnabled added in v0.8.0

func AppContainerPostStartInjectEnabled(infos map[string]string) (match bool)

func AppControllerDisabled added in v0.8.0

func AppControllerDisabled(info map[string]string) (match bool)

func AppendOrOverrideVolume added in v0.9.0

func AppendOrOverrideVolume(volumes []corev1.Volume, vol corev1.Volume) []corev1.Volume

func AppendOrOverrideVolumeMounts added in v0.9.0

func AppendOrOverrideVolumeMounts(volumeMounts []corev1.VolumeMount, vm corev1.VolumeMount) []corev1.VolumeMount

func BytesSize added in v0.4.0

func BytesSize(size float64) string

BytesSize returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes, but with a B, kB, MB unit style. This is to make byte units be in consistent with Alluxio See https://github.com/Alluxio/alluxio/blob/master/core/common/src/main/java/alluxio/util/FormatUtils.java#L135

func CalculateDuration added in v0.6.0

func CalculateDuration(creationTime time.Time, finishTime time.Time) string

CalculateDuration generates a string of duration from creationTime and finishTime if finish time is zero, use current time as default

func ChangeNodeLabelWithPatchMode added in v0.6.0

func ChangeNodeLabelWithPatchMode(cli client.Client, node *v1.Node, labelsToModify common.LabelsToModify) (modifiedLabels []string, err error)

ChangeNodeLabelWithPatchMode updates the input labels in PATCH mode.

func ChangeNodeLabelWithUpdateMode added in v0.6.0

func ChangeNodeLabelWithUpdateMode(client client.Client, node *v1.Node, labelsToModify common.LabelsToModify) (modifiedLabels []string, err error)

ChangeNodeLabelWithUpdateMode updates the input labels in UPDATE mode.

func CheckMountPointBroken added in v0.7.0

func CheckMountPointBroken(mountPath string) (broken bool, err error)

func CheckMountReadyAndSubPathExist added in v0.9.0

func CheckMountReadyAndSubPathExist(fluidPath string, mountType string, subPath string) (err error)

func CheckObject added in v0.8.0

func CheckObject(client client.Client, key types.NamespacedName, obj client.Object) (found bool, err error)

func CheckValidateEnvName added in v1.0.0

func CheckValidateEnvName(key string) (err error)

func ContainsAll added in v0.6.0

func ContainsAll(m map[string]string, slice []string) bool

ContainsAll checks if a map contains all the elements in a slice

func ContainsOwners added in v0.5.0

func ContainsOwners(owners []metav1.OwnerReference, dataset *datav1alpha1.Dataset) bool

ContainsOwners Determine whether the slice of owners contains the owner of a Dataset return true if contains the owner and return false if not.

func ContainsSelector added in v0.5.0

func ContainsSelector(labels map[string]string, selector map[string]string) bool

ContainsSelector Determine whether the labels contain the selector

func ContainsString

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

ContainsString Determine whether the string array contains a specific string return true if contains the string and return false if not.

func ContainsSubString added in v0.8.0

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

ContainsSubString Determine whether the string array contains a sub string return true if contains the string and return false if not.

func ConvertDashToUnderscore added in v1.0.0

func ConvertDashToUnderscore(s string) string

ConvertDashToUnderscore converts all dash "-" characters in a string to underscore "_" characters.

func CreateRuntimeForReferenceDatasetIfNotExist added in v0.9.0

func CreateRuntimeForReferenceDatasetIfNotExist(client client.Client, dataset *datav1alpha1.Dataset) (err error)

CreateRuntimeForReferenceDatasetIfNotExist creates runtime for ReferenceDataset

func CreateSymlink(targetPath, mountPath string) error

func DumpJSON added in v0.8.0

func DumpJSON(o interface{}) string

DumpJSON returns the JSON encoding

func FillSliceWithString added in v0.5.0

func FillSliceWithString(str string, num int) *[]string

FillSliceWithString fills a slice with repeated given string

func FilterVolumesByVolumeMounts added in v0.9.0

func FilterVolumesByVolumeMounts(volumes []corev1.Volume, volumeMounts []corev1.VolumeMount) []corev1.Volume

FilterVolumesByVolumeMounts returns volumes that exists in the volumeMounts

func FindVolumeByVolumeMount added in v0.9.0

func FindVolumeByVolumeMount(volumeMount corev1.VolumeMount, volumes []corev1.Volume) *corev1.Volume

func FromHumanSize added in v0.4.0

func FromHumanSize(size string) (int64, error)

FromHumanSize returns an integer from a human-readable specification of a size with 1024 as multiplier e.g.:

  1. 1 KiB = 1024 byte

func FromRawToObject added in v0.7.0

func FromRawToObject(raw []byte) (obj runtime.Object, err error)

FromRawToObject is used to convert from raw to the runtime object

func FuseSidecarPrivileged added in v1.0.1

func FuseSidecarPrivileged(infos map[string]string) (match bool)

FuseSidecarPrivileged decides if the injected fuse sidecar should be privileged, only used when fuse sidecar should be injected - sidecar is privileged only when setting serverless.fluid.io/inject=true without unprivileged.sidecar.fluid.io/inject=true

func FuseSidecarUnprivileged added in v0.8.0

func FuseSidecarUnprivileged(infos map[string]string) (match bool)

FuseSidecarUnprivileged decides if the injected fuse sidecar should be unprivileged, only used when fuse sidecar should be injected - serverlessPlatform implies injecting unprivileged fuse sidecar - serverless.fluid.io/inject=true + unprivileged.sidecar.fluid.io/inject=true implies injecting unprivileged fuse sidecar,

func GetAccessModesOfDataset added in v0.5.0

func GetAccessModesOfDataset(client client.Client, name, namespace string) (accessModes []corev1.PersistentVolumeAccessMode, err error)

func GetAddressOfMaster added in v0.5.0

func GetAddressOfMaster(pod *v1.Pod) (nodeName string, ip string, rpcPort int32)

GetAddressOfMaster return the ip and port of engine master

func GetAlluxioRuntime

func GetAlluxioRuntime(client client.Client, name, namespace string) (*datav1alpha1.AlluxioRuntime, error)

GetAlluxioRuntime gets Alluxio Runtime object with the given name and namespace

func GetBackupUserDir added in v0.6.0

func GetBackupUserDir(namespace string, name string) string

GetBackupUserDir generate the temp dir of backup user

func GetBoolValueFromEnv added in v0.9.2

func GetBoolValueFromEnv(key string, defaultValue bool) (value bool)

func GetChartsDirectory

func GetChartsDirectory() string

GetChartsDirectory gets the directory of the charts

func GetCommonLabelName added in v1.0.2

func GetCommonLabelName(isDeprecated bool, namespace string, name string) string

func GetDataBackup added in v0.5.0

func GetDataBackup(client client.Client, name, namespace string) (*datav1alpha1.DataBackup, error)

GetDataBackup gets the DataBackup given its name and namespace

func GetDataBackupPodName added in v0.5.0

func GetDataBackupPodName(name string) string

GetDataBackupPodName returns DataBackup pod's name given the DataBackup's name

func GetDataBackupReleaseName added in v0.5.0

func GetDataBackupReleaseName(name string) string

GetDataBackupReleaseName returns DataBackup helm release's name given the DataBackup's name

func GetDataLoad

func GetDataLoad(client client.Client, name, namespace string) (*datav1alpha1.DataLoad, error)

GetDataLoad gets the DataLoad given its name and namespace

func GetDataLoadJobName added in v0.4.0

func GetDataLoadJobName(releaseName string) string

GetDataLoadJobName returns DataLoad job's name given the DataLoad helm release's name

func GetDataLoadReleaseName added in v0.4.0

func GetDataLoadReleaseName(name string) string

GetDataLoadReleaseName returns DataLoad helm release's name given the DataLoad's name

func GetDataMigrate added in v0.9.0

func GetDataMigrate(client client.Client, name, namespace string) (*datav1alpha1.DataMigrate, error)

GetDataMigrate gets the DataMigrate given its name and namespace

func GetDataMigrateJobName added in v0.9.0

func GetDataMigrateJobName(releaseName string) string

GetDataMigrateJobName returns DataMigrate job(or cronjob)'s name given the DataMigrate helm release's name

func GetDataMigrateReleaseName added in v0.9.0

func GetDataMigrateReleaseName(name string) string

GetDataMigrateReleaseName returns DataMigrate helm release's name given the DataMigrate's name

func GetDataProcess added in v1.0.0

func GetDataProcess(client client.Client, name, namespace string) (*datav1alpha1.DataProcess, error)

func GetDataProcessJobName added in v1.0.0

func GetDataProcessJobName(releaseName string) string

func GetDataProcessReleaseName added in v1.0.0

func GetDataProcessReleaseName(name string) string

GetDataProcessReleaseName returns the helm release name given the DataProcess's name.

func GetDataset

func GetDataset(client client.Client, name, namespace string) (*datav1alpha1.Dataset, error)

GetDataset gets the dataset. It returns a pointer to the dataset if successful.

func GetDatasetCondition

func GetDatasetCondition(conditions []datav1alpha1.DatasetCondition,
	condType datav1alpha1.DatasetConditionType) (index int, condition *datav1alpha1.DatasetCondition)

GetDatasetCondition returns dataset condition according to a given dataset condition type. If found, return index of the founded condition in the condition array and the founded condition itself, otherwise return -1 and nil.

func GetDurationValueFromEnv added in v0.8.0

func GetDurationValueFromEnv(key string, defaultValue time.Duration) (value time.Duration)

func GetEFCRuntime added in v0.9.0

func GetEFCRuntime(client client.Client, name, namespace string) (*datav1alpha1.EFCRuntime, error)

GetEFCRuntime gets EFC Runtime object with the given name and namespace

func GetEnvByKey added in v0.6.0

func GetEnvByKey(k string) (string, error)

func GetExclusiveKey added in v0.5.0

func GetExclusiveKey() string

GetExclusiveKey gets exclusive key

func GetExclusiveValue added in v0.5.0

func GetExclusiveValue(namespace, name string) string

GetExclusiveValue gets exclusive value

func GetGooseFSRuntime added in v0.6.0

func GetGooseFSRuntime(client client.Client, name, namespace string) (*datav1alpha1.GooseFSRuntime, error)

GetGooseFSRuntime gets GooseFS Runtime object with the given name and namespace

func GetInitUserEnv added in v0.6.0

func GetInitUserEnv(user *datav1alpha1.User) string

func GetInitUsersArgs added in v0.6.0

func GetInitUsersArgs(user *datav1alpha1.User) []string

func GetIntValueFromEnv added in v0.9.2

func GetIntValueFromEnv(key string) (value int, found bool)

func GetJindoRuntime added in v0.6.0

func GetJindoRuntime(client client.Client, name, namespace string) (*datav1alpha1.JindoRuntime, error)

GetJindoRuntime gets Jindo Runtime object with the given name and namespace

func GetJuiceFSRuntime added in v0.7.0

func GetJuiceFSRuntime(client client.Client, name, namespace string) (*datav1alpha1.JuiceFSRuntime, error)

GetJuiceFSRuntime gets JuiceFS Runtime object with the given name and namespace

func GetLabelNameForDisk added in v1.0.2

func GetLabelNameForDisk(isDeprecated bool, runtimeType string, namespace string, name string) string

func GetLabelNameForMemory added in v1.0.2

func GetLabelNameForMemory(isDeprecated bool, runtimeType string, namespace string, name string) string

func GetLabelNameForTotal added in v1.0.2

func GetLabelNameForTotal(isDeprecated bool, runtimeType string, namespace string, name string) string

func GetMountRoot added in v0.4.0

func GetMountRoot() (string, error)

GetMountRoot gets the value of the env variable named MOUNT_ROOT

func GetObjectMeta added in v0.9.0

func GetObjectMeta(object client.Object) (objectMeta metav1.Object, err error)

func GetOperationStatus added in v1.0.0

func GetOperationStatus(obj client.Object) (*datav1alpha1.OperationStatus, error)

func GetOrDefault

func GetOrDefault(str *string, defaultValue string) string

GetOrDefault returns the default value unless there is a specified value.

func GetPVCStorageCapacityOfDataset added in v1.0.1

func GetPVCStorageCapacityOfDataset(client client.Client, name, namespace string) (storageCapacity resource.Quantity, err error)

func GetParallelOperationWorkersName added in v1.0.0

func GetParallelOperationWorkersName(releaseName string) string

GetParallelOperationWorkersName Get the workers statefulset name according the helm release name

func GetPrecedingOperationStatus added in v1.0.0

func GetPrecedingOperationStatus(client client.Client, opRef *datav1alpha1.ObjectRef, opRefNamespace string) (*datav1alpha1.OperationStatus, error)

func GetRpcPortFromMasterContainer added in v0.6.0

func GetRpcPortFromMasterContainer(container *v1.Container) (rpcPort int32)

func GetRuntimeByCategory added in v0.4.0

func GetRuntimeByCategory(runtimes []datav1alpha1.Runtime, category common.Category) (index int, runtime *datav1alpha1.Runtime)

func GetRuntimeCondition

func GetRuntimeCondition(conditions []data.RuntimeCondition,
	condType data.RuntimeConditionType) (index int, condition *data.RuntimeCondition)

GetRuntimeCondition gets a runtime condition given a runtime condition type. If found, return index of the founded condition in the condition array and the founded condition itself, otherwise return -1 and nil.

func GetRuntimeLabelName added in v1.0.2

func GetRuntimeLabelName(isDeprecated bool, runtimeType string, namespace string, name string) string

func GetRuntimeNameFromFusePod added in v0.7.0

func GetRuntimeNameFromFusePod(pod corev1.Pod) (runtimeName string, err error)

func GetServerlessPlatfrom added in v1.0.0

func GetServerlessPlatfrom(infos map[string]string) (platform string)

func GetStoragetLabelName added in v1.0.2

func GetStoragetLabelName(read common.ReadType, storage common.StorageType, isDeprecated bool, runtimeType string, namespace string, name string) string

func GetStringValueFromEnv added in v0.8.0

func GetStringValueFromEnv(key string, defaultValue string) (value string)

func GetTargetDatasetNamespacedNameOfMigrate added in v1.0.3

func GetTargetDatasetNamespacedNameOfMigrate(client client.Client, dataMigrate *datav1alpha1.DataMigrate) (namespacedName types.NamespacedName, err error)

func GetTargetDatasetOfMigrate added in v0.9.0

func GetTargetDatasetOfMigrate(client client.Client, dataMigrate *datav1alpha1.DataMigrate) (targetDataset *datav1alpha1.Dataset, err error)

func GetThinRuntime added in v0.9.0

func GetThinRuntime(client client.Client, name, namespace string) (*datav1alpha1.ThinRuntime, error)

func GetThinRuntimeProfile added in v0.9.0

func GetThinRuntimeProfile(client client.Client, name string) (*datav1alpha1.ThinRuntimeProfile, error)

func GetVineyardRuntime added in v1.0.0

func GetVineyardRuntime(client client.Client, name, namespace string) (*datav1alpha1.VineyardRuntime, error)

GetVineyardRuntime gets Vineyard Runtime object with the given name and namespace

func HasDeletionTimestamp

func HasDeletionTimestamp(obj metav1.ObjectMeta) bool

HasDeletionTimestamp method that makes logic easier to read.

func Home

func Home() (string, error)

Home returns the home directory for the executing user. This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.

func IgnoreAlreadyExists added in v0.8.0

func IgnoreAlreadyExists(err error) error

IgnoreAlreadyExists ignores already existes error

func IgnoreNoKindMatchError added in v0.9.0

func IgnoreNoKindMatchError(err error) error

func IgnoreNotFound

func IgnoreNotFound(err error) error

IgnoreNotFound ignores not found

func InjectCacheDirEnabled added in v0.7.0

func InjectCacheDirEnabled(infos map[string]string) (match bool)

func InjectMountPropagation added in v0.7.0

func InjectMountPropagation(datasetNames []string, pod *corev1.Pod)

func InjectNodeSelectorRequirements added in v1.0.1

func InjectNodeSelectorRequirements(matchExpressions []v1.NodeSelectorRequirement, affinity *v1.Affinity) *v1.Affinity

InjectNodeSelectorRequirements injects(not append) a node selector term to affinity‘s nodeAffinity.

func InjectNodeSelectorTerms added in v0.6.0

func InjectNodeSelectorTerms(requiredSchedulingTerms []corev1.NodeSelectorTerm, pod *corev1.Pod)

InjectRequiredSchedulingTerms inject the NodeSelectorTerms into a pod

func InjectPreferredSchedulingTerms added in v0.6.0

func InjectPreferredSchedulingTerms(preferredSchedulingTerms []corev1.PreferredSchedulingTerm, pod *corev1.Pod)

InjectPreferredSchedulingTerms inject the preferredSchedulingTerms into a pod

func InjectPreferredSchedulingTermsToAffinity added in v1.0.1

func InjectPreferredSchedulingTermsToAffinity(terms []v1.PreferredSchedulingTerm, affinity *v1.Affinity) *v1.Affinity

func InjectSidecarDone added in v0.7.0

func InjectSidecarDone(infos map[string]string) (match bool)

func IntersectIntegerSets added in v1.0.0

func IntersectIntegerSets(map1 map[int]bool, map2 map[int]bool) map[int]bool

IntersectIntegerSets returns the intersection of integer set 1 and set 2.

func IsDatasetConditionExist

func IsDatasetConditionExist(conditions []datav1alpha1.DatasetCondition,
	cond datav1alpha1.DatasetCondition) (found bool)

IsDatasetConditionExist checks if the given dataset condition exists in the given dataset condition array.

func IsFusePod added in v0.7.0

func IsFusePod(pod corev1.Pod) bool

func IsMounted added in v0.7.0

func IsMounted(absPath string) (bool, error)

func IsPodManagedByFluid added in v0.9.0

func IsPodManagedByFluid(pod *corev1.Pod) bool

IsPodManagedByFluid checks if the given Pod is managed by Fluid.

func IsSetupDone added in v0.4.0

func IsSetupDone(dataset *datav1alpha1.Dataset) (done bool)

checks the setup is done

func IsSubPath added in v0.6.0

func IsSubPath(path, subPath string) bool

determine if subPath is a subdirectory of path

func IsTargetPathUnderFluidNativeMounts added in v0.6.0

func IsTargetPathUnderFluidNativeMounts(targetPath string, dataset datav1alpha1.Dataset) bool

IsTargetPathUnderFluidNativeMounts checks if targetPath is a subpath under some given native mount point. We check this for the reason that native mount points need extra metadata sync alluxioOperations.

func IsTimeTrackerDebugEnabled added in v0.8.0

func IsTimeTrackerDebugEnabled() bool

func IsTimeTrackerEnabled added in v0.8.0

func IsTimeTrackerEnabled() bool

func ListDataOperationJobByCronjob added in v1.0.0

func ListDataOperationJobByCronjob(c client.Client, cronjobNamespacedName types.NamespacedName) ([]batchv1.Job, error)

ListDataOperationJobByCronjob gets the DataOperation(i.e. DataMigrate, DataLoad) job by cronjob given its name and namespace

func LoggingErrorExceptConflict added in v0.7.0

func LoggingErrorExceptConflict(logging logr.Logger, err error, info string, namespacedKey types.NamespacedName) (result error)

LoggingErrorExceptConflict logs error except for updating operation violates with etcd concurrency control

func NeedCleanUp added in v1.0.0

func NeedCleanUp(opStatus *datav1alpha1.OperationStatus, operation dataoperation.OperationInterface) bool

func NewDatasetCondition

func NewDatasetCondition(conditionType datav1alpha1.DatasetConditionType, reason, message string, status v1.ConditionStatus) datav1alpha1.DatasetCondition

NewDatasetCondition creates a new Cache condition.

func NewPprofServer added in v0.7.0

func NewPprofServer(setupLog logr.Logger, pprofAddr string, enableFullGoProfile bool)

func NewRuntime

func NewRuntime(name, namespace string, category common.Category, runtimeType string, replicas int32) datav1alpha1.Runtime

NewRuntimeCondition creates a new Cache condition.

func NewRuntimeCondition

func NewRuntimeCondition(conditionType data.RuntimeConditionType, reason, message string, status v1.ConditionStatus) data.RuntimeCondition

NewRuntimeCondition creates a new Cache condition.

func NoRequeue

func NoRequeue() (ctrl.Result, error)

NoRequeue returns the result of a reconcile invocation and no err The Object will not requeue

func Now

func Now() *metav1.Time

Now returns the current time

func OrderedKeys added in v1.0.3

func OrderedKeys[K cmp.Ordered, V any](m map[K]V) []K

OrderedKeys returns a sorted slice with all keys defined in the map.

func ParseBackupRestorePath added in v0.5.0

func ParseBackupRestorePath(backupRestorePath string) (pvcName string, path string, err error)

ParseBackupRestorePath parse the BackupPath in spec of DataBackup or the RestorePath in spec of Dataset

func PatchLabels added in v0.9.0

func PatchLabels(cli client.Client, obj client.Object, labelsToModify common.LabelsToModify) (modifiedLabels []string, err error)

func PathExists

func PathExists(path string) bool

PathExists returns the specified path is exists or not

func RandomAlphaNumberString

func RandomAlphaNumberString(l int32) string

RandomAlphaNumberString returns a string of length l which is made up of runes randomly selected from [0-9a-z].

func RandomReplacePrefix added in v0.7.0

func RandomReplacePrefix(input string, l int) (output string)

func RandomString

func RandomString(source []rune, l int32) string

RandomString returns a string of length l which is made up of runes randomly selected from `source`.

func RemoveDuplicateStr added in v0.7.0

func RemoveDuplicateStr(strSlice []string) []string

RemoveDuplicateStr removes duplicate string

func RemoveNotFoundDatasetRef added in v1.0.0

func RemoveNotFoundDatasetRef(client client.Client, dataset datav1alpha1.Dataset, log logr.Logger) ([]string, error)

RemoveNotFoundDatasetRef checks datasetRef existence and remove if reference dataset is not found

func RemoveString

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

RemoveString removes strings in a array, which is equal to a given string.

func RemoveSymlink(targetPath string) (bool, error)

func ReplacePrefix added in v0.7.0

func ReplacePrefix(input, suffix string) (output string)

ReplacePrefix replaces the input with suffix string

func RequeueAfterInterval

func RequeueAfterInterval(interval time.Duration) (ctrl.Result, error)

RequeueAfterInterval returns the result of a reconcile invocation with a given requeue interval and no err The Object will requeue after the given requeue interval

func RequeueIfError

func RequeueIfError(err error) (ctrl.Result, error)

RequeueIfError returns the result of a reconciler invocation and the err The Object will requeue when err is not nil

func RequeueImmediately

func RequeueImmediately() (ctrl.Result, error)

RequeueImmediately returns the result of a reconciler invocation and no err The Object will requeue immediately whether the err is nil or not

func RequeueImmediatelyUnlessGenerationChanged

func RequeueImmediatelyUnlessGenerationChanged(prevGeneration, curGeneration int64) (ctrl.Result, error)

RequeueImmediatelyUnlessGenerationChanged requeues immediately if the object generation has not changed. Otherwise, since the generation change will trigger an immediate update anyways, this will not requeue. This prevents some cases where two reconciliation loops will occur.

func ResourceRequirementsEqual added in v0.8.0

func ResourceRequirementsEqual(source corev1.ResourceRequirements,
	target corev1.ResourceRequirements) bool

func ServerfulFuseEnabled added in v0.9.0

func ServerfulFuseEnabled(infos map[string]string) (match bool)

ServerfulFuseEnabled decides if FUSE CSI related optimization should be injected, e.g. HostToContainer mountPropagation for FUSE Recovery feature.

func ServerlessEnabled added in v0.7.0

func ServerlessEnabled(infos map[string]string) (match bool)

ServerlessEnabled decides if fuse sidecar should be injected, whether privileged or unprivileged - serverlessPlatform implies injecting unprivileged fuse sidecar - serverless.fluid.io/inject=true implies injecting (privileged/unprivileged) fuse sidecar, - deprecated fuse.sidecar.fluid.io/inject=true is the deprecated version of serverless.fluid.io/inject=true

func SetValueIfKeyAbsent added in v1.0.1

func SetValueIfKeyAbsent(m map[string]string, key string, value string)

SetValueIfKeyAbsent sets value when key is not found in the map.

func SkipSidecarPostStartInject added in v1.0.0

func SkipSidecarPostStartInject(infos map[string]string) (match bool)

func SortIpAddresses added in v0.9.0

func SortIpAddresses(ips []string) (orderedIps []string)

func SplitSchemaAddr

func SplitSchemaAddr(addr string) (string, string)

SplitSchemaAddr splits the address string into 2 parts: proto and addr. Proto is set to "tcp" in default. It returns proto and addr separately.

func SubtractString added in v0.6.0

func SubtractString(x []string, y []string) []string

SubtractString returns the subtraction between two string slice

func TimeTrack added in v0.6.0

func TimeTrack(start time.Time, processName string, keysAndValues ...interface{})

TimeTrack tracks the time cost for some process with some optional information. For example, to track the processing time of a function, just add the following code at the beginning of your function:

defer utils.TimeTrack(time.Now(), <func-name>, <keysAndValues>...)

func Timeleft added in v1.0.0

Timeleft return not nil remaining time if data operation has completion time and set ttlAfterFinished

func ToYaml

func ToYaml(values interface{}, file *os.File) error

ToYaml converts values from json format to yaml format and stores the values to the file. It will return err when failed to marshal value or write file.

func TranformQuantityToUnits added in v0.5.0

func TranformQuantityToUnits(q *resource.Quantity) (value string)

TransformQuantityToUnits returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").

func TransformEFCUnitToQuantity added in v0.9.0

func TransformEFCUnitToQuantity(value string) (q *resource.Quantity)

func TransformQuantityToAlluxioUnit added in v0.6.0

func TransformQuantityToAlluxioUnit(q *resource.Quantity) (value string)

TransformQuantityToAlluxioUnit transform a given input quantity to another one that can be recognized by Alluxio. This is necessary because Alluxio takes decimal byte units(e.g. KB, MB, GB, etc.) as binary byte units(e.g. Ki, Mi, Gi)

func TransformQuantityToEFCUnit added in v0.9.0

func TransformQuantityToEFCUnit(q *resource.Quantity) (value string)

TransformQuantityToEFCUnit transform a given input quantity to another one that can be recognized by EFC. This is necessary because EFC takes decimal byte units(e.g. KB, MB, GB, etc.) as binary byte units(e.g. Ki, Mi, Gi)

func TransformQuantityToGooseFSUnit added in v0.6.0

func TransformQuantityToGooseFSUnit(q *resource.Quantity) (value string)

TransformQuantityToGooseFSUnit transform a given input quantity to another one that can be recognized by GooseFS. This is necessary because GooseFS takes decimal byte units(e.g. KB, MB, GB, etc.) as binary byte units(e.g. Ki, Mi, Gi)

func TransformQuantityToJindoUnit added in v0.6.0

func TransformQuantityToJindoUnit(q *resource.Quantity) (value string)

TransfromQuantityToJindoUnit transform a given input quantity to another one that can be recognized by Jindo.

func TransformRequirementsToResources

func TransformRequirementsToResources(res corev1.ResourceRequirements) (cRes common.Resources)

func TrimCapabilities added in v0.8.0

func TrimCapabilities(inputs []corev1.Capability, excludeNames []string) (outputs []corev1.Capability)

func TrimVolumeMounts added in v0.7.0

func TrimVolumeMounts(inputs []corev1.VolumeMount, excludeNames []string) (outputs []corev1.VolumeMount)

func TrimVolumes added in v0.7.0

func TrimVolumes(inputs []corev1.Volume, excludeNames []string) (outputs []corev1.Volume)

TrimVolumes trims the volumes

func UnionMapsWithOverride added in v0.8.0

func UnionMapsWithOverride(map1 map[string]string, map2 map[string]string) map[string]string

UnionMapsWithOverride unions two maps into one. If both maps are empty or nil, return an empty map. If both maps share the same key, the value in map2 overrides the value in map1.

func UpdateDatasetCondition

func UpdateDatasetCondition(conditions []datav1alpha1.DatasetCondition, condition datav1alpha1.DatasetCondition) []datav1alpha1.DatasetCondition

SetDatasetCondition updates the dataset to include the provided condition. If the condition that we are about to add already exists and has the same status and reason then we are not going to update.

func UpdateMountStatus added in v0.6.0

func UpdateMountStatus(client client.Client, name string, namespace string, phase datav1alpha1.DatasetPhase) error

UpdateMountStatus updates the mount status of the dataset according to the given phase

func UpdateRuntimeCondition

func UpdateRuntimeCondition(conditions []data.RuntimeCondition, condition data.RuntimeCondition) []data.RuntimeCondition

UpdateRuntimeCondition updates the runtime to include the provided condition. If the condition that we are about to add already exists and has the same status and reason then we are not going to update.

Types

type UFSPathBuilder added in v0.6.0

type UFSPathBuilder struct{}

func (UFSPathBuilder) GenAlluxioUFSRootPath added in v0.6.0

func (u UFSPathBuilder) GenAlluxioUFSRootPath(items []datav1alpha1.Mount) (string, *datav1alpha1.Mount)

GenAlluxioUFSRootPath determines which mount point should be mounted on the root path of the unified namespace in Alluxio engine. Commonly there are two cases:

  1. If a `mount` item is the only item defined in `dataset.sepc.mounts[*]` and its ufs path equals to "/", its `mountpoint` should be on the root path. e.g. alluxio fs mount s3://mybucket /
  2. Otherwise, pick `/underFSStorage` as the default root path. e.g. alluxio fs mount /underFSStorage / && alluxio fs mount s3://mybucket /mybucket

func (UFSPathBuilder) GenLocalStoragePath added in v0.6.0

func (u UFSPathBuilder) GenLocalStoragePath(curMount datav1alpha1.Mount) string

generate local storage path by mount info

func (UFSPathBuilder) GenUFSPathInUnifiedNamespace added in v1.0.2

func (u UFSPathBuilder) GenUFSPathInUnifiedNamespace(mount datav1alpha1.Mount) string

GenUFSPathInUnifiedNamespace generates a path in the cache engine's unified namespace for the given mount. It follows the convention defined internally by Fluid:

1. if `dataset.spec.mounts[*].path` is set to a absolute path, pick `path`. 2. otherwise, pick `/{dataset.spec.mounts[*].name}`

func (UFSPathBuilder) GetLocalStorageRootDir added in v0.6.0

func (u UFSPathBuilder) GetLocalStorageRootDir() string

this value will be the default value for the alluxio configuration:

alluxio.master.mount.table.root.ufs

e.g. :

$ alluxio fs mount
/underFSStorage  on  /  (local, capacity=0B, used=-1B, not read-only, not shared, properties={})

type UFSToUpdate added in v0.6.0

type UFSToUpdate struct {
	// contains filtered or unexported fields
}

UFSToUpdate records the mountPath to change in virtual file system of dataset

func NewUFSToUpdate added in v0.6.0

func NewUFSToUpdate(ds *datav1alpha1.Dataset) *UFSToUpdate

NewUFSToUpdate get UFSToUpdate according the given dataset

func (*UFSToUpdate) AddMountPaths added in v0.7.0

func (u *UFSToUpdate) AddMountPaths(mountPaths []string)

AddMountPaths add mounted path to ToAdd

func (*UFSToUpdate) AnalyzePathsDelta added in v0.6.0

func (u *UFSToUpdate) AnalyzePathsDelta() (specMountPaths, mountedMountPaths []string)

AnalyzePathsDelta analyze the ToAdd and ToRemove from the spec and mounted mountPaths of dataset No need for a mount point with Fluid native scheme('local://' and 'pvc://') to be mounted

func (*UFSToUpdate) ShouldUpdate added in v0.6.0

func (u *UFSToUpdate) ShouldUpdate() bool

ShouldUpdate check if needs to update the mount points according to ToAdd and ToRemove

func (*UFSToUpdate) ToAdd added in v0.6.0

func (u *UFSToUpdate) ToAdd() []string

ToAdd get the mountPaths to add into virtual file system of dataset

func (*UFSToUpdate) ToRemove added in v0.6.0

func (u *UFSToUpdate) ToRemove() []string

ToRemove get the mountPaths to remove from virtual file system of dataset

type VolumeLocks added in v0.9.2

type VolumeLocks struct {
	// contains filtered or unexported fields
}

func NewVolumeLocks added in v0.9.2

func NewVolumeLocks() *VolumeLocks

func (*VolumeLocks) Release added in v0.9.2

func (lock *VolumeLocks) Release(volumeID string)

Release releases lock in volume level

func (*VolumeLocks) TryAcquire added in v0.9.2

func (lock *VolumeLocks) TryAcquire(volumeID string) bool

TryAcquire tries to acquire the lock for operating on resourceID and returns true if successful. If another operation is already using resourceID, returns false.

Jump to

Keyboard shortcuts

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