Documentation
¶
Index ¶
- Constants
- Variables
- func ApplySysfsConfig(targetMountPath string, sysfsBDI map[string]int64, mountOptions []string, ...)
- func CeilDiv64(a, b int64) int64
- func CheckAndDeleteStaleFile(dirPath, fileName string) error
- func CheckForKernelReader(options []string) bool
- func CheckNotSymlink(path string) error
- func ConvertLabelsStringToMap(labels string) (map[string]string, error)
- func FetchK8sTokenFromFile(tokenPath string) (string, error)
- func FuseMaxMaxPagesUpdateSupported() bool
- func GetCloudProfilerServiceVersion(podName, podUID string) string
- func GetSocketBasePath(podUID, volumeName, fuseSocketDir string) string
- func GetZonesForALocation(ctx context.Context, projectNumber string, computeService *compute.Service, ...) ([]string, error)
- func IsDirMounted(targetPath string) (bool, error)
- func IsGKEIdentityProvider(identityProvider string) bool
- func MonitorKernelParamsFile(ctx context.Context, mountPoint, emptyDirBasePath, logPrefix string, ...)
- func MountUsingElevatedFuseMaxPagesLimit(targetLimit int64, logPrefix string, fn func() error) error
- func ParseBool(str string) (bool, error)
- func ParseEndpoint(endpoint string, cleanupSocket bool) (string, string, error)
- func ParsePodIDVolumeFromTargetpath(targetPath string) (string, string, error)
- func ParseVolumeID(bucketHandle string) string
- func PrepareEmptyDir(targetPath string, createEmptyDir bool) (string, error)
- func PrepareSharedMountOptions(options []string) ([]string, map[string]int64, int64, error)
- func PrepareSidecarMountOptions(options []string) ([]string, []string, map[string]int64, int64, error)
- func ReadFuseMaxPagesLimit() (int64, error)
- func RecvMsg(via net.Conn) (int, []byte, error)
- func SendMsg(via net.Conn, fd int, msg []byte) error
- func SetFuseMaxPagesLimit(target int64) error
- func WaitForPathMounted(ctx context.Context, path string) error
- type GCSFuseKernelParamsMonitor
- type KernelParam
- type KernelParamsConfig
- type ParamName
- type VolumeLocks
- type VolumeState
- type VolumeStateStore
- func (vss *VolumeStateStore) Delete(volumeID string)
- func (vss *VolumeStateStore) Load(volumeID string) (*VolumeState, bool)
- func (vss *VolumeStateStore) LoadOrStore(volumeID string, state *VolumeState) (*VolumeState, bool)
- func (vss *VolumeStateStore) Size() int32
- func (vss *VolumeStateStore) Store(volumeID string, state *VolumeState)
Constants ¶
const ( KiB = 1024 MiB = 1024 * KiB 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" PodNameConst = "pod-name" PodUIDConst = "pod-uid" TokenServerIdentityProviderConst = "token-server-identity-provider" FileCacheMediumConst = "file-cache-medium" EnableGCSFuseKernelParams = "enable-gcsfuse-kernel-params" GCSFuseKernelParamsFileName = "kernel-params.json" ErrorFileName = "error" MediumRAM = "ram" MediumLSSD = "lssd" OptInHnw = "hnw-ksa" EnableCloudProfilerForSidecarConst = "enable-cloud-profiler-for-sidecar" EnableCloudProfilerConst = "enable-cloud-profiler" 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" CustomEndpointConfigFileFlag = "gcs-connection:custom-endpoint" CustomEndpointCLIFlag = "custom-endpoint" EnableAutoGoMemLimitConst = "enable-auto-gomemlimit" AutoGoMemLimitRatioConst = "auto-gomemlimit-ratio" GoMemLimitCgroupPercentage = 0.95 StorageEndpointInternal = "storage-endpoint-internal" KubeletDir = "/var/lib/kubelet" KubeletPluginsGCSFuseDir = "/var/lib/kubelet/plugins/kubernetes.io/csi/gcsfuse.csi.storage.gke.io" VolumeContextKeyPVName = "csi.storage.k8s.io/pv/name" MounterPodNamePrefix = "gcsfusecsi-mount" SidecarImageConfigMapName = "gcsfusecsi-image-config" SidecarImageConfigMapKey = "sidecar-image" )
const (
VolumeOperationAlreadyExistsFmt = "An operation with the given volume key %s already exists"
)
Variables ¶
var (
// ProcSysFsFuseMaxPagesLimitPath is the host FUSE max_pages_limit path (overridable for unit testing).
ProcSysFsFuseMaxPagesLimitPath = "/host-proc-sys-fs-fuse/max_pages_limit"
)
Functions ¶
func ApplySysfsConfig ¶ added in v1.24.0
func CeilDiv64 ¶ added in v1.23.33
CeilDiv64 performs integer division of 'a' by 'b', rounding the result up.
func CheckAndDeleteStaleFile ¶ added in v1.14.4
func CheckForKernelReader ¶ added in v1.24.0
CheckForKernelReader returns true if kernel reader is enabled in mount options.
func CheckNotSymlink ¶ added in v1.21.29
CheckNotSymlink verifies that the given path is not a symbolic link. This is used to prevent TOCTOU symlink takeover attacks.
func ConvertLabelsStringToMap ¶
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 FuseMaxMaxPagesUpdateSupported ¶ added in v1.23.33
func FuseMaxMaxPagesUpdateSupported() bool
FuseMaxMaxPagesUpdateSupported returns true if the host supports FUSE max_pages_limit tuning.
func GetCloudProfilerServiceVersion ¶ added in v1.23.5
GetCloudProfilerServiceVersion returns the service version for Cloud Profiler. It returns the provided podName and podUID joined by an underscore. If both podName and podUID are empty, it returns an empty string.
func GetSocketBasePath ¶ added in v1.6.0
GetSocketBasePath constructs the base path for a Unix domain socket. It takes the podUID, volumeName, and the directory where Fuse sockets are stored as input.
func GetZonesForALocation ¶ added in v1.21.0
func IsDirMounted ¶ added in v1.24.0
IsDirMounted checks if the path is already a mount point.
func IsGKEIdentityProvider ¶ added in v1.19.2
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, mountPoint, emptyDirBasePath, logPrefix string, interval time.Duration)
MonitorKernelParamsFile monitors the kernel params file and continously enforces kernel parameter changes at regular interval as requested by GCSFuse.
func MountUsingElevatedFuseMaxPagesLimit ¶ added in v1.23.33
func MountUsingElevatedFuseMaxPagesLimit(targetLimit int64, logPrefix string, fn func() error) error
MountUsingElevatedFuseMaxPagesLimit temporarily increases the host's FUSE max_pages_limit if the current limit is lower, executes the provided function, and then restores the original limit.
func ParseEndpoint ¶
func ParseVolumeID ¶ added in v1.19.0
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 PrepareSharedMountOptions ¶ added in v1.24.0
PrepareSharedMountOptions prepares mount options specifically for shared node mount architecture. It returns gcsfuseMO, sysfsBDI, fuseMaxPagesLimit, and error.
func PrepareSidecarMountOptions ¶ added in v1.24.0
func PrepareSidecarMountOptions(options []string) ([]string, []string, map[string]int64, int64, error)
PrepareSidecarMountOptions prepares mount options specifically for sidecar mounter.
func ReadFuseMaxPagesLimit ¶ added in v1.23.33
ReadFuseMaxPagesLimit reads the host's current FUSE max_pages_limit.
func SetFuseMaxPagesLimit ¶ added in v1.23.33
SetFuseMaxPagesLimit writes the target limit to the host's FUSE max_pages_limit file.
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
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.
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
VolumeName string
MounterPodUID string
}
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) LoadOrStore ¶ added in v1.24.0
func (vss *VolumeStateStore) LoadOrStore(volumeID string, state *VolumeState) (*VolumeState, bool)
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
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.