Skip to content

Commit ded8f1d

Browse files
authored
CR-14419-add-cluster-logs (#559)
* show logs + return error * bump * updated version to 0.0.502
1 parent c42a06f commit ded8f1d

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.501
1+
VERSION=v0.0.502
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.501/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.502/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.501/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.502/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

manifests/runtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: "{{ namespace }}"
66
spec:
77
defVersion: 1.0.1
8-
version: 0.0.501
8+
version: 0.0.502
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

pkg/util/kube/kube.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ func GetClusterSecret(ctx context.Context, kubeFactory kube.Factory, namespace s
218218

219219
func WaitForJob(ctx context.Context, f kube.Factory, ns, jobName string) error {
220220
var attempt int32
221-
return f.Wait(ctx, &kube.WaitOptions{
222-
Interval: time.Second * 10,
223-
Timeout: time.Minute * 11, // BackOffLimit of 6 is a total of 630s, or 10m30s
221+
var jobErr error
222+
_ = f.Wait(ctx, &kube.WaitOptions{
223+
Interval: time.Second * 5,
224+
Timeout: time.Minute,
224225
Resources: []kube.Resource{
225226
{
226227
Name: jobName,
@@ -236,28 +237,30 @@ func WaitForJob(ctx context.Context, f kube.Factory, ns, jobName string) error {
236237
return false, err
237238
}
238239

240+
totalRetries := *j.Spec.BackoffLimit + 1
239241
if j.Status.Failed > attempt {
240242
attempt = j.Status.Failed
241-
log.G(ctx).Warnf("Attempt #%d/%d failed:", attempt, *j.Spec.BackoffLimit)
243+
log.G(ctx).Warnf("Attempt #%d/%d failed:", attempt, totalRetries)
242244
printJobLogs(ctx, cs, j)
243245
} else if j.Status.Succeeded == 1 {
244246
attempt += 1
245-
log.G(ctx).Infof("Attempt #%d/%d succeeded:", attempt, *j.Spec.BackoffLimit)
247+
log.G(ctx).Infof("Attempt #%d/%d succeeded:", attempt, totalRetries)
246248
printJobLogs(ctx, cs, j)
247249
}
248250

249251
for _, cond := range j.Status.Conditions {
250252
if cond.Type == batchv1.JobFailed {
251-
err = fmt.Errorf("add-cluster-job failed after %d attempts", j.Status.Failed)
253+
jobErr = fmt.Errorf("add-cluster-job failed after %d attempt(s)", j.Status.Failed)
252254
break
253255
}
254256
}
255257

256-
return j.Status.Succeeded == 1 || j.Status.Failed == *j.Spec.BackoffLimit, err
258+
return j.Status.Succeeded == 1 || j.Status.Failed == totalRetries, jobErr
257259
},
258260
},
259261
},
260262
})
263+
return jobErr
261264
}
262265

263266
func printJobLogs(ctx context.Context, client kubernetes.Interface, job *batchv1.Job) {

0 commit comments

Comments
 (0)