Skip to content

Commit

Permalink
more projections
Browse files Browse the repository at this point in the history
  • Loading branch information
webconn committed Feb 28, 2025
1 parent 04872e8 commit 820e816
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 77 deletions.
52 changes: 25 additions & 27 deletions internal/consts/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const (
)

const (
SlurmdbdConfFile = "slurmdbd.conf"

VolumeNameSlurmConfigs = slurmConfigs
VolumeNameSlurmTopologyConfig = slurmTopologyConfig
VolumeNameSlurmdbdSecret = slurmdbdSecret
VolumeNameSpool = spool
VolumeNameJail = jail
VolumeNameJailSnapshot = jail + "-snapshot"
Expand All @@ -50,29 +50,27 @@ const (
VolumeNameInMemorySubmount = "in-memory"
VolumeNameTmpDisk = "tmp-disk"

VolumeMountPathSlurmConfigs = "/mnt/" + slurmConfigs
VolumeMountPathSlurmTopologyConfig = "/mnt/" + slurmConfigs // intended to overlay original config
VolumeMountPathSlurmdbdSecret = "/mnt/" + slurmdbdSecret
VolumeMountPathSpool = "/var/" + spool
VolumeMountPathSpoolSlurmdbd = "/var/spool/slurmdbd"
VolumeMountPathJail = "/mnt/" + jail
VolumeMountPathJailSnapshot = "/jail"
VolumeMountPathJailUpper = "/mnt/" + jail + ".upper"
VolumeMountPathMungeSocket = "/run/" + Munge
VolumeMountPathMungeKey = "/mnt/" + mungeKey
VolumeMountPathRESTJWTKey = "/mnt/" + RESTJWTKey
VolumeMountPathNvidia = "/run/" + nvidia
VolumeMountPathBoot = "/" + boot
VolumeMountPathSSHConfigs = "/mnt/" + sshConfigs
VolumeMountPathSSHRootKeys = "/root/.ssh/" + authorizedKeys
VolumeMountSubPathSSHRootKeys = authorizedKeys
VolumeMountPathSecurityLimits = "/etc/security/" + securityLimitsConfFile
VolumeMountSubPathSecurityLimits = securityLimitsConfFile
VolumeMountPathNCCLTopology = "/run/nvidia-topologyd"
VolumeMountPathSharedMemory = "/dev/shm"
VolumeMountPathSysctl = "/etc/" + sysctlConfFile
VolumeMountSubPathSysctl = sysctlConfFile
VolumeMountPathSupervisordConfig = "/etc/supervisor/conf.d/"
VolumeMountPathInMemorySubmount = VolumeMountPathJailUpper + "/mnt/memory"
VolumeMountPathTmpDisk = "/tmp"
VolumeMountPathSlurmConfigs = "/mnt/" + slurmConfigs
VolumeMountPathSpool = "/var/" + spool
VolumeMountPathSpoolSlurmdbd = "/var/spool/slurmdbd"
VolumeMountPathJail = "/mnt/" + jail
VolumeMountPathJailSnapshot = "/jail"
VolumeMountPathJailUpper = "/mnt/" + jail + ".upper"
VolumeMountPathMungeSocket = "/run/" + Munge
VolumeMountPathMungeKey = "/mnt/" + mungeKey
VolumeMountPathRESTJWTKey = "/mnt/" + RESTJWTKey
VolumeMountPathNvidia = "/run/" + nvidia
VolumeMountPathBoot = "/" + boot
VolumeMountPathSSHConfigs = "/mnt/" + sshConfigs
VolumeMountPathSSHRootKeys = "/root/.ssh/" + authorizedKeys
VolumeMountSubPathSSHRootKeys = authorizedKeys
VolumeMountPathSecurityLimits = "/etc/security/" + securityLimitsConfFile
VolumeMountSubPathSecurityLimits = securityLimitsConfFile
VolumeMountPathNCCLTopology = "/run/nvidia-topologyd"
VolumeMountPathSharedMemory = "/dev/shm"
VolumeMountPathSysctl = "/etc/" + sysctlConfFile
VolumeMountSubPathSysctl = sysctlConfFile
VolumeMountPathSupervisordConfig = "/etc/supervisor/conf.d/"
VolumeMountPathInMemorySubmount = VolumeMountPathJailUpper + "/mnt/memory"
VolumeMountPathTmpDisk = "/tmp"
)
1 change: 0 additions & 1 deletion internal/render/accounting/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func renderContainerAccounting(container values.Container) corev1.Container {
common.RenderVolumeMountSlurmConfigs(),
common.RenderVolumeMountMungeSocket(),
common.RenderVolumeMountRESTJWTKey(),
RenderVolumeMountSlurmdbdConfigs(),
RenderVolumeMountSlurmdbdSpool(),
},
ReadinessProbe: &corev1.Probe{
Expand Down
7 changes: 5 additions & 2 deletions internal/render/accounting/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ func BasePodTemplateSpec(
) (*corev1.PodTemplateSpec, error) {
volumes := []corev1.Volume{
common.RenderVolumeJailFromSource(volumeSources, *accounting.VolumeJail.VolumeSourceName),
common.RenderVolumeProjectedSlurmConfigs(clusterName, slurmTopologyConfigMapRefName),
common.RenderVolumeProjectedSlurmConfigs(
clusterName,
common.RenderVolumeProjectionSlurmTopologyConfig(slurmTopologyConfigMapRefName),
RenderVolumeProjecitonSlurmdbdConfigs(clusterName),
),
common.RenderVolumeMungeKey(clusterName),
common.RenderVolumeRESTJWTKey(clusterName),
common.RenderVolumeMungeSocket(),
RenderVolumeSlurmdbdConfigs(clusterName),
RenderVolumeSlurmdbdSpool(accounting),
}

Expand Down
28 changes: 12 additions & 16 deletions internal/render/accounting/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@ import (
"nebius.ai/slurm-operator/internal/values"
)

// RenderVolumeMountSlurmConfigs renders [corev1.VolumeMount] defining the mounting path for Slurm config files
func RenderVolumeMountSlurmdbdConfigs() corev1.VolumeMount {
return corev1.VolumeMount{
Name: consts.VolumeNameSlurmdbdSecret,
MountPath: consts.VolumeMountPathSlurmdbdSecret,
ReadOnly: true,
}
}

func RenderVolumeSlurmdbdConfigs(clusterName string) corev1.Volume {
return corev1.Volume{
Name: consts.VolumeNameSlurmdbdSecret,
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: naming.BuildSecretSlurmdbdConfigsName(clusterName),
DefaultMode: ptr.To(int32(0600)),
func RenderVolumeProjecitonSlurmdbdConfigs(clusterName string) corev1.VolumeProjection {
return corev1.VolumeProjection{
Secret: &corev1.SecretProjection{
LocalObjectReference: corev1.LocalObjectReference{
Name: naming.BuildSecretSlurmdbdConfigsName(clusterName),
},
Items: []corev1.KeyToPath{
{
Key: consts.SlurmdbdConfFile,
Path: consts.SlurmdbdConfFile,
Mode: ptr.To(int32(0600)),
},
},
},
}
Expand Down
16 changes: 1 addition & 15 deletions internal/render/accounting/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,10 @@ import (

slurmv1 "nebius.ai/slurm-operator/api/v1"
"nebius.ai/slurm-operator/internal/consts"
"nebius.ai/slurm-operator/internal/naming"
accounting "nebius.ai/slurm-operator/internal/render/accounting"
"nebius.ai/slurm-operator/internal/render/accounting"
"nebius.ai/slurm-operator/internal/values"
)

func Test_RenderVolumeSlurmdbdConfigs(t *testing.T) {
volume := accounting.RenderVolumeSlurmdbdConfigs(defaultNameCluster)
assert.Equal(t, consts.VolumeNameSlurmdbdSecret, volume.Name)
assert.Equal(t, naming.BuildSecretSlurmdbdConfigsName(defaultNameCluster), volume.VolumeSource.Secret.SecretName)
}

func Test_RenderVolumeMountSlurmdbdConfigs(t *testing.T) {
volumeMount := accounting.RenderVolumeMountSlurmdbdConfigs()
assert.Equal(t, consts.VolumeNameSlurmdbdSecret, volumeMount.Name)
assert.Equal(t, consts.VolumeMountPathSlurmdbdSecret, volumeMount.MountPath)
assert.True(t, volumeMount.ReadOnly)
}

func Test_RenderVolumeSlurmdbd(t *testing.T) {
sizeGi := resource.MustParse("1Gi")
testAcc := *acc
Expand Down
27 changes: 11 additions & 16 deletions internal/render/common/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func RenderVolumeMountSlurmConfigs() corev1.VolumeMount {
// region Slurm topology config

// RenderVolumeProjectedSlurmConfigs renders [corev1.Volume] containing Slurm common configs + topology config file
func RenderVolumeProjectedSlurmConfigs(clusterName string, slurmTopologyConfigMapRefName string) corev1.Volume {
func RenderVolumeProjectedSlurmConfigs(clusterName string, additionalProjections ...corev1.VolumeProjection) corev1.Volume {
sources := []corev1.VolumeProjection{
{
ConfigMap: &corev1.ConfigMapProjection{
Expand All @@ -96,15 +96,7 @@ func RenderVolumeProjectedSlurmConfigs(clusterName string, slurmTopologyConfigMa
},
},
}
if slurmTopologyConfigMapRefName != "" {
sources = append(sources, corev1.VolumeProjection{
ConfigMap: &corev1.ConfigMapProjection{
LocalObjectReference: corev1.LocalObjectReference{
Name: slurmTopologyConfigMapRefName,
},
},
})
}
sources = append(sources, additionalProjections...)
return corev1.Volume{
Name: consts.VolumeNameSlurmConfigs,
VolumeSource: corev1.VolumeSource{
Expand All @@ -115,12 +107,15 @@ func RenderVolumeProjectedSlurmConfigs(clusterName string, slurmTopologyConfigMa
}
}

// RenderVolumeMountSlurmTopologyConfig renders [corev1.VolumeMount] defining the mounting path for Slurm topology config path
func RenderVolumeMountSlurmTopologyConfig() corev1.VolumeMount {
return corev1.VolumeMount{
Name: consts.VolumeNameSlurmTopologyConfig,
MountPath: consts.VolumeMountPathSlurmConfigs, // intended to be the same as configs, it's a dedicated file
ReadOnly: true,
// RenderVolumeProjectionSlurmTopologyConfig renders [corev1.VolumeProjection]
// defining the configmap to overlay in /etc/slurm
func RenderVolumeProjectionSlurmTopologyConfig(slurmTopologyConfigMapRefName string) corev1.VolumeProjection {
return corev1.VolumeProjection{
ConfigMap: &corev1.ConfigMapProjection{
LocalObjectReference: corev1.LocalObjectReference{
Name: slurmTopologyConfigMapRefName,
},
},
}
}

Expand Down

0 comments on commit 820e816

Please sign in to comment.