Skip to content

Commit

Permalink
fix: config host path
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaansehgal99 committed Apr 4, 2024
1 parent 340a155 commit 5652d19
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
7 changes: 4 additions & 3 deletions pkg/tuning/preset-tuning.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func handleImageDataSource(ctx context.Context, workspaceObj *kaitov1alpha1.Work
},
})

volumes, volumeMounts := utils.ConfigDataVolume()
volumes, volumeMounts := utils.ConfigDataVolume("")
return initContainers, volumes, volumeMounts
}

Expand All @@ -153,13 +153,14 @@ func handleURLDataSource(ctx context.Context, workspaceObj *kaitov1alpha1.Worksp
},
},
})
volumes, volumeMounts := utils.ConfigDataVolume()
volumes, volumeMounts := utils.ConfigDataVolume("")
return initContainers, volumes, volumeMounts
}

func handleHostPathDataSource(ctx context.Context, workspaceObj *kaitov1alpha1.Workspace) ([]corev1.Container, []corev1.Volume, []corev1.VolumeMount) {
var initContainers []corev1.Container
volumes, volumeMounts := utils.ConfigDataVolume()
hostPath := workspaceObj.Tuning.Input.HostPath
volumes, volumeMounts := utils.ConfigDataVolume(hostPath)
return initContainers, volumes, volumeMounts
}

Expand Down
20 changes: 15 additions & 5 deletions pkg/utils/common-preset.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,24 @@ func ConfigSHMVolume(wObj *kaitov1alpha1.Workspace) (corev1.Volume, corev1.Volum
return volume, volumeMount
}

func ConfigDataVolume() ([]corev1.Volume, []corev1.VolumeMount) {
func ConfigDataVolume(hostPath string) ([]corev1.Volume, []corev1.VolumeMount) {
var volumes []corev1.Volume
var volumeMounts []corev1.VolumeMount
volumes = append(volumes, corev1.Volume{
Name: "data-volume",
VolumeSource: corev1.VolumeSource{
var volumeSource corev1.VolumeSource
if hostPath != "" {
volumeSource = corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: hostPath,
},
}
} else {
volumeSource = corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
}
}
volumes = append(volumes, corev1.Volume{
Name: "data-volume",
VolumeSource: volumeSource,
})

volumeMounts = append(volumeMounts, corev1.VolumeMount{
Expand Down

0 comments on commit 5652d19

Please sign in to comment.