Skip to content

Commit 978a4a1

Browse files
committed
More
1 parent 50cf684 commit 978a4a1

15 files changed

+453
-58
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,11 @@ local-release: snapshot-release
8585
docker push localhost:32000/troubleshoot:alpha
8686
docker push localhost:32000/preflight:alpha
8787
docker push localhost:32000/troubleshoot-manager:alpha
88+
89+
.PHONY: run-preflight
90+
run-preflight: preflight
91+
./bin/preflight run \
92+
--collector-image=localhost:32000/troubleshoot:alpha \
93+
--collector-pullpolicy=Always \
94+
--image=localhost:32000/troubleshoot:alpha \
95+
--pullpolicy=Always

cmd/preflight/cli/receive.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"io/ioutil"
66
"net/http"
77
"os"
8-
"time"
98

109
kuberneteserrors "k8s.io/apimachinery/pkg/api/errors"
1110
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -34,12 +33,6 @@ func receivePreflightResults(preflightJobNamespace string, preflightJobName stri
3433
return err
3534
}
3635

37-
// If the collectors are still running, hang tight.
38-
if !job.Status.IsCollectorsComplete {
39-
time.Sleep(time.Millisecond * 400)
40-
continue
41-
}
42-
4336
for _, readyPreflight := range job.Status.AnalyzersSuccessful {
4437
alreadyReceived := false
4538
for _, receivedPreflight := range receivedPreflights {
@@ -67,22 +60,8 @@ func receivePreflightResults(preflightJobNamespace string, preflightJobName stri
6760
receivedPreflights = append(receivedPreflights, readyPreflight)
6861
}
6962

70-
// if len(job.Status.Running) == 0 {
71-
// tarGz := archiver.TarGz{
72-
// Tar: &archiver.Tar{
73-
// ImplicitTopLevelFolder: false,
74-
// },
75-
// }
76-
77-
// paths := make([]string, 0, 0)
78-
// for _, id := range receivedCollectors {
79-
// paths = append(paths, filepath.Join(bundlePath, id))
80-
// }
81-
82-
// if err := tarGz.Archive(paths, "support-bundle.tar.gz"); err != nil {
83-
// return err
84-
// }
85-
// return nil
86-
// }
63+
if len(job.Status.AnalyzersRunning) == 0 {
64+
return nil
65+
}
8766
}
8867
}

cmd/preflight/cli/run.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ func Run() *cobra.Command {
125125
cmd.Flags().String("pullpolicy", "", "the pull policy of the preflight image")
126126
cmd.Flags().String("collector-image", "", "the full name of the collector image to use")
127127
cmd.Flags().String("collector-pullpolicy", "", "the pull policy of the collector image")
128-
cmd.Flags().String("analyzer-image", "", "the full name of the analyzer image to use")
129-
cmd.Flags().String("analyzer-pullpolicy", "", "the pull policy of the analyzer image")
130128

131129
viper.BindPFlags(cmd.Flags())
132130

config/crds/troubleshoot.replicated.com_preflightjobs.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,6 @@ spec:
391391
type: object
392392
spec:
393393
properties:
394-
analyzerImage:
395-
type: string
396-
analyzerImagePullPolicy:
397-
type: string
398394
collectorImage:
399395
type: string
400396
collectorImagePullPolicy:
@@ -443,8 +439,6 @@ spec:
443439
type: array
444440
isAnalyzersComplete:
445441
type: boolean
446-
isCollectorsComplete:
447-
type: boolean
448442
isServerReady:
449443
type: boolean
450444
serverPodName:
@@ -458,7 +452,6 @@ spec:
458452
- serverPodName
459453
- serverPodNamespace
460454
- serverPodPort
461-
- isCollectorsComplete
462455
- collectorsRunning
463456
- collectorsSuccessful
464457
- collectorsFailed

config/crds/troubleshoot.replicated.com_preflights.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,84 @@ spec:
393393
properties:
394394
analyzers:
395395
items:
396+
properties:
397+
clusterVersion:
398+
properties:
399+
outcomes:
400+
items:
401+
properties:
402+
fail:
403+
properties:
404+
message:
405+
type: string
406+
uri:
407+
type: string
408+
when:
409+
type: string
410+
type: object
411+
pass:
412+
properties:
413+
message:
414+
type: string
415+
uri:
416+
type: string
417+
when:
418+
type: string
419+
type: object
420+
warn:
421+
properties:
422+
message:
423+
type: string
424+
uri:
425+
type: string
426+
when:
427+
type: string
428+
type: object
429+
type: object
430+
type: array
431+
required:
432+
- outcomes
433+
type: object
434+
storageClass:
435+
properties:
436+
name:
437+
type: string
438+
outcomes:
439+
items:
440+
properties:
441+
fail:
442+
properties:
443+
message:
444+
type: string
445+
uri:
446+
type: string
447+
when:
448+
type: string
449+
type: object
450+
pass:
451+
properties:
452+
message:
453+
type: string
454+
uri:
455+
type: string
456+
when:
457+
type: string
458+
type: object
459+
warn:
460+
properties:
461+
message:
462+
type: string
463+
uri:
464+
type: string
465+
when:
466+
type: string
467+
type: object
468+
type: object
469+
type: array
470+
required:
471+
- outcomes
472+
- name
473+
type: object
396474
type: object
397475
type: array
398476
collectors:

config/crds/zz_generated.deepcopy.go

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ import (
1111
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
1212
func (in *Analyze) DeepCopyInto(out *Analyze) {
1313
*out = *in
14+
if in.ClusterVersion != nil {
15+
in, out := &in.ClusterVersion, &out.ClusterVersion
16+
*out = new(ClusterVersion)
17+
(*in).DeepCopyInto(*out)
18+
}
19+
if in.StorageClass != nil {
20+
in, out := &in.StorageClass, &out.StorageClass
21+
*out = new(StorageClass)
22+
(*in).DeepCopyInto(*out)
23+
}
1424
}
1525

1626
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Analyze.
@@ -231,6 +241,32 @@ func (in *ClusterResources) DeepCopy() *ClusterResources {
231241
return out
232242
}
233243

244+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
245+
func (in *ClusterVersion) DeepCopyInto(out *ClusterVersion) {
246+
*out = *in
247+
if in.Outcomes != nil {
248+
in, out := &in.Outcomes, &out.Outcomes
249+
*out = make([]*Outcome, len(*in))
250+
for i := range *in {
251+
if (*in)[i] != nil {
252+
in, out := &(*in)[i], &(*out)[i]
253+
*out = new(Outcome)
254+
(*in).DeepCopyInto(*out)
255+
}
256+
}
257+
}
258+
}
259+
260+
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterVersion.
261+
func (in *ClusterVersion) DeepCopy() *ClusterVersion {
262+
if in == nil {
263+
return nil
264+
}
265+
out := new(ClusterVersion)
266+
in.DeepCopyInto(out)
267+
return out
268+
}
269+
234270
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
235271
func (in *Collect) DeepCopyInto(out *Collect) {
236272
*out = *in
@@ -460,6 +496,36 @@ func (in *CollectorStatus) DeepCopy() *CollectorStatus {
460496
return out
461497
}
462498

499+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
500+
func (in *Outcome) DeepCopyInto(out *Outcome) {
501+
*out = *in
502+
if in.Fail != nil {
503+
in, out := &in.Fail, &out.Fail
504+
*out = new(SingleOutcome)
505+
**out = **in
506+
}
507+
if in.Warn != nil {
508+
in, out := &in.Warn, &out.Warn
509+
*out = new(SingleOutcome)
510+
**out = **in
511+
}
512+
if in.Pass != nil {
513+
in, out := &in.Pass, &out.Pass
514+
*out = new(SingleOutcome)
515+
**out = **in
516+
}
517+
}
518+
519+
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Outcome.
520+
func (in *Outcome) DeepCopy() *Outcome {
521+
if in == nil {
522+
return nil
523+
}
524+
out := new(Outcome)
525+
in.DeepCopyInto(out)
526+
return out
527+
}
528+
463529
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
464530
func (in *Preflight) DeepCopyInto(out *Preflight) {
465531
*out = *in
@@ -675,7 +741,7 @@ func (in *PreflightSpec) DeepCopyInto(out *PreflightSpec) {
675741
if (*in)[i] != nil {
676742
in, out := &(*in)[i], &(*out)[i]
677743
*out = new(Analyze)
678-
**out = **in
744+
(*in).DeepCopyInto(*out)
679745
}
680746
}
681747
}
@@ -705,3 +771,44 @@ func (in *PreflightStatus) DeepCopy() *PreflightStatus {
705771
in.DeepCopyInto(out)
706772
return out
707773
}
774+
775+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
776+
func (in *SingleOutcome) DeepCopyInto(out *SingleOutcome) {
777+
*out = *in
778+
}
779+
780+
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SingleOutcome.
781+
func (in *SingleOutcome) DeepCopy() *SingleOutcome {
782+
if in == nil {
783+
return nil
784+
}
785+
out := new(SingleOutcome)
786+
in.DeepCopyInto(out)
787+
return out
788+
}
789+
790+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
791+
func (in *StorageClass) DeepCopyInto(out *StorageClass) {
792+
*out = *in
793+
if in.Outcome != nil {
794+
in, out := &in.Outcome, &out.Outcome
795+
*out = make([]*Outcome, len(*in))
796+
for i := range *in {
797+
if (*in)[i] != nil {
798+
in, out := &(*in)[i], &(*out)[i]
799+
*out = new(Outcome)
800+
(*in).DeepCopyInto(*out)
801+
}
802+
}
803+
}
804+
}
805+
806+
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClass.
807+
func (in *StorageClass) DeepCopy() *StorageClass {
808+
if in == nil {
809+
return nil
810+
}
811+
out := new(StorageClass)
812+
in.DeepCopyInto(out)
813+
return out
814+
}

config/samples/troubleshoot_v1beta1_preflight.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ metadata:
55
spec:
66
analyzers:
77
- clusterVersion:
8-
fail:
9-
when: "< 1.13.0"
10-
message: You need more kubernetes
11-
warn:
12-
when: "< 1.15.0"
13-
message: You have barely enough kubernetes
14-
pass:
15-
message: Good job keeping k8s current
8+
outcomes:
9+
- fail:
10+
when: "< 1.13.0"
11+
message: You need more kubernetes
12+
- warn:
13+
when: "< 1.15.0"
14+
message: You have barely enough kubernetes
15+
- pass:
16+
message: Good job keeping k8s current
1617
# - storageClass:
1718
# name: "my-custom-storage-class"
1819
# fail:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
package v1beta1
22

3+
type SingleOutcome struct {
4+
When string `json:"when,omitempty" yaml:"when,omitempty"`
5+
Message string `json:"message,omitempty" yaml:"message,omitempty"`
6+
URI string `json:"uri,omitempty" yaml:"uri,omitempty"`
7+
}
8+
9+
type Outcome struct {
10+
Fail *SingleOutcome `json:"fail,omitempty" yaml:"fail,omitempty"`
11+
Warn *SingleOutcome `json:"warn,omitempty" yaml:"warn,omitempty"`
12+
Pass *SingleOutcome `json:"pass,omitempty" yaml:"pass,omitempty"`
13+
}
14+
15+
type ClusterVersion struct {
16+
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
17+
}
18+
19+
type StorageClass struct {
20+
Outcome []*Outcome `json:"outcomes" yaml:"outcomes"`
21+
Name string `json:"name" yaml:"name"`
22+
}
23+
324
type Analyze struct {
25+
ClusterVersion *ClusterVersion `json:"clusterVersion,omitempty" yaml:"clusterVersion,omitempty"`
26+
StorageClass *StorageClass `json:"storageClass,omitempty" yaml:"supportBundle,omitempty"`
427
}

0 commit comments

Comments
 (0)