Skip to content

Commit

Permalink
Merge pull request #608 from replicatedhq/divolgin/support
Browse files Browse the repository at this point in the history
Correct default analyzer structure
  • Loading branch information
divolgin committed May 29, 2020
2 parents 11f68ae + a317389 commit 1abab6e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kotsadm/pkg/handlers/troubleshoot.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handlers

import (
"bytes"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -30,6 +31,7 @@ import (
"github.com/replicatedhq/yaml/v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8sjson "k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/client-go/kubernetes/scheme"
)
Expand Down Expand Up @@ -214,14 +216,16 @@ func UploadSupportBundle(w http.ResponseWriter, r *http.Request) {
return
}

b, err := json.Marshal(analyzer)
if err != nil {
s := k8sjson.NewYAMLSerializer(k8sjson.DefaultMetaFactory, scheme.Scheme, scheme.Scheme)

var b bytes.Buffer
if err := s.Encode(analyzer, &b); err != nil {
logger.Error(err)
w.WriteHeader(500)
return
}

analyzeResult, err := troubleshootanalyze.DownloadAndAnalyze(tmpFile.Name(), string(b))
analyzeResult, err := troubleshootanalyze.DownloadAndAnalyze(tmpFile.Name(), b.String())
if err != nil {
logger.Error(err)
w.WriteHeader(500)
Expand Down
10 changes: 10 additions & 0 deletions kotsadm/pkg/supportbundle/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ func injectAPIReplicaAnalyzer(analyzer *troubleshootv1beta1.Analyzer) error {
When: "> 1",
Message: "At least 2 replicas of the Admin Console API is running and ready",
},
},
{
Warn: &troubleshootv1beta1.SingleOutcome{
When: "= 1",
Message: "Only 1 replica of the Admin Console API is running and ready",
},
},
{
Fail: &troubleshootv1beta1.SingleOutcome{
When: "= 0",
Message: "There are no replicas of the Admin Console API running and ready",
Expand All @@ -86,6 +90,8 @@ func injectOperatorReplicaAnalyzer(analyzer *troubleshootv1beta1.Analyzer) error
When: "= 1",
Message: "Exactly 1 replica of the Admin Console Operator is running and ready",
},
},
{
Fail: &troubleshootv1beta1.SingleOutcome{
Message: "There is not exactly 1 replica of the Admin Console Operator running and ready",
},
Expand All @@ -105,6 +111,8 @@ func injectNoGvisorAnalyzer(analyzer *troubleshootv1beta1.Analyzer) error {
When: "== gvisor",
Message: "The Admin Console does not support using the gvisor runtime",
},
},
{
Pass: &troubleshootv1beta1.SingleOutcome{
Message: "A supported container runtime is present on all nodes",
},
Expand All @@ -130,6 +138,8 @@ func injectIfMissingKubernetesVersionAnalyzer(analyzer *troubleshootv1beta1.Anal
When: "< 1.16.0",
Message: "The Admin Console requires at least Kubernetes 1.16.0",
},
},
{
Pass: &troubleshootv1beta1.SingleOutcome{
Message: "Your cluster meets the recommended and required versions of Kubernetes",
},
Expand Down
4 changes: 4 additions & 0 deletions kotsadm/pkg/supportbundle/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ func CreateBundleForBackup(appID string, backupName string, backupNamespace stri
Fail: &troubleshootv1beta1.SingleOutcome{
Message: "Velero has errors",
},
},
{
Pass: &troubleshootv1beta1.SingleOutcome{
Message: "Velero does not have errors",
},
Expand All @@ -174,6 +176,8 @@ func CreateBundleForBackup(appID string, backupName string, backupNamespace stri
Fail: &troubleshootv1beta1.SingleOutcome{
Message: "Restic volume error",
},
},
{
Pass: &troubleshootv1beta1.SingleOutcome{
Message: "No restic volume error",
},
Expand Down

0 comments on commit 1abab6e

Please sign in to comment.