Skip to content

Commit 6e15a6f

Browse files
authored
fix build job's temporary storage access mode (#4281)
Signed-off-by: Patrick Zhao <[email protected]>
1 parent 6ec607d commit 6e15a6f

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

pkg/microservice/aslan/core/multicluster/service/clusters.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,14 +1400,19 @@ func CreateDynamicPVC(clusterID, prefix string, nfsProperties *types.NFSProperti
14001400
return fmt.Errorf("failed to parse storage size: %d. err: %s", nfsProperties.StorageSizeInGiB, err)
14011401
}
14021402

1403+
accessMode := []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany}
1404+
if nfsProperties.AccessMode != "" {
1405+
accessMode = []corev1.PersistentVolumeAccessMode{corev1.PersistentVolumeAccessMode(nfsProperties.AccessMode)}
1406+
}
1407+
14031408
pvc = &corev1.PersistentVolumeClaim{
14041409
ObjectMeta: metav1.ObjectMeta{
14051410
Name: pvcName,
14061411
Namespace: namespace,
14071412
},
14081413
Spec: corev1.PersistentVolumeClaimSpec{
14091414
StorageClassName: &nfsProperties.StorageClass,
1410-
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
1415+
AccessModes: accessMode,
14111416
VolumeMode: &filesystemVolume,
14121417
Resources: corev1.ResourceRequirements{
14131418
Requests: corev1.ResourceList{

pkg/microservice/aslan/core/workflow/service/workflow/controller/job/job_build.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"strings"
2424

2525
"go.uber.org/zap"
26+
corev1 "k8s.io/api/core/v1"
2627
"k8s.io/apimachinery/pkg/util/sets"
2728

2829
configbase "github.com/koderover/zadig/v2/pkg/config"
@@ -401,6 +402,7 @@ func (j BuildJobController) ToTask(taskID int64) ([]*commonmodels.JobTask, error
401402

402403
if buildInfo.PreBuild != nil && buildInfo.PreBuild.TemporaryStorage != nil && buildInfo.PreBuild.TemporaryStorage.Enabled {
403404
jobTaskSpec.Properties.TemporaryStorage = buildInfo.PreBuild.TemporaryStorage.NFSProperties
405+
jobTaskSpec.Properties.TemporaryStorage.AccessMode = string(corev1.ReadWriteOnce)
404406
}
405407

406408
paramEnvs := generateKeyValsFromWorkflowParam(j.workflow.Params)

pkg/types/cache.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type NFSProperties struct {
4545
StorageSizeInGiB int64 `json:"storage_size_in_gib" bson:"storage_size_in_gib" yaml:"storage_size_in_gib"`
4646
PVC string `json:"pvc" bson:"pvc" yaml:"pvc"`
4747
Subpath string `json:"subpath" bson:"subpath" yaml:"subpath"`
48+
AccessMode string `json:"access_mode" bson:"access_mode" yaml:"access_mode"`
4849
}
4950

5051
type Cache struct {

0 commit comments

Comments
 (0)