util

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Mb = 1024 * 1024

	TrueStr  = "true"
	FalseStr = "false"

	// mount options that both CSI mounter and sidecar mounter should understand.
	DisableMetricsForGKE                = "disable-metrics-for-gke"
	EnableSidecarBucketAccessCheckConst = "enable-sidecar-bucket-access-check"
	TokenServerIdentityPoolConst        = "token-server-identity-pool"
	ServiceAccountNameConst             = "service-account-name"
	PodNamespaceConst                   = "pod-namespace"
	TokenServerIdentityProviderConst    = "token-server-identity-provider"
	FileCacheMediumConst                = "file-cache-medium"
	EnableGCSFuseKernelParams           = "enable-gcsfuse-kernel-params"
	GCSFuseKernelParamsFileName         = "kernel-params.json"
	MediumRAM                           = "ram"
	MediumLSSD                          = "lssd"
	OptInHnw                            = "hnw-ksa"
	EnableCloudProfilerForSidecarConst  = "enable-cloud-profiler-for-sidecar"
	SidecarContainerTmpVolumeName       = "gke-gcsfuse-tmp"
	SidecarBucketAccessCheckErrorPrefix = "sidecar bucket access check error"
	StorageServiceErrorStr              = "failed to setup storage service"
	GCSFuseCsiDriverName                = "gcsfuse.csi.storage.gke.io"
	GCSFuseNumaNodeArg                  = "gcs-fuse-numa-node"
	GCSFuseAppNameArg                   = "app-name"
)
View Source
const (
	VolumeOperationAlreadyExistsFmt = "An operation with the given volume key %s already exists"
)

Variables

This section is empty.

Functions

func CheckAndDeleteStaleFile added in v1.14.4

func CheckAndDeleteStaleFile(dirPath, fileName string) error

func ConvertLabelsStringToMap

func ConvertLabelsStringToMap(labels string) (map[string]string, error)

ConvertLabelsStringToMap converts the labels from string to map example: "key1=value1,key2=value2" gets converted into {"key1": "value1", "key2": "value2"}

func FetchK8sTokenFromFile added in v1.19.0

func FetchK8sTokenFromFile(tokenPath string) (string, error)

func GetSocketBasePath added in v1.6.0

func GetSocketBasePath(targetPath, fuseSocketDir string) string

GetSocketBasePath constructs the base path for a Unix domain socket. It takes the target path and the directory where Fuse sockets are stored as input.

func GetZonesForALocation added in v1.21.0

func GetZonesForALocation(ctx context.Context, projectNumber string, computeService *compute.Service, location string) ([]string, error)

func IsGKEIdentityProvider added in v1.19.2

func IsGKEIdentityProvider(identityProvider string) bool

Returns true if the identity provider is a GKE identity provider in the format: https://container.googleapis.com/v1/projects/{project_id}/locations/{location}/clusters/{cluster_name}. Other GKE environments (staging, staging2, test, sandbox) are supported as well.

func MonitorKernelParamsFile added in v1.22.0

func MonitorKernelParamsFile(ctx context.Context, targetPath string, interval time.Duration)

MonitorKernelParamsFile monitors the kernel params file and continously enforces kernel parameter changes at regular interval as requested by GCSFuse.

func ParseBool added in v1.20.0

func ParseBool(str string) (bool, error)

func ParseEndpoint

func ParseEndpoint(endpoint string, cleanupSocket bool) (string, string, error)

func ParsePodIDVolumeFromTargetpath

func ParsePodIDVolumeFromTargetpath(targetPath string) (string, string, error)

func ParseVolumeID added in v1.19.0

func ParseVolumeID(bucketHandle string) string

The format allows customers to specify a fake volume handle for static provisioning, enabling multiple PVs in the same pod to mount the same bucket. This prevents Kubelet from skipping mounts of volumes with the same volume handle, which can cause the pod to be stuck in container creation.

func PrepareEmptyDir

func PrepareEmptyDir(targetPath string, createEmptyDir bool) (string, error)

func RecvMsg

func RecvMsg(via net.Conn) (int, []byte, error)

func SendMsg

func SendMsg(via net.Conn, fd int, msg []byte) error

Types

type GCSFuseKernelParamsMonitor added in v1.22.0

type GCSFuseKernelParamsMonitor struct {
	// StartKernelParamsFileMonitorOnce ensures the kernel params file monitor is started only once per volume (target path).
	StartKernelParamsFileMonitorOnce sync.Once
	// CancelFunc holds the cancel function for the kernel params file monitor goroutine which
	// is populated in NodePublishVolume operation and called in NodeUnpublishVolume operation.
	CancelFunc context.CancelFunc
}

GCSFuseKernelParamsMonitor holds the state for a goroutine that monitors the GCSFuse kernel parameters file.

type KernelParam added in v1.22.0

type KernelParam struct {
	Name  ParamName `json:"name"`
	Value string    `json:"value"`
}

KernelParam represents an individual parameter setting.

type KernelParamsConfig added in v1.22.0

type KernelParamsConfig struct {
	RequestID  string        `json:"request_id"`
	Timestamp  string        `json:"timestamp"` // Format: 2026-01-12T16:23:05.636831Z
	Parameters []KernelParam `json:"parameters"`
}

KernelParamsConfig acts as the primary container for kernel settings. Example Json config:

{
	  "request_id": "10c8148f-b26f-4ba4-9d09-e854311eb5d6",
	  "timestamp": "2026-02-04T02:26:45.622211445Z",
	  "parameters": [
	    {
	      "name": "max-read-ahead-kb",
	      "value": "16384"
	    },
	    {
	      "name": "fuse-congestion-window-threshold",
	      "value": "12"
	    },
	    {
	      "name": "fuse-max-background-requests",
	      "value": "16"
	    }
	  ]
}

type ParamName added in v1.22.0

type ParamName string

ParamName acts as an Enum for the parameter keys to ensure contract safety from typo errors.

const (
	MaxReadAheadKb            ParamName = "max-read-ahead-kb"
	MaxBackgroundRequests     ParamName = "fuse-max-background-requests"
	CongestionWindowThreshold ParamName = "fuse-congestion-window-threshold"
)

type VolumeLocks

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

func NewVolumeLocks() *VolumeLocks

func (*VolumeLocks) Release

func (vl *VolumeLocks) Release(volumeID string)

func (*VolumeLocks) TryAcquire

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.

type VolumeState added in v1.13.0

type VolumeState struct {
	BucketAccessCheckPassed   bool
	GCSFuseKernelMonitorState GCSFuseKernelParamsMonitor
}

type VolumeStateStore added in v1.13.0

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

VolumeStateStore provides a thread-safe map for storing volume states.

func NewVolumeStateStore added in v1.13.0

func NewVolumeStateStore() *VolumeStateStore

NewVolumeStateStore initializes the volume state store.

func (*VolumeStateStore) Delete added in v1.13.0

func (vss *VolumeStateStore) Delete(volumeID string)

Delete removes a volume from the store.

func (*VolumeStateStore) Load added in v1.13.0

func (vss *VolumeStateStore) Load(volumeID string) (*VolumeState, bool)

Load retrieves the state of a volume.

func (*VolumeStateStore) Size added in v1.13.0

func (vss *VolumeStateStore) Size() int32

NewVolumeStateStore initializes the volume state store.

func (*VolumeStateStore) Store added in v1.13.0

func (vss *VolumeStateStore) Store(volumeID string, state *VolumeState)

Store adds or updates a volume state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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