Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
marccampbell committed Jul 12, 2019
1 parent 50cf684 commit 978a4a1
Show file tree
Hide file tree
Showing 15 changed files with 453 additions and 58 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,11 @@ local-release: snapshot-release
docker push localhost:32000/troubleshoot:alpha
docker push localhost:32000/preflight:alpha
docker push localhost:32000/troubleshoot-manager:alpha

.PHONY: run-preflight
run-preflight: preflight
./bin/preflight run \
--collector-image=localhost:32000/troubleshoot:alpha \
--collector-pullpolicy=Always \
--image=localhost:32000/troubleshoot:alpha \
--pullpolicy=Always
27 changes: 3 additions & 24 deletions cmd/preflight/cli/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io/ioutil"
"net/http"
"os"
"time"

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

// If the collectors are still running, hang tight.
if !job.Status.IsCollectorsComplete {
time.Sleep(time.Millisecond * 400)
continue
}

for _, readyPreflight := range job.Status.AnalyzersSuccessful {
alreadyReceived := false
for _, receivedPreflight := range receivedPreflights {
Expand Down Expand Up @@ -67,22 +60,8 @@ func receivePreflightResults(preflightJobNamespace string, preflightJobName stri
receivedPreflights = append(receivedPreflights, readyPreflight)
}

// if len(job.Status.Running) == 0 {
// tarGz := archiver.TarGz{
// Tar: &archiver.Tar{
// ImplicitTopLevelFolder: false,
// },
// }

// paths := make([]string, 0, 0)
// for _, id := range receivedCollectors {
// paths = append(paths, filepath.Join(bundlePath, id))
// }

// if err := tarGz.Archive(paths, "support-bundle.tar.gz"); err != nil {
// return err
// }
// return nil
// }
if len(job.Status.AnalyzersRunning) == 0 {
return nil
}
}
}
2 changes: 0 additions & 2 deletions cmd/preflight/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ func Run() *cobra.Command {
cmd.Flags().String("pullpolicy", "", "the pull policy of the preflight image")
cmd.Flags().String("collector-image", "", "the full name of the collector image to use")
cmd.Flags().String("collector-pullpolicy", "", "the pull policy of the collector image")
cmd.Flags().String("analyzer-image", "", "the full name of the analyzer image to use")
cmd.Flags().String("analyzer-pullpolicy", "", "the pull policy of the analyzer image")

viper.BindPFlags(cmd.Flags())

Expand Down
7 changes: 0 additions & 7 deletions config/crds/troubleshoot.replicated.com_preflightjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,6 @@ spec:
type: object
spec:
properties:
analyzerImage:
type: string
analyzerImagePullPolicy:
type: string
collectorImage:
type: string
collectorImagePullPolicy:
Expand Down Expand Up @@ -443,8 +439,6 @@ spec:
type: array
isAnalyzersComplete:
type: boolean
isCollectorsComplete:
type: boolean
isServerReady:
type: boolean
serverPodName:
Expand All @@ -458,7 +452,6 @@ spec:
- serverPodName
- serverPodNamespace
- serverPodPort
- isCollectorsComplete
- collectorsRunning
- collectorsSuccessful
- collectorsFailed
Expand Down
78 changes: 78 additions & 0 deletions config/crds/troubleshoot.replicated.com_preflights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,84 @@ spec:
properties:
analyzers:
items:
properties:
clusterVersion:
properties:
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
storageClass:
properties:
name:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
- name
type: object
type: object
type: array
collectors:
Expand Down
109 changes: 108 additions & 1 deletion config/crds/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ import (
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Analyze) DeepCopyInto(out *Analyze) {
*out = *in
if in.ClusterVersion != nil {
in, out := &in.ClusterVersion, &out.ClusterVersion
*out = new(ClusterVersion)
(*in).DeepCopyInto(*out)
}
if in.StorageClass != nil {
in, out := &in.StorageClass, &out.StorageClass
*out = new(StorageClass)
(*in).DeepCopyInto(*out)
}
}

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

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterVersion) DeepCopyInto(out *ClusterVersion) {
*out = *in
if in.Outcomes != nil {
in, out := &in.Outcomes, &out.Outcomes
*out = make([]*Outcome, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(Outcome)
(*in).DeepCopyInto(*out)
}
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterVersion.
func (in *ClusterVersion) DeepCopy() *ClusterVersion {
if in == nil {
return nil
}
out := new(ClusterVersion)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Collect) DeepCopyInto(out *Collect) {
*out = *in
Expand Down Expand Up @@ -460,6 +496,36 @@ func (in *CollectorStatus) DeepCopy() *CollectorStatus {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Outcome) DeepCopyInto(out *Outcome) {
*out = *in
if in.Fail != nil {
in, out := &in.Fail, &out.Fail
*out = new(SingleOutcome)
**out = **in
}
if in.Warn != nil {
in, out := &in.Warn, &out.Warn
*out = new(SingleOutcome)
**out = **in
}
if in.Pass != nil {
in, out := &in.Pass, &out.Pass
*out = new(SingleOutcome)
**out = **in
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Outcome.
func (in *Outcome) DeepCopy() *Outcome {
if in == nil {
return nil
}
out := new(Outcome)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Preflight) DeepCopyInto(out *Preflight) {
*out = *in
Expand Down Expand Up @@ -675,7 +741,7 @@ func (in *PreflightSpec) DeepCopyInto(out *PreflightSpec) {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(Analyze)
**out = **in
(*in).DeepCopyInto(*out)
}
}
}
Expand Down Expand Up @@ -705,3 +771,44 @@ func (in *PreflightStatus) DeepCopy() *PreflightStatus {
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SingleOutcome) DeepCopyInto(out *SingleOutcome) {
*out = *in
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SingleOutcome.
func (in *SingleOutcome) DeepCopy() *SingleOutcome {
if in == nil {
return nil
}
out := new(SingleOutcome)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StorageClass) DeepCopyInto(out *StorageClass) {
*out = *in
if in.Outcome != nil {
in, out := &in.Outcome, &out.Outcome
*out = make([]*Outcome, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(Outcome)
(*in).DeepCopyInto(*out)
}
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClass.
func (in *StorageClass) DeepCopy() *StorageClass {
if in == nil {
return nil
}
out := new(StorageClass)
in.DeepCopyInto(out)
return out
}
17 changes: 9 additions & 8 deletions config/samples/troubleshoot_v1beta1_preflight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ metadata:
spec:
analyzers:
- clusterVersion:
fail:
when: "< 1.13.0"
message: You need more kubernetes
warn:
when: "< 1.15.0"
message: You have barely enough kubernetes
pass:
message: Good job keeping k8s current
outcomes:
- fail:
when: "< 1.13.0"
message: You need more kubernetes
- warn:
when: "< 1.15.0"
message: You have barely enough kubernetes
- pass:
message: Good job keeping k8s current
# - storageClass:
# name: "my-custom-storage-class"
# fail:
Expand Down
23 changes: 23 additions & 0 deletions pkg/apis/troubleshoot/v1beta1/analyzer_shared.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
package v1beta1

type SingleOutcome struct {
When string `json:"when,omitempty" yaml:"when,omitempty"`
Message string `json:"message,omitempty" yaml:"message,omitempty"`
URI string `json:"uri,omitempty" yaml:"uri,omitempty"`
}

type Outcome struct {
Fail *SingleOutcome `json:"fail,omitempty" yaml:"fail,omitempty"`
Warn *SingleOutcome `json:"warn,omitempty" yaml:"warn,omitempty"`
Pass *SingleOutcome `json:"pass,omitempty" yaml:"pass,omitempty"`
}

type ClusterVersion struct {
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
}

type StorageClass struct {
Outcome []*Outcome `json:"outcomes" yaml:"outcomes"`
Name string `json:"name" yaml:"name"`
}

type Analyze struct {
ClusterVersion *ClusterVersion `json:"clusterVersion,omitempty" yaml:"clusterVersion,omitempty"`
StorageClass *StorageClass `json:"storageClass,omitempty" yaml:"supportBundle,omitempty"`
}
Loading

0 comments on commit 978a4a1

Please sign in to comment.