-
Notifications
You must be signed in to change notification settings - Fork 554
fix: pvc mounted on pods for cache handling #2912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
163c47c
1493f1b
ae7a2e1
c060002
370f203
433f682
bee1026
9de2527
b3c0a2e
b1ee28f
5c37659
afbcbf4
df1c326
f343616
1b52200
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ package pipeline | |
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" | ||
| "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned" | ||
| v1alpha12 "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned/typed/workflow/v1alpha1" | ||
|
|
@@ -37,6 +38,7 @@ import ( | |
| "k8s.io/client-go/rest" | ||
| "net/url" | ||
| "strconv" | ||
| "strings" | ||
| ) | ||
|
|
||
| type WorkflowService interface { | ||
|
|
@@ -112,6 +114,9 @@ type WorkflowRequest struct { | |
| CiBuildDockerMtuValue int `json:"ciBuildDockerMtuValue"` | ||
| IgnoreDockerCachePush bool `json:"ignoreDockerCachePush"` | ||
| IgnoreDockerCachePull bool `json:"ignoreDockerCachePull"` | ||
| CacheInvalidate bool `json:"cacheInvalidate"` | ||
| IsPvcMounted bool `json:"IsPvcMounted"` | ||
| PvcCachePath string `json:"pvcCachePath"` | ||
|
||
| } | ||
|
|
||
| const ( | ||
|
|
@@ -122,6 +127,8 @@ const ( | |
| CI_WORKFLOW_NAME = "ci" | ||
| CI_WORKFLOW_WITH_STAGES = "ci-stages-with-env" | ||
| CI_NODE_SELECTOR_APP_LABEL_KEY = "devtron.ai/node-selector" | ||
| CI_NODE_PVC_ALL_ENV = "devtron.ai/ci-pvc-all" | ||
| CI_NODE_PVC_PIPELINE_PREFIX = "devtron.ai/ci-pvc" | ||
| ) | ||
|
|
||
| type ContainerResources struct { | ||
|
|
@@ -194,7 +201,18 @@ func (impl *WorkflowServiceImpl) SubmitWorkflow(workflowRequest *WorkflowRequest | |
| miniCred := []v12.EnvVar{{Name: "AWS_ACCESS_KEY_ID", Value: impl.ciConfig.BlobStorageS3AccessKey}, {Name: "AWS_SECRET_ACCESS_KEY", Value: impl.ciConfig.BlobStorageS3SecretKey}} | ||
| containerEnvVariables = append(containerEnvVariables, miniCred...) | ||
| } | ||
|
|
||
| pvc := appLabels[strings.ToLower(fmt.Sprintf("%s-%s", CI_NODE_PVC_PIPELINE_PREFIX, workflowRequest.PipelineName))] | ||
| if len(pvc) == 0 { | ||
| pvc = appLabels[CI_NODE_PVC_ALL_ENV] | ||
| } | ||
| if len(pvc) != 0 { | ||
| workflowRequest.IsPvcMounted = true | ||
| workflowRequest.IgnoreDockerCachePush = true | ||
| workflowRequest.IgnoreDockerCachePull = true | ||
| } | ||
| if impl.ciConfig.IgnoreDockerCacheForCI && workflowRequest.CacheInvalidate { | ||
| workflowRequest.IsPvcMounted = false | ||
|
||
| } | ||
| ciCdTriggerEvent := CiCdTriggerEvent{ | ||
| Type: ciEvent, | ||
| CiRequest: workflowRequest, | ||
|
|
@@ -543,6 +561,37 @@ func (impl *WorkflowServiceImpl) SubmitWorkflow(workflowRequest *WorkflowRequest | |
| } | ||
| } | ||
|
|
||
| // pvc mounting starts | ||
| if len(pvc) != 0 { | ||
| buildPvcCachePath := impl.ciConfig.BuildPvcCachePath | ||
| buildxPvcCachePath := impl.ciConfig.BuildxPvcCachePath | ||
| defaultPvcCachePath := impl.ciConfig.DefaultPvcCachePath | ||
|
|
||
| workflowRequest.PvcCachePath = buildPvcCachePath | ||
| ciTemplate.Volumes = append(ciTemplate.Volumes, v12.Volume{ | ||
| Name: "root-vol", | ||
| VolumeSource: v12.VolumeSource{ | ||
| PersistentVolumeClaim: &v12.PersistentVolumeClaimVolumeSource{ | ||
| ClaimName: pvc, | ||
| ReadOnly: false, | ||
| }, | ||
| }, | ||
| }) | ||
| ciTemplate.Container.VolumeMounts = append(ciTemplate.Container.VolumeMounts, | ||
| v12.VolumeMount{ | ||
| Name: "root-vol", | ||
| MountPath: buildPvcCachePath, | ||
| }, | ||
| v12.VolumeMount{ | ||
| Name: "root-vol", | ||
| MountPath: buildxPvcCachePath, | ||
| }, | ||
| v12.VolumeMount{ | ||
| Name: "root-vol", | ||
| MountPath: defaultPvcCachePath, | ||
| }) | ||
| } | ||
|
|
||
| // node selector | ||
| if val, ok := appLabels[CI_NODE_SELECTOR_APP_LABEL_KEY]; ok { | ||
| var nodeSelectors map[string]string | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename these Params, BUILD_PVC_CACHE_PATH, DEFAULT_PVC_CACHE_PATH, something related to intent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done