Skip to content

Commit ed8453c

Browse files
committed
Distribution analyzer
1 parent 5744d60 commit ed8453c

File tree

11 files changed

+559
-12
lines changed

11 files changed

+559
-12
lines changed

config/crds/troubleshoot.replicated.com_analyzers.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,45 @@ spec:
433433
required:
434434
- outcomes
435435
type: object
436+
containerRuntime:
437+
properties:
438+
checkName:
439+
type: string
440+
outcomes:
441+
items:
442+
properties:
443+
fail:
444+
properties:
445+
message:
446+
type: string
447+
uri:
448+
type: string
449+
when:
450+
type: string
451+
type: object
452+
pass:
453+
properties:
454+
message:
455+
type: string
456+
uri:
457+
type: string
458+
when:
459+
type: string
460+
type: object
461+
warn:
462+
properties:
463+
message:
464+
type: string
465+
uri:
466+
type: string
467+
when:
468+
type: string
469+
type: object
470+
type: object
471+
type: array
472+
required:
473+
- outcomes
474+
type: object
436475
customResourceDefinition:
437476
properties:
438477
checkName:
@@ -520,6 +559,45 @@ spec:
520559
- namespace
521560
- name
522561
type: object
562+
distribution:
563+
properties:
564+
checkName:
565+
type: string
566+
outcomes:
567+
items:
568+
properties:
569+
fail:
570+
properties:
571+
message:
572+
type: string
573+
uri:
574+
type: string
575+
when:
576+
type: string
577+
type: object
578+
pass:
579+
properties:
580+
message:
581+
type: string
582+
uri:
583+
type: string
584+
when:
585+
type: string
586+
type: object
587+
warn:
588+
properties:
589+
message:
590+
type: string
591+
uri:
592+
type: string
593+
when:
594+
type: string
595+
type: object
596+
type: object
597+
type: array
598+
required:
599+
- outcomes
600+
type: object
523601
imagePullSecret:
524602
properties:
525603
checkName:

config/crds/troubleshoot.replicated.com_preflights.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,45 @@ spec:
433433
required:
434434
- outcomes
435435
type: object
436+
containerRuntime:
437+
properties:
438+
checkName:
439+
type: string
440+
outcomes:
441+
items:
442+
properties:
443+
fail:
444+
properties:
445+
message:
446+
type: string
447+
uri:
448+
type: string
449+
when:
450+
type: string
451+
type: object
452+
pass:
453+
properties:
454+
message:
455+
type: string
456+
uri:
457+
type: string
458+
when:
459+
type: string
460+
type: object
461+
warn:
462+
properties:
463+
message:
464+
type: string
465+
uri:
466+
type: string
467+
when:
468+
type: string
469+
type: object
470+
type: object
471+
type: array
472+
required:
473+
- outcomes
474+
type: object
436475
customResourceDefinition:
437476
properties:
438477
checkName:
@@ -520,6 +559,45 @@ spec:
520559
- namespace
521560
- name
522561
type: object
562+
distribution:
563+
properties:
564+
checkName:
565+
type: string
566+
outcomes:
567+
items:
568+
properties:
569+
fail:
570+
properties:
571+
message:
572+
type: string
573+
uri:
574+
type: string
575+
when:
576+
type: string
577+
type: object
578+
pass:
579+
properties:
580+
message:
581+
type: string
582+
uri:
583+
type: string
584+
when:
585+
type: string
586+
type: object
587+
warn:
588+
properties:
589+
message:
590+
type: string
591+
uri:
592+
type: string
593+
when:
594+
type: string
595+
type: object
596+
type: object
597+
type: array
598+
required:
599+
- outcomes
600+
type: object
523601
imagePullSecret:
524602
properties:
525603
checkName:

config/crds/zz_generated.deepcopy.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ func (in *Analyze) DeepCopyInto(out *Analyze) {
7676
*out = new(StatefulsetStatus)
7777
(*in).DeepCopyInto(*out)
7878
}
79+
if in.ContainerRuntime != nil {
80+
in, out := &in.ContainerRuntime, &out.ContainerRuntime
81+
*out = new(ContainerRuntime)
82+
(*in).DeepCopyInto(*out)
83+
}
84+
if in.Distribution != nil {
85+
in, out := &in.Distribution, &out.Distribution
86+
*out = new(Distribution)
87+
(*in).DeepCopyInto(*out)
88+
}
7989
}
8090

8191
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Analyze.
@@ -677,6 +687,33 @@ func (in *CollectorStatus) DeepCopy() *CollectorStatus {
677687
return out
678688
}
679689

690+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
691+
func (in *ContainerRuntime) DeepCopyInto(out *ContainerRuntime) {
692+
*out = *in
693+
out.AnalyzeMeta = in.AnalyzeMeta
694+
if in.Outcomes != nil {
695+
in, out := &in.Outcomes, &out.Outcomes
696+
*out = make([]*Outcome, len(*in))
697+
for i := range *in {
698+
if (*in)[i] != nil {
699+
in, out := &(*in)[i], &(*out)[i]
700+
*out = new(Outcome)
701+
(*in).DeepCopyInto(*out)
702+
}
703+
}
704+
}
705+
}
706+
707+
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntime.
708+
func (in *ContainerRuntime) DeepCopy() *ContainerRuntime {
709+
if in == nil {
710+
return nil
711+
}
712+
out := new(ContainerRuntime)
713+
in.DeepCopyInto(out)
714+
return out
715+
}
716+
680717
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
681718
func (in *Copy) DeepCopyInto(out *Copy) {
682719
*out = *in
@@ -752,6 +789,33 @@ func (in *DeploymentStatus) DeepCopy() *DeploymentStatus {
752789
return out
753790
}
754791

792+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
793+
func (in *Distribution) DeepCopyInto(out *Distribution) {
794+
*out = *in
795+
out.AnalyzeMeta = in.AnalyzeMeta
796+
if in.Outcomes != nil {
797+
in, out := &in.Outcomes, &out.Outcomes
798+
*out = make([]*Outcome, len(*in))
799+
for i := range *in {
800+
if (*in)[i] != nil {
801+
in, out := &(*in)[i], &(*out)[i]
802+
*out = new(Outcome)
803+
(*in).DeepCopyInto(*out)
804+
}
805+
}
806+
}
807+
}
808+
809+
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Distribution.
810+
func (in *Distribution) DeepCopy() *Distribution {
811+
if in == nil {
812+
return nil
813+
}
814+
out := new(Distribution)
815+
in.DeepCopyInto(out)
816+
return out
817+
}
818+
755819
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
756820
func (in *Exec) DeepCopyInto(out *Exec) {
757821
*out = *in
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
apiVersion: troubleshoot.replicated.com/v1beta1
22
kind: Analyzer
33
metadata:
4-
name: defaultAnalyzers
4+
name: a
55
spec:
66
analyzers:
7-
- clusterVersion:
7+
- distribution:
88
outcomes:
99
- fail:
10-
when: "< 1.13.0"
11-
message: The application requires at Kubernetes 1.13.0 or later, and recommends 1.15.0.
12-
uri: https://www.kubernetes.io
10+
when: "= docker desktop"
11+
message: "docker for desktop is not allowed"
12+
- fail:
13+
when: "microk8s"
14+
message: "mickrk8s is not prod"
1315
- warn:
14-
when: "< 1.15.0"
15-
message: Your cluster meets the minimum version of Kubernetes, but we recommend you update to 1.15.0 or later.
16-
uri: https://kubernetes.io
16+
when: "!= eks"
17+
message: "YMMV on not eks"
1718
- pass:
18-
when: ">= 1.15.0"
19-
message: Your cluster meets the recommended and required versions of Kubernetes.
19+
message: "good work"
20+
21+

pkg/analyze/analyzer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ func Analyze(analyzer *troubleshootv1beta1.Analyze, getFile getCollectedFileCont
4646
if analyzer.ContainerRuntime != nil {
4747
return analyzeContainerRuntime(analyzer.ContainerRuntime, getFile)
4848
}
49+
if analyzer.Distribution != nil {
50+
return analyzeDistribution(analyzer.Distribution, getFile)
51+
}
4952

5053
return nil, errors.New("invalid analyzer")
5154
}

pkg/analyze/deployment_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func analyzeDeploymentStatus(analyzer *troubleshootv1beta1.DeploymentStatus, get
3333
return &AnalyzeResult{
3434
Title: fmt.Sprintf("%s Deployment Status", analyzer.Name),
3535
IsFail: true,
36-
Message: "not found",
36+
Message: fmt.Sprintf("The deployment %q was not found", analyzer.Name),
3737
}, nil
3838
}
3939

0 commit comments

Comments
 (0)