Skip to content

Commit 08de0ed

Browse files
Mount COS CSI socket directory instead of socket (#66)
* Mount COS CSI socket directory instead of socket Signed-off-by: Mayank Sachan <[email protected]> * Set COS_CSI_MOUNTER_SOCKET env for csi node server container Signed-off-by: Mayank Sachan <[email protected]> --------- Signed-off-by: Mayank Sachan <[email protected]> Co-authored-by: Ashima <[email protected]>
1 parent 7649d23 commit 08de0ed

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

controllers/constants/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const (
4747
ControllerSocketPath = "/var/lib/csi/sockets/pluginproxy/csi.sock"
4848
NodeSocketPath = "/csi/csi.sock"
4949
NodeRegistrarSocketPath = "/var/lib/kubelet/plugins/cos.s3.csi.ibm.io/csi.sock"
50+
COSCSIMounterSocketPath = "/var/lib/coscsi-sock/coscsi.sock"
5051
CSIEndpoint = "unix:///var/lib/csi/sockets/pluginproxy/csi.sock"
5152
CSINodeEndpoint = "unix:///csi/csi.sock"
5253
RegistrationVolumeMountPath = "/registration"

controllers/syncer/csi_node.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,7 @@ func (s *csiNodeSyncer) ensureContainersSpec() []corev1.Container {
173173
healthPortArg,
174174
},
175175
)
176-
// livenessprobe sidecar container inherits securityContext defined at NodeServer pod level
177-
if livenessProbe.SecurityContext == nil {
178-
livenessProbe.SecurityContext = &corev1.SecurityContext{}
179-
}
176+
180177
fillSecurityContextCapabilities(livenessProbe.SecurityContext)
181178
livenessProbe.ImagePullPolicy = s.getCSINodeDriverRegistrarPullPolicy()
182179
livenessProbe.Resources = getSidecarResourceRequests(s.driver, constants.LivenessProbe)
@@ -219,6 +216,10 @@ func (s *csiNodeSyncer) getEnvFor(name string) []corev1.EnvVar {
219216
Name: "CSI_ENDPOINT",
220217
Value: constants.CSINodeEndpoint,
221218
},
219+
{
220+
Name: "COS_CSI_MOUNTER_SOCKET",
221+
Value: constants.COSCSIMounterSocketPath,
222+
},
222223
envVarFromField("KUBE_NODE_NAME", "spec.nodeName"),
223224
}
224225

@@ -270,13 +271,12 @@ func (s *csiNodeSyncer) getVolumeMountsFor(name string) []corev1.VolumeMount {
270271
MountPath: "/host/var/log",
271272
},
272273
{
273-
Name: "coscsi-socket",
274-
MountPath: "/var/lib/coscsi.sock",
275-
ReadOnly: false,
274+
Name: "coscsi-socket-path",
275+
MountPath: "/var/lib/coscsi-sock",
276276
},
277277
{
278-
Name: "coscsi-mounter-config",
279-
MountPath: "/var/lib/cos-csi",
278+
Name: "coscsi-mounter-config-path",
279+
MountPath: "/var/lib/coscsi-config",
280280
},
281281
}
282282

@@ -312,8 +312,8 @@ func (s *csiNodeSyncer) ensureVolumes() []corev1.Volume {
312312
ensureVolume("fuse-device", ensureHostPathVolumeSource("/dev/fuse", "")),
313313
ensureVolume("log-dev", ensureHostPathVolumeSource("/dev/log", "")),
314314
ensureVolume("host-log", ensureHostPathVolumeSource("/var/log", "")),
315-
ensureVolume("coscsi-socket", ensureHostPathVolumeSource("/var/lib/coscsi.sock", "Socket")),
316-
ensureVolume("coscsi-mounter-config", ensureHostPathVolumeSource("/var/lib/cos-csi", "DirectoryOrCreate")),
315+
ensureVolume("coscsi-socket-path", ensureHostPathVolumeSource("/var/lib/coscsi-sock", "Directory")),
316+
ensureVolume("coscsi-mounter-config-path", ensureHostPathVolumeSource("/var/lib/coscsi-config", "DirectoryOrCreate")),
317317
}
318318
}
319319

@@ -357,6 +357,9 @@ func ensureHostPathVolumeSource(path, pathType string) corev1.VolumeSource {
357357
}
358358

359359
func fillSecurityContextCapabilities(sc *corev1.SecurityContext, add ...string) {
360+
if sc == nil {
361+
sc = &corev1.SecurityContext{}
362+
}
360363
sc.Capabilities = &corev1.Capabilities{
361364
Drop: []corev1.Capability{"ALL"},
362365
}

0 commit comments

Comments
 (0)