You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enableSidecarBucketAccessCheck=flag.Bool("enable-sidecar-bucket-access-check", false, "Enable bucket access check on sidecar, this does not disable bucket access check in node driver.")
71
72
enableCloudProfilerForDriver=flag.Bool("enable-cloud-profiler-for-driver", false, "Enable cloud profiler to collect analysis data.")
72
73
assumeGoodSidecarVersion=flag.Bool("assume-good-sidecar-version", false, "Assume the sidecar version is compatible with all features in the running version of the driver.")
74
+
enableAutoGoMemLimit=flag.Bool("enable-auto-gomemlimit", false, "Automatically set GOMEMLIMIT to a percentage of the container's cgroup memory limit.")
75
+
autoGoMemLimitRatio=flag.Float64("auto-gomemlimit-ratio", util.GoMemLimitCgroupPercentage, "The ratio of the container's cgroup memory limit to set as GOMEMLIMIT when enable-auto-gomemlimit is enabled.")
metadataSidecarImage=flag.String("metadata-sidecar-image", "", "The metadata prefetch sidecar container image.")
57
59
injectSAVol=flag.Bool("should-inject-sa-vol", false, "Inject projected service account volume when true")
58
60
enableGcsfuseProfiles=flag.Bool("enable-gcsfuse-profiles", false, "Enable gcsfuse profiles when true")
61
+
enableAutoGoMemLimit=flag.Bool("enable-auto-gomemlimit", false, "Automatically set GOMEMLIMIT to a percentage of the container's cgroup memory limit.")
62
+
autoGoMemLimitRatio=flag.Float64("auto-gomemlimit-ratio", util.GoMemLimitCgroupPercentage, "The ratio of the container's cgroup memory limit to set as GOMEMLIMIT when enable-auto-gomemlimit is enabled.")
59
63
metadataMemoryRequest=flag.String("metadata-sidecar-memory-request", "10Mi", "Flag to use default value for gcsfuse memory prefetch sidecar container memory request.")
60
64
metadataMemoryLimit=flag.String("metadata-sidecar-memory-limit", "10Mi", "Flag to use default value for gcsfuse memory prefetch sidecar container memory limit.")
61
65
metadataPrefetchCPURequest=flag.String("metadata-sidecar-cpu-request", "10m", "The default cpu request for gcsfuse memory prefetch sidecar container cpu request.")
@@ -78,6 +82,20 @@ func main() {
78
82
// This line prevents controller-runtime from complaining about log.SetLogger never being called
79
83
log.SetLogger(logr.New(log.NullLogSink{}))
80
84
85
+
if*enableAutoGoMemLimit {
86
+
// Sets GOMEMLIMIT to a percentage of the cgroup limit.
87
+
// If cgroup limits are unavailable, it falls back to doing nothing
88
+
// (no limit).
89
+
if_, err:=memlimit.SetGoMemLimitWithOpts(
90
+
memlimit.WithRatio(*autoGoMemLimitRatio),
91
+
memlimit.WithProvider(memlimit.FromCgroup),
92
+
); err!=nil {
93
+
// This can happen if the gcs-fuse-csi-driver-webhook container
94
+
// memory limit is not set.
95
+
klog.Warningf("Failed to automatically set GOMEMLIMIT: %v", err)
96
+
}
97
+
}
98
+
81
99
klog.Infof("Running Google Cloud Storage FUSE CSI driver admission webhook version %v, sidecar container image %v", webhookVersion, *sidecarImage)
0 commit comments