Skip to content
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

engine/engine_impl.go: Add a mutex around pod image updates for step progress. #26

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -28,10 +28,10 @@ import (
)

var backoff = wait.Backoff{
Steps: 5,
Steps: 15,
Duration: 500 * time.Millisecond,
Factor: 1.0,
Jitter: 0.1,
Jitter: 0.5,
}

// Kubernetes implements a Kubernetes pipeline engine.
@@ -246,6 +246,12 @@ func (k *Kubernetes) tail(ctx context.Context, spec *Spec, step *Step, output io

func (k *Kubernetes) start(spec *Spec, step *Step) error {
err := retry.RetryOnConflict(backoff, func() error {
// We protect this read/modify/write with a mutex to reduce the
// chance of a self-inflicted concurrent modification error
// when a DAG in a pipeline is fanning out and we have a lot of
// steps to Start at once.
spec.podUpdateMutex.Lock()
defer spec.podUpdateMutex.Unlock()
pod, err := k.client.CoreV1().Pods(spec.PodSpec.Namespace).Get(spec.PodSpec.Name, metav1.GetOptions{})
if err != nil {
return err
@@ -4,6 +4,10 @@

package engine

import (
"sync"
)

type (
// Spec provides the pipeline spec. This provides the
// required instructions for reproducible pipeline
@@ -15,6 +19,10 @@ type (
Volumes []*Volume `json:"volumes,omitempty"`
Secrets map[string]*Secret `json:"secrets,omitempty"`
PullSecret *Secret `json:"pull_secrets,omitempty"`
// Runtime field to gate updating of the pod that this pipeline
// is running on. Helps to avoid self-inflicted 409 Conflict
// responses from the kubernetes api server.
podUpdateMutex sync.Mutex
}

// Step defines a pipeline step.