Skip to content

Commit

Permalink
Add support for pvcs to apiserver (#1118)
Browse files Browse the repository at this point in the history
Signed-off-by: Paul S. Schweigert <[email protected]>
  • Loading branch information
psschwei authored Jun 6, 2023
1 parent 35fe6f9 commit 2de3fe5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apiserver/pkg/util/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,18 @@ func buildVols(apiVolumes []*api.Volume) []v1.Volume {
}
vols = append(vols, vol)
}
// TODO(Jeffwan@): handle PVC in the future
if rayVol.VolumeType == api.Volume_PERSISTENT_VOLUME_CLAIM {
vol := v1.Volume{
Name: rayVol.Name,
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: rayVol.Name,
ReadOnly: rayVol.ReadOnly,
},
},
}
vols = append(vols, vol)
}
}

return vols
Expand Down
32 changes: 32 additions & 0 deletions apiserver/pkg/util/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ var testFileVolume = &api.Volume{
ReadOnly: true,
}

var testPVCVolume = &api.Volume{
Name: "test-pvc",
VolumeType: api.Volume_PERSISTENT_VOLUME_CLAIM,
MountPath: "/pvc/dir",
ReadOnly: true,
}

// Spec for testing
var headGroup = api.HeadGroupSpec{
ComputeTemplate: "foo",
Expand Down Expand Up @@ -113,6 +120,16 @@ func TestBuildVolumes(t *testing.T) {
},
},
}

targetPVCVolume := v1.Volume{
Name: testPVCVolume.Name,
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: testPVCVolume.Name,
ReadOnly: testPVCVolume.ReadOnly,
},
},
}
tests := []struct {
name string
apiVolume []*api.Volume
Expand All @@ -125,6 +142,11 @@ func TestBuildVolumes(t *testing.T) {
},
[]v1.Volume{targetVolume, targetFileVolume},
},
{
"pvc test",
[]*api.Volume{testPVCVolume},
[]v1.Volume{targetPVCVolume},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -149,6 +171,11 @@ func TestBuildVolumeMounts(t *testing.T) {
MountPath: testFileVolume.MountPath,
MountPropagation: &hostToContainer,
}
targetPVCVolumeMount := v1.VolumeMount{
Name: testPVCVolume.Name,
ReadOnly: testPVCVolume.ReadOnly,
MountPath: testPVCVolume.MountPath,
}
tests := []struct {
name string
apiVolume []*api.Volume
Expand All @@ -165,6 +192,11 @@ func TestBuildVolumeMounts(t *testing.T) {
targetFileVolumeMount,
},
},
{
"pvc test",
[]*api.Volume{testPVCVolume},
[]v1.VolumeMount{targetPVCVolumeMount},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 2de3fe5

Please sign in to comment.