Skip to content

Commit 28612f2

Browse files
authored
add running state to job gates (#150)
1 parent 80bcab4 commit 28612f2

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/orcaman/concurrent-map/v2 v2.0.1
1818
github.com/osteele/liquid v1.3.2
1919
github.com/pkg/errors v0.9.1
20-
github.com/pluralsh/console-client-go v0.1.0
20+
github.com/pluralsh/console-client-go v0.1.8
2121
github.com/pluralsh/controller-reconcile-helper v0.0.4
2222
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34
2323
github.com/pluralsh/polly v0.1.6
@@ -31,6 +31,7 @@ require (
3131
golang.org/x/net v0.18.0
3232
helm.sh/helm/v3 v3.11.2
3333
k8s.io/api v0.27.7
34+
k8s.io/apiextensions-apiserver v0.27.7
3435
k8s.io/apimachinery v0.27.7
3536
k8s.io/cli-runtime v0.26.0
3637
k8s.io/client-go v0.27.7
@@ -197,7 +198,6 @@ require (
197198
gopkg.in/ini.v1 v1.67.0 // indirect
198199
gopkg.in/yaml.v2 v2.4.0 // indirect
199200
gopkg.in/yaml.v3 v3.0.1 // indirect
200-
k8s.io/apiextensions-apiserver v0.27.7 // indirect
201201
k8s.io/apiserver v0.27.7 // indirect
202202
k8s.io/component-base v0.27.7 // indirect
203203
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
581581
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
582582
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
583583
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
584-
github.com/pluralsh/console-client-go v0.1.0 h1:Nvu1ch2Q5X0UqndUaCuTC6lL/yzm7ANjKB0xejsNS9I=
585-
github.com/pluralsh/console-client-go v0.1.0/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
584+
github.com/pluralsh/console-client-go v0.1.8 h1:/MLVzacjCuqbb8bGsZornvya7ubMt2jeNM0dxPJduQU=
585+
github.com/pluralsh/console-client-go v0.1.8/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
586586
github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E=
587587
github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s=
588588
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34 h1:ab2PN+6if/Aq3/sJM0AVdy1SYuMAnq4g20VaKhTm/Bw=

internal/controller/pipelinegate_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ func (r *PipelineGateReconciler) reconcilePendingGate(ctx context.Context, gate
152152
job := generateJob(*jobSpec, jobRef)
153153

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

161163
if !gate.Status.HasJobRef() {
162164
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)
@@ -165,8 +167,6 @@ func (r *PipelineGateReconciler) reconcilePendingGate(ctx context.Context, gate
165167
log.Error(err, "Error setting ControllerReference for Job.")
166168
return ctrl.Result{}, err
167169
}
168-
169-
gate.Status.SetState(console.GateStatePending)
170170
gate.Status.JobRef = lo.ToPtr(jobRef)
171171
return ctrl.Result{}, nil
172172
}

0 commit comments

Comments
 (0)