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

Show failed/running jobs as part of analysis runs. Fix degraded checks #278

Merged
merged 1 commit into from
Nov 8, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/kubectl-argo-rollouts/cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
IconRevision = "#"
IconReplicaSet = "⧉"
IconPod = "□"
IconJob = "⊞"
IconService = "⑃" // other options: ⋲ ⇶ ⋔ ⤨
IconExperiment = "Σ" // other options: ꀀ ⋃ ⨄
IconAnalysis = "α" // other options: ⚯
Expand Down
5 changes: 2 additions & 3 deletions pkg/kubectl-argo-rollouts/cmd/get/get_experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ func (o *GetOptions) PrintExperimentInfo(w io.Writer, expInfo info.ExperimentInf
curr++
}
for _, arInfo := range expInfo.AnalysisRuns {
fmt.Fprintf(w, subpfx)
arPrefix, _ := getPrefixes(curr == total-1, "")
o.PrintAnalysisRunInfo(w, arInfo, arPrefix, "")
arPrefix, arChildPrefix := getPrefixes(curr == total-1, subpfx)
o.PrintAnalysisRunInfo(w, arInfo, arPrefix, arChildPrefix)
curr++
}
}
13 changes: 11 additions & 2 deletions pkg/kubectl-argo-rollouts/cmd/get/get_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,8 @@ func (o *GetOptions) PrintReplicaSetInfo(w io.Writer, rsInfo info.ReplicaSetInfo
}
fmt.Fprintf(w, "%s%s %s\t%s\t%s %s\t%s\t%v\n", prefix, IconReplicaSet, name, "ReplicaSet", o.colorize(rsInfo.Icon), rsInfo.Status, rsInfo.Age(), strings.Join(infoCols, ","))
for i, podInfo := range rsInfo.Pods {
fmt.Fprintf(w, subpfx)
isLast := i == len(rsInfo.Pods)-1
podPrefix, _ := getPrefixes(isLast, "")
podPrefix, _ := getPrefixes(isLast, subpfx)
podInfoCol := []string{fmt.Sprintf("ready:%s", podInfo.Ready)}
if podInfo.Restarts > 0 {
podInfoCol = append(podInfoCol, fmt.Sprintf("restarts:%d", podInfo.Restarts))
Expand All @@ -211,4 +210,14 @@ func (o *GetOptions) PrintAnalysisRunInfo(w io.Writer, arInfo info.AnalysisRunIn
infoCols = append(infoCols, fmt.Sprintf("%s %d", o.colorize(info.IconWarning), arInfo.Error))
}
fmt.Fprintf(w, "%s%s %s\t%s\t%s %s\t%s\t%v\n", prefix, IconAnalysis, name, "AnalysisRun", o.colorize(arInfo.Icon), arInfo.Status, arInfo.Age(), strings.Join(infoCols, ","))
for i, jobInfo := range arInfo.Jobs {
isLast := i == len(arInfo.Jobs)-1
jobPrefix, jobChildPrefix := getPrefixes(isLast, subpfx)
o.PrintJob(w, jobInfo, jobPrefix, jobChildPrefix)
}
}

func (o *GetOptions) PrintJob(w io.Writer, jobInfo info.JobInfo, prefix string, subpfx string) {
name := o.colorizeStatus(jobInfo.Name, jobInfo.Status)
fmt.Fprintf(w, "%s%s %s\t%s\t%s %s\t%s\t%v\n", prefix, IconJob, name, "Job", o.colorize(jobInfo.Icon), jobInfo.Status, jobInfo.Age(), "")
}
49 changes: 49 additions & 0 deletions pkg/kubectl-argo-rollouts/cmd/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,52 @@ NAME KIND
`, "\n")
assertStdout(t, expectedOut, o.IOStreams)
}

func TestGetRolloutWithExperimentJob(t *testing.T) {
rolloutObjs := testdata.NewExperimentAnalysisJobRollout()

tf, o := options.NewFakeArgoRolloutsOptions(rolloutObjs.AllObjects()...)
o.RESTClientGetter = tf.WithNamespace(rolloutObjs.Rollouts[0].Namespace)
defer tf.Cleanup()
cmd := NewCmdGetRollout(o)
cmd.PersistentPreRunE = o.PersistentPreRunE
cmd.SetArgs([]string{rolloutObjs.Rollouts[0].Name, "--no-color"})
err := cmd.Execute()
assert.NoError(t, err)

expectedOut := strings.TrimPrefix(`
Name: canary-demo
Namespace: jesse-test
Status: ◌ Progressing
Strategy: Canary
Step: 0/1
SetWeight: 0
ActualWeight: 0
Images: argoproj/rollouts-demo:blue (Σ:canary-preview)
argoproj/rollouts-demo:green (stable)
Replicas:
Desired: 5
Current: 5
Updated: 0
Ready: 5
Available: 5

NAME KIND STATUS AGE INFO
⟳ canary-demo Rollout ◌ Progressing 7d
├──# revision:2
│ ├──⧉ canary-demo-645d5dbc4c ReplicaSet • ScaledDown 7d canary
│ └──Σ canary-demo-645d5dbc4c-2-0 Experiment ◌ Running 7d
│ ├──⧉ canary-demo-645d5dbc4c-2-0-canary-preview ReplicaSet ✔ Healthy 7d
│ │ └──□ canary-demo-645d5dbc4c-2-0-canary-preview-zmmvz Pod ✔ Running 7d ready:1/1
│ └──α canary-demo-645d5dbc4c-2-0-stress-test AnalysisRun ◌ Running 7d
│ └──⊞ 4e2d824d-01af-11ea-b38c-42010aa80083.stress.1 Job ◌ Running 7d
└──# revision:1
└──⧉ canary-demo-877894d5b ReplicaSet ✔ Healthy 7d stable
├──□ canary-demo-877894d5b-n6xqz Pod ✔ Running 7d ready:1/1
├──□ canary-demo-877894d5b-nlmj9 Pod ✔ Running 7d ready:1/1
├──□ canary-demo-877894d5b-txgs5 Pod ✔ Running 7d ready:1/1
├──□ canary-demo-877894d5b-wfqqr Pod ✔ Running 7d ready:1/1
└──□ canary-demo-877894d5b-zhh6x Pod ✔ Running 7d ready:1/1
`, "\n")
assertStdout(t, expectedOut, o.IOStreams)
}
25 changes: 25 additions & 0 deletions pkg/kubectl-argo-rollouts/info/analysisrun_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (

"k8s.io/apimachinery/pkg/types"

"github.com/argoproj/argo-rollouts/metricproviders/job"
"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
analysisutil "github.com/argoproj/argo-rollouts/utils/analysis"
)

type AnalysisRunInfo struct {
Expand All @@ -17,6 +19,13 @@ type AnalysisRunInfo struct {
Failed int32
Inconclusive int32
Error int32
Jobs []JobInfo
}

type JobInfo struct {
Metadata
Status string
Icon string
}

func getAnalysisRunInfo(ownerUID types.UID, allAnalysisRuns []*v1alpha1.AnalysisRun) []AnalysisRunInfo {
Expand All @@ -39,6 +48,22 @@ func getAnalysisRunInfo(ownerUID types.UID, allAnalysisRuns []*v1alpha1.Analysis
arInfo.Failed += mr.Failed
arInfo.Inconclusive += mr.Inconclusive
arInfo.Error += mr.Error
lastMeasurement := analysisutil.LastMeasurement(run, mr.Name)
if lastMeasurement != nil && lastMeasurement.Metadata != nil && lastMeasurement.Phase != v1alpha1.AnalysisPhaseSuccessful {
if jobName, ok := lastMeasurement.Metadata[job.JobNameKey]; ok {
jobInfo := JobInfo{
Metadata: Metadata{
Name: jobName,
},
Icon: analysisIcon(lastMeasurement.Phase),
Status: string(lastMeasurement.Phase),
}
if lastMeasurement.StartedAt != nil {
jobInfo.CreationTimestamp = *lastMeasurement.StartedAt
}
arInfo.Jobs = append(arInfo.Jobs, jobInfo)
}
}
}
arInfo.Icon = analysisIcon(run.Status.Phase)
arInfo.Revision = parseRevision(run.ObjectMeta.Annotations)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"argoproj.io/v1alpha1","kind":"Rollout","metadata":{"annotations":{},"name":"canary-demo","namespace":"jesse-test"},"spec":{"replicas":5,"revisionHistoryLimit":3,"selector":{"matchLabels":{"app":"canary-demo"}},"strategy":{"canary":{"steps":[{"experiment":{"analyses":[{"name":"stress-test","templateName":"stress-test"}],"templates":[{"metadata":{"labels":{"app":"rollout-canary-preview"}},"name":"canary-preview","selector":{"matchLabels":{"app":"rollout-canary-preview"}},"specRef":"canary"}]}}]}},"template":{"metadata":{"labels":{"app":"canary-demo"}},"spec":{"containers":[{"image":"argoproj/rollouts-demo:blue","imagePullPolicy":"Always","name":"canary-demo","ports":[{"containerPort":8080,"name":"http","protocol":"TCP"}],"resources":{"requests":{"cpu":"5m","memory":"32Mi"}}}]}}}}
rollout.argoproj.io/revision: "2"
creationTimestamp: "2019-11-07T22:38:03Z"
generation: 13
name: canary-demo
namespace: jesse-test
resourceVersion: "33430711"
selfLink: /apis/argoproj.io/v1alpha1/namespaces/jesse-test/rollouts/canary-demo
uid: 42b19359-01af-11ea-b38c-42010aa80083
spec:
replicas: 5
revisionHistoryLimit: 3
selector:
matchLabels:
app: canary-demo
strategy:
canary:
steps:
- experiment:
analyses:
- name: stress-test
templateName: stress-test
templates:
- metadata:
labels:
app: rollout-canary-preview
name: canary-preview
selector:
matchLabels:
app: rollout-canary-preview
specRef: canary
template:
metadata:
creationTimestamp: null
labels:
app: canary-demo
spec:
containers:
- image: argoproj/rollouts-demo:blue
imagePullPolicy: Always
name: canary-demo
ports:
- containerPort: 8080
name: http
protocol: TCP
resources:
requests:
cpu: 5m
memory: 32Mi
status:
HPAReplicas: 5
availableReplicas: 5
blueGreen: {}
canary:
currentExperiment: canary-demo-645d5dbc4c-2-0
stableRS: 877894d5b
conditions:
- lastTransitionTime: "2019-11-07T22:38:11Z"
lastUpdateTime: "2019-11-07T22:38:11Z"
message: Rollout has minimum availability
reason: AvailableReason
status: "True"
type: Available
- lastTransitionTime: "2019-11-07T22:38:03Z"
lastUpdateTime: "2019-11-07T22:38:18Z"
message: Created new replica set "canary-demo-645d5dbc4c"
reason: NewReplicaSetCreated
status: "True"
type: Progressing
currentPodHash: 645d5dbc4c
currentStepHash: 7d595679dd
currentStepIndex: 0
observedGeneration: 7664c98448
readyReplicas: 5
replicas: 5
selector: app=canary-demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2019-11-07T22:38:23Z"
generateName: 4e2d824d-01af-11ea-b38c-42010aa80083.stress.1-
labels:
controller-uid: 4e309601-01af-11ea-b38c-42010aa80083
job-name: 4e2d824d-01af-11ea-b38c-42010aa80083.stress.1
name: 4e2d824d-01af-11ea-b38c-42010aa80083.stress.1-lsrws
namespace: jesse-test
ownerReferences:
- apiVersion: batch/v1
blockOwnerDeletion: true
controller: true
kind: Job
name: 4e2d824d-01af-11ea-b38c-42010aa80083.stress.1
uid: 4e309601-01af-11ea-b38c-42010aa80083
resourceVersion: "33430818"
selfLink: /api/v1/namespaces/jesse-test/pods/4e2d824d-01af-11ea-b38c-42010aa80083.stress.1-lsrws
uid: 4e340a3d-01af-11ea-b38c-42010aa80083
spec:
containers:
- command:
- wrk
- -t12
- -c100
- -d30s
- http://canary-demo-preview/color]
image: williamyeh/wrk
imagePullPolicy: Always
name: stress
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-5wzlj
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: gke-argoproj-demo-01-default-pool-848985e7-g3kx
priority: 0
restartPolicy: Never
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: default-token-5wzlj
secret:
defaultMode: 420
secretName: default-token-5wzlj
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2019-11-07T22:38:23Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2019-11-07T22:38:27Z"
message: 'containers with unready status: [stress]'
reason: ContainersNotReady
status: "False"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2019-11-07T22:38:27Z"
message: 'containers with unready status: [stress]'
reason: ContainersNotReady
status: "False"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2019-11-07T22:38:23Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: docker://ea0f9d5abffb5a3d608d45702caed64f11a6864828f4dfb173f31a2a5e19c70e
image: williamyeh/wrk:latest
imageID: docker-pullable://williamyeh/wrk@sha256:78adc0d9d51a99e6759e702a08d03eaece81c890ffcc9790ef9e5b199d54f091
lastState: {}
name: stress
ready: false
restartCount: 0
state:
terminated:
containerID: docker://ea0f9d5abffb5a3d608d45702caed64f11a6864828f4dfb173f31a2a5e19c70e
exitCode: 1
finishedAt: "2019-11-07T22:38:26Z"
reason: Error
startedAt: "2019-11-07T22:38:25Z"
hostIP: 10.168.0.26
phase: Failed
podIP: 10.16.3.136
qosClass: BestEffort
startTime: "2019-11-07T22:38:23Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: batch/v1
kind: Job
metadata:
annotations:
analysisrun.argoproj.io/metric-name: stress
analysisrun.argoproj.io/name: canary-demo-645d5dbc4c-2-0-stress-test
creationTimestamp: "2019-11-07T22:38:23Z"
labels:
analysisrun.argoproj.io/uid: 4e2d824d-01af-11ea-b38c-42010aa80083
name: 4e2d824d-01af-11ea-b38c-42010aa80083.stress.1
namespace: jesse-test
ownerReferences:
- apiVersion: argoproj.io/v1alpha1
blockOwnerDeletion: true
controller: true
kind: AnalysisRun
name: canary-demo-645d5dbc4c-2-0-stress-test
uid: 4e2d824d-01af-11ea-b38c-42010aa80083
resourceVersion: "33430820"
selfLink: /apis/batch/v1/namespaces/jesse-test/jobs/4e2d824d-01af-11ea-b38c-42010aa80083.stress.1
uid: 4e309601-01af-11ea-b38c-42010aa80083
spec:
backoffLimit: 0
completions: 1
parallelism: 1
selector:
matchLabels:
controller-uid: 4e309601-01af-11ea-b38c-42010aa80083
template:
metadata:
creationTimestamp: null
labels:
controller-uid: 4e309601-01af-11ea-b38c-42010aa80083
job-name: 4e2d824d-01af-11ea-b38c-42010aa80083.stress.1
spec:
containers:
- command:
- wrk
- -t12
- -c100
- -d30s
- http://canary-demo-preview/color]
image: williamyeh/wrk
imagePullPolicy: Always
name: stress
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Never
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status:
conditions:
- lastProbeTime: "2019-11-07T22:38:27Z"
lastTransitionTime: "2019-11-07T22:38:27Z"
message: Job has reached the specified backoff limit
reason: BackoffLimitExceeded
status: "True"
type: Failed
failed: 1
startTime: "2019-11-07T22:38:23Z"
Loading