Documentation ¶
Index ¶
- Constants
- func AlignBytes(currBytes int64, stepBytes int64) int64
- func BackupVolumeSourceToCSIVolumeHandle(sourceInstance, sourceShare string) (string, error)
- func BytesToGb(bytes int64) int64
- func CheckLabelValueRegex(value string) error
- func ConvertLabelsStringToMap(labels string) (map[string]string, error)
- func ConvertVolToShareName(csiVolName string) string
- func CreateConfigMapWithData(ctx context.Context, cmName, cmNamespace string, data map[string]string, ...) (*corev1.ConfigMap, error)
- func ErrCodePtr(code codes.Code) *codes.Code
- func GKENodeNameFromConfigMap(cm *corev1.ConfigMap) (string, error)
- func GbToBytes(gbs int64) int64
- func GenerateConfigMapKey(...) string
- func GetBackupLocation(params map[string]string) string
- func GetConfigMap(ctx context.Context, cmName, cmNamespace string, client kubernetes.Interface) (*corev1.ConfigMap, error)
- func GetMultishareOpsTimeoutConfig(opType OperationType) (time.Duration, time.Duration, error)
- func GetRegionFromZone(location string) (string, error)
- func InstanceStateToCRDStatus(state string) (v1alpha1.FilestoreStatus, error)
- func IsAligned(curSizeBytes int64, expectedBytes int64) bool
- func IsBackupHandle(handle string) (bool, error)
- func IsSnapshotTypeSupported(params map[string]string) (bool, error)
- func Max(a, b int64) int64
- func MbToBytes(mbs int64) int64
- func Min(a, b int64) int64
- func ParseConfigMapKey(key string) (string, string, string, string, string, string, error)
- func ParseInstanceURI(instanceURI string) (string, string, string, error)
- func ParseShareURI(shareURI string) (string, string, string, string, error)
- func ParseTimestamp(timestamp string) (*timestamppb.Timestamp, error)
- func RemoveKeyFromConfigMap(ctx context.Context, cm *corev1.ConfigMap, key string, ...) error
- func RemoveKeyFromConfigMapWithRetry(ctx context.Context, cm *corev1.ConfigMap, key string, ...) error
- func RoundBytesToGb(bytes int64) int64
- func ShareStateToCRDStatus(state string) (v1alpha1.FilestoreStatus, error)
- func UpdateConfigMapWithKeyValue(ctx context.Context, cm *corev1.ConfigMap, key, value string, ...) error
- type IPAllocator
- type OperationStatus
- type OperationType
- type VolumeLocks
Constants ¶
const ( ConfigMapNamePrefix = "fscsi-" ConfigMapNamespace = "gke-managed-filestorecsi" // ConfigMapFinalzer is the finalizer which will be added during configmap creation. ConfigMapFinalzer = "filestore.csi.storage.gke.io/lock-release" )
const ( // the ipRangeSize for Filestore instances IpRangeSize = 29 // the ipRangeSize for enterprise tier Filestore instances IpRangeSizeEnterprise = 26 )
const ( InstanceURISplitLen = 6 FilestoreResourceCleanupFinalizer = "multishare.filestore.csi.storage.gke.io/resource-cleanup-protection" )
const ( OpVerbCreate = "create" OpVerbDelete = "delete" OpVerbUpdate = "update" )
const ( Mb = 1024 * 1024 Gb = 1024 * Mb Tb = 1024 * Gb // VolumeSnapshot parameters VolumeSnapshotTypeKey = "type" VolumeSnapshotLocationKey = "location" VolumeSnapshotTypeSnapshot = "snapshot" VolumeSnapshotTypeBackup = "backup" SnapshotHandleBackupKey = "backups" )
const (
VolumeOperationAlreadyExistsFmt = "" /* 132-byte string literal not displayed */
)
Variables ¶
This section is empty.
Functions ¶
func AlignBytes ¶ added in v1.2.1
Aligns to the next higher multiple of step size. No-op if step size is 0, or already aligned.
func BackupVolumeSourceToCSIVolumeHandle ¶ added in v0.3.1
func CheckLabelValueRegex ¶ added in v1.2.0
func ConvertLabelsStringToMap ¶ added in v0.3.1
ConvertLabelsStringToMap converts the labels from string to map example: "key1=value1,key2=value2" gets converted into {"key1": "value1", "key2": "value2"}
func ConvertVolToShareName ¶ added in v1.2.0
func CreateConfigMapWithData ¶ added in v1.4.1
func CreateConfigMapWithData(ctx context.Context, cmName, cmNamespace string, data map[string]string, client kubernetes.Interface) (*corev1.ConfigMap, error)
CreateConfigMapWithData creates a configmap in the api server. Returns the api server's representation of the configmap, and an error, if there is any.
func GKENodeNameFromConfigMap ¶ added in v1.4.1
GKENodeNameFromConfigMap extracts the GKE node name from configmap. The name of a configmap which stores lock info should start with "fscsi-", and will be in format "fscsi-{GKE_node_name}".
func GenerateConfigMapKey ¶ added in v1.4.1
func GenerateConfigMapKey(projectID, location, filestoreName, shareName, gkeNodeID, gkeNodeInternalIP string) string
GenerateConfigMapKey generates a configmap key for the given filestore and GKE node info strings. The generated key will be in format {projectID}.{location}.{filestoreName}.{shareName}.{nodeID}.{nodeInternalIP} The input gkeNodeInternalIP has to a valid IPV4 address. The output nodeInternalIP will be in underscore concatenation.
func GetBackupLocation ¶ added in v0.3.1
func GetConfigMap ¶ added in v1.4.1
func GetConfigMap(ctx context.Context, cmName, cmNamespace string, client kubernetes.Interface) (*corev1.ConfigMap, error)
GetConfigMap gets the configmap from the api server. Returns nil if the expected configmap is not found.
func GetMultishareOpsTimeoutConfig ¶ added in v1.2.0
func GetRegionFromZone ¶ added in v0.3.1
func InstanceStateToCRDStatus ¶ added in v1.4.1
func InstanceStateToCRDStatus(state string) (v1alpha1.FilestoreStatus, error)
func IsBackupHandle ¶ added in v0.3.1
func IsSnapshotTypeSupported ¶ added in v0.3.1
func ParseConfigMapKey ¶ added in v1.4.1
ParseConfigMapKey converts the a configmap key into projectID, location, filestoreName, shareName, nodeID, and nodeInternalIP. Throws an error if the input key is not in the format of {projectID}.{location}.{filestoreName}.{shareName}.{nodeID}.{nodeInternalIP}
func ParseInstanceURI ¶ added in v1.2.0
func ParseShareURI ¶ added in v1.2.0
func ParseTimestamp ¶ added in v0.3.1
func ParseTimestamp(timestamp string) (*timestamppb.Timestamp, error)
func RemoveKeyFromConfigMap ¶ added in v1.4.1
func RemoveKeyFromConfigMap(ctx context.Context, cm *corev1.ConfigMap, key string, client kubernetes.Interface) error
RemoveKeyFromConfigMap deletes the key from configmap.data, then updates the configmap. No-op if the key does not exist.
func RemoveKeyFromConfigMapWithRetry ¶ added in v1.4.1
func RemoveKeyFromConfigMapWithRetry(ctx context.Context, cm *corev1.ConfigMap, key string, client kubernetes.Interface) error
RemoveKeyFromConfigMapWithRetry gets the latest configmap from the api server, removes the key from configmap.data, and update the configmap. Keeps retrying until configmap successfully update or timeout. No-op if the key does not exist.
func ShareStateToCRDStatus ¶ added in v1.4.1
func ShareStateToCRDStatus(state string) (v1alpha1.FilestoreStatus, error)
func UpdateConfigMapWithKeyValue ¶ added in v1.4.1
func UpdateConfigMapWithKeyValue(ctx context.Context, cm *corev1.ConfigMap, key, value string, client kubernetes.Interface) error
UpdateConfigMapWithKeyValue adds a key value pair into configmap.data, and updates the configmap in the api server. No-op if the key already exists in configmap.data. Returns the server's representation of the configMap, and an error, if there is any.
Types ¶
type IPAllocator ¶ added in v0.2.0
type IPAllocator struct {
// contains filtered or unexported fields
}
IPAllocator struct consists of shared resources that are used to keep track of the CIDR IPRanges currently reserved by service instances
func NewIPAllocator ¶ added in v0.2.0
func NewIPAllocator(pendingIPRanges map[string]bool) *IPAllocator
NewIPAllocator is the constructor to initialize the IPAllocator object Argument pendingIPRanges map[string]bool is a set of IP ranges currently reserved by service instances but pending reservation in the cloud instances
func (*IPAllocator) GetUnreservedIPRange ¶ added in v0.2.0
func (ipAllocator *IPAllocator) GetUnreservedIPRange(cidr string, ipRangeSize int, cloudInstancesReservedIPRanges map[string]bool) (string, error)
GetUnreservedIPRange returns an unreserved IP block. cidr: Provided cidr address in which we need to look for an unreserved IP range with specified size ipRangeSize: the size of the unreserved IP range we are looking for cloudInstancesReservedIPRanges: All the used IP ranges in the cloud instances All the used IP ranges in the service instances not updated in cloud instances is extracted from the pendingIPRanges list in the IPAllocator Finally a final reservedIPRange list is created by merging these two lists Potential error cases: 1) No IP range in the CIDR is unreserved 2) Parsing the CIDR resulted in an error
func (*IPAllocator) ReleaseIPRange ¶ added in v0.2.0
func (ipAllocator *IPAllocator) ReleaseIPRange(ipRange string)
ReleaseIPRange releases the pending IPRange Argument ipRange string is an IPV4 range which needs to be released
type OperationStatus ¶ added in v1.2.0
type OperationStatus int
const ( StatusSuccess OperationStatus = iota StatusRunning StatusFailed StatusUnknown )
type OperationType ¶ added in v1.2.0
type OperationType int
const ( InstanceCreate OperationType = iota InstanceDelete InstanceUpdate UnknownOp )
func ConvertInstanceOpVerbToType ¶ added in v1.2.0
func ConvertInstanceOpVerbToType(v string) OperationType
func ConvertShareOpVerbToType ¶ added in v1.2.0
func ConvertShareOpVerbToType(v string) OperationType
func (OperationType) String ¶ added in v1.2.0
func (o OperationType) String() string
type VolumeLocks ¶ added in v0.5.0
type VolumeLocks struct {
// contains filtered or unexported fields
}
VolumeLocks implements a map with atomic operations. It stores a set of all volume IDs with an ongoing operation.
func NewVolumeLocks ¶ added in v0.5.0
func NewVolumeLocks() *VolumeLocks
func (*VolumeLocks) Release ¶ added in v0.5.0
func (vl *VolumeLocks) Release(volumeID string)
func (*VolumeLocks) TryAcquire ¶ added in v0.5.0
func (vl *VolumeLocks) TryAcquire(volumeID string) bool
TryAcquire tries to acquire the lock for operating on volumeID and returns true if successful. If another operation is already using volumeID, returns false.