Skip to content

Commit

Permalink
Controller support for overlapping artifact path to user specified vo…
Browse files Browse the repository at this point in the history
…lume mountPaths
  • Loading branch information
jessesuen committed Nov 4, 2017
1 parent 3782bad commit b4d7770
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 95 deletions.
32 changes: 16 additions & 16 deletions api/workflow/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1
import (
"fmt"

corev1 "k8s.io/api/core/v1"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)
Expand Down Expand Up @@ -46,12 +46,12 @@ type WorkflowList struct {
}

type WorkflowSpec struct {
Templates []Template `json:"templates"`
Entrypoint string `json:"entrypoint"`
Arguments Arguments `json:"arguments,omitempty"`
Volumes []corev1.Volume `json:"volumes,omitempty"`
VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"`
Timeout string `json:"timeout,omitempty"`
Templates []Template `json:"templates"`
Entrypoint string `json:"entrypoint"`
Arguments Arguments `json:"arguments,omitempty"`
Volumes []apiv1.Volume `json:"volumes,omitempty"`
VolumeClaimTemplates []apiv1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"`
Timeout string `json:"timeout,omitempty"`
}

type Template struct {
Expand All @@ -63,7 +63,7 @@ type Template struct {
Steps []map[string]WorkflowStep `json:"steps,omitempty"`

// Container
Container *corev1.Container `json:"container,omitempty"`
Container *apiv1.Container `json:"container,omitempty"`

// Script
Script *Script `json:"script,omitempty"`
Expand Down Expand Up @@ -122,7 +122,7 @@ type Arguments struct {
type WorkflowStatus struct {
Tree NodeTree `json:"tree"`
Nodes map[string]NodeStatus `json:"nodes"`
PersistentVolumeClaims []corev1.Volume `json:"persistentVolumeClaims,omitempty"`
PersistentVolumeClaims []apiv1.Volume `json:"persistentVolumeClaims,omitempty"`
}

type NodeTree struct {
Expand Down Expand Up @@ -156,10 +156,10 @@ func (n NodeStatus) Successful() bool {
}

type S3Bucket struct {
Endpoint string `json:"endpoint"`
Bucket string `json:"bucket"`
AccessKeySecret corev1.SecretKeySelector `json:"accessKeySecret"`
SecretKeySecret corev1.SecretKeySelector `json:"secretKeySecret"`
Endpoint string `json:"endpoint"`
Bucket string `json:"bucket"`
AccessKeySecret apiv1.SecretKeySelector `json:"accessKeySecret"`
SecretKeySecret apiv1.SecretKeySelector `json:"secretKeySecret"`
}

type S3Artifact struct {
Expand All @@ -168,9 +168,9 @@ type S3Artifact struct {
}

type GitArtifact struct {
URL string `json:"url"`
UsernameSecret *corev1.SecretKeySelector `json:"usernameSecret"`
PasswordSecret *corev1.SecretKeySelector `json:"passwordSecret"`
URL string `json:"url"`
UsernameSecret *apiv1.SecretKeySelector `json:"usernameSecret"`
PasswordSecret *apiv1.SecretKeySelector `json:"passwordSecret"`
}

type HTTPArtifact struct {
Expand Down
4 changes: 0 additions & 4 deletions examples/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ spec:
- name: build
inputs:
artifacts:
# NOTE: we need to handle overlapping input artifacts with volume mounts.
# In the case where input artifacts are desired to be placed in a sub-directory
# of a volume mount, the executor should place the artifact in the volume, as
# opposed to the artifacts volume
- name: CODE
path: /go/src/github.com/golang/example
git:
Expand Down
26 changes: 26 additions & 0 deletions workflow/common/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package common

import (
"strings"

wfv1 "github.com/argoproj/argo/api/workflow/v1"
apiv1 "k8s.io/api/core/v1"
)

// FindOverlappingVolume looks an artifact path, checks if it overlaps with any
// user specified volumeMounts in the template, and returns the deepest volumeMount
// (if any).
func FindOverlappingVolume(tmpl *wfv1.Template, path string) *apiv1.VolumeMount {
var volMnt *apiv1.VolumeMount
deepestLen := 0
for _, mnt := range tmpl.Container.VolumeMounts {
if !strings.HasPrefix(path, mnt.MountPath) {
continue
}
if len(mnt.MountPath) > deepestLen {
volMnt = &mnt
deepestLen = len(mnt.MountPath)
}
}
return volMnt
}
Loading

0 comments on commit b4d7770

Please sign in to comment.