Skip to content

Commit

Permalink
add running state to job gates (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz authored Mar 25, 2024
1 parent 80bcab4 commit 28612f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/orcaman/concurrent-map/v2 v2.0.1
github.com/osteele/liquid v1.3.2
github.com/pkg/errors v0.9.1
github.com/pluralsh/console-client-go v0.1.0
github.com/pluralsh/console-client-go v0.1.8
github.com/pluralsh/controller-reconcile-helper v0.0.4
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34
github.com/pluralsh/polly v0.1.6
Expand All @@ -31,6 +31,7 @@ require (
golang.org/x/net v0.18.0
helm.sh/helm/v3 v3.11.2
k8s.io/api v0.27.7
k8s.io/apiextensions-apiserver v0.27.7
k8s.io/apimachinery v0.27.7
k8s.io/cli-runtime v0.26.0
k8s.io/client-go v0.27.7
Expand Down Expand Up @@ -197,7 +198,6 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.27.7 // indirect
k8s.io/apiserver v0.27.7 // indirect
k8s.io/component-base v0.27.7 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
github.com/pluralsh/console-client-go v0.1.0 h1:Nvu1ch2Q5X0UqndUaCuTC6lL/yzm7ANjKB0xejsNS9I=
github.com/pluralsh/console-client-go v0.1.0/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
github.com/pluralsh/console-client-go v0.1.8 h1:/MLVzacjCuqbb8bGsZornvya7ubMt2jeNM0dxPJduQU=
github.com/pluralsh/console-client-go v0.1.8/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E=
github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s=
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34 h1:ab2PN+6if/Aq3/sJM0AVdy1SYuMAnq4g20VaKhTm/Bw=
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/pipelinegate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ func (r *PipelineGateReconciler) reconcilePendingGate(ctx context.Context, gate
job := generateJob(*jobSpec, jobRef)

gate.Spec.GateSpec.JobSpec = lo.ToPtr(job.Spec)
// create or get existing job
reconciledJob, err := Job(ctx, r.Client, job, log)
if err != nil {
log.Error(err, "Error reconciling Job.", "JobName", job.Name, "JobNamespace", job.Namespace)
return ctrl.Result{}, err
}
gate.Status.SetState(console.GateStateRunning)

if !gate.Status.HasJobRef() {
log.V(2).Info("Gate doesn't have a JobRef, this is a new gate or a re-run.", "Name", gate.Name, "ID", gate.Spec.ID, "State", *gate.Status.State)
Expand All @@ -165,8 +167,6 @@ func (r *PipelineGateReconciler) reconcilePendingGate(ctx context.Context, gate
log.Error(err, "Error setting ControllerReference for Job.")
return ctrl.Result{}, err
}

gate.Status.SetState(console.GateStatePending)
gate.Status.JobRef = lo.ToPtr(jobRef)
return ctrl.Result{}, nil
}
Expand Down

0 comments on commit 28612f2

Please sign in to comment.