Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Riddle <driddle@vmware.com>
  • Loading branch information
joyvuu-dave committed Nov 18, 2022
1 parent 2a99c18 commit a4cf1b5
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 35 deletions.
4 changes: 3 additions & 1 deletion pkg/client/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ func getPodsToStreamLogs(client kubernetes.Interface, cfg *LogConfig, podCh chan
}

// watchPodsToStreamLogs creates a watch for the desired pods and, as it gets events for new pods will add them onto the pod channel.
// If a plugin name has been provided, retrieve the pods with only the plugin label matching that plugin name. If no pods are found,
//
// If a plugin name has been provided, retrieve the pods with only the plugin label matching that plugin name. If no pods are found,
//
// or no plugin has been specified, retrieve all pods within the namespace. It will return an error if unable to create the watcher
// but will continue to add pods to the channel in a separate go routine.
func watchPodsToStreamLogs(client kubernetes.Interface, cfg *LogConfig, podCh chan *v1.Pod) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
10 changes: 6 additions & 4 deletions pkg/client/results/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ func hasCustomValues(items ...Item) bool {

// AggregateStatus defines the aggregation rules for status according to the following rules:
// If only pass/fail/unknown values are found, we apply very basic rules:
// - failure + * = failure
// - unknown + [pass|unknown] = unknown
// - empty list = unknown
// - failure + * = failure
// - unknown + [pass|unknown] = unknown
// - empty list = unknown
//
// If we find other values (e.g. from manual results typically) then we just combine/count them:
// - foo + bar = 'foo: 1, bar:1'
// - foo + bar = 'foo: 1, bar:1'
//
// useCustom is specified rather than looking for custom values because different branches of the
// result tree may have/not have those values. So instead, we should look down the tree initially to decide.
func AggregateStatus(useCustom bool, items ...Item) string {
Expand Down
1 change: 0 additions & 1 deletion pkg/client/results/reader_unix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || nacl || netbsd || openbsd || solaris
// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris

/*
Copyright 2018 Heptio Inc.
Expand Down
1 change: 0 additions & 1 deletion pkg/client/results/reader_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build windows
// +build windows

/*
Copyright 2018 Heptio Inc.
Expand Down
3 changes: 1 addition & 2 deletions pkg/client/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ import (
"github.com/sirupsen/logrus"
"github.com/vmware-tanzu/sonobuoy/pkg/plugin/aggregation"
"golang.org/x/term"
corev1 "k8s.io/api/core/v1"
kubeerror "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/kubernetes/scheme"
corev1 "k8s.io/api/core/v1"
)

const (
Expand Down Expand Up @@ -307,7 +307,6 @@ func humanReadableStatus(str string) string {
}
}


func getPodStatus(pod corev1.Pod) string {
const ContainersNotReady = "ContainersNotReady"
if pod.Status.Phase != corev1.PodRunning && pod.Status.Phase != corev1.PodSucceeded {
Expand Down
6 changes: 3 additions & 3 deletions pkg/client/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
package client

import (
"os"
"strings"
"encoding/json"
"reflect"
corev1 "k8s.io/api/core/v1"
"os"
"reflect"
"strings"
"testing"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/discovery/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ func ReadPodHealth(r *results.Reader) (HealthInfo, error) {
return health, nil
}

//ReadHealthSummary reads the core_v1_nodes.json file from ClusterResourceLocation
//and returns a summary of the health fo the cluster, ready to be saved
//tarballRootDir is the directory that will be used to provide the contents of the tarball
// ReadHealthSummary reads the core_v1_nodes.json file from ClusterResourceLocation
// and returns a summary of the health fo the cluster, ready to be saved
// tarballRootDir is the directory that will be used to provide the contents of the tarball
func ReadHealthSummary(tarballRootDir string) (ClusterSummary, error) {
summary := ClusterSummary{}
nodes := &v1.NodeList{}
Expand Down
16 changes: 8 additions & 8 deletions pkg/plugin/aggregation/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ func (t *timeoutErr) Error() string { return t.e.Error() }
//
// Basic workflow:
//
// 1. Create the aggregator object (`aggr`) to keep track of results
// 2. Launch the HTTP server with the aggr's HandleHTTPResult function as the
// callback
// 3. Run all the aggregation plugins, monitoring each one in a goroutine,
// configuring them to send failure results through a shared channel
// 4. Hook the shared monitoring channel up to aggr's IngestResults() function
// 5. Block until aggr shows all results accounted for (results come in through
// the HTTP callback), stopping the HTTP server on completion
// 1. Create the aggregator object (`aggr`) to keep track of results
// 2. Launch the HTTP server with the aggr's HandleHTTPResult function as the
// callback
// 3. Run all the aggregation plugins, monitoring each one in a goroutine,
// configuring them to send failure results through a shared channel
// 4. Hook the shared monitoring channel up to aggr's IngestResults() function
// 5. Block until aggr shows all results accounted for (results come in through
// the HTTP callback), stopping the HTTP server on completion
func Run(client kubernetes.Interface, plugins []plugin.Interface, cfg plugin.AggregationConfig, progressPort, pluginResultsDir, namespace, outdir string) error {
// Construct a list of things we'll need to dispatch
if len(plugins) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/driver/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestCreateWorkerContainerDefinition(t *testing.T) {
},
}
expectedEnvVars = append(expectedEnvVars, presetPluginEnv...)

for _, e := range expectedEnvVars {
if !envContains(container.Env, e) {
return fmt.Errorf("expected container environment to contain %q", e)
Expand Down
1 change: 0 additions & 1 deletion pkg/plugin/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ func (s ProgressUpdate) Key() string {
// Corresponding to S = ProgressUpdate.Completed, F = len(ProgressUpdate.Failures),
// and ProgressUpdate.Total - S - F respectively
// and the ", Remaining: R" part is printed only if R is not negative
//
func (s *ProgressUpdate) FormatPluginProgress() (output string) {
//Minumum size of each field, in characters
minSize := 3
Expand Down
14 changes: 7 additions & 7 deletions pkg/plugin/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,34 @@ func TestCombineUpdates(t *testing.T) {
func TestProgressUpdateFormatting(t *testing.T) {
testCases := []struct {
desc string
p ProgressUpdate
p ProgressUpdate
expect string
}{
{
desc: "Zero total should produce NO 'Remaining:'",
p: ProgressUpdate{Node: "nonempty", Completed: 1, Failures: []string{"c", "d"}, Message: "bar"},
p: ProgressUpdate{Node: "nonempty", Completed: 1, Failures: []string{"c", "d"}, Message: "bar"},
expect: "Passed: 1, Failed: 2",
}, {
desc: "When Total matches the total, Remaining SHOULD printed",
p: ProgressUpdate{Node: "nonempty", Completed: 1, Total: 3, Failures: []string{"c", "d"}, Message: "bar"},
p: ProgressUpdate{Node: "nonempty", Completed: 1, Total: 3, Failures: []string{"c", "d"}, Message: "bar"},
expect: "Passed: 1, Failed: 2, Remaining: 0",
}, {
desc: "When Total is less than failures+completed, Remaining should NOT be printed",
p: ProgressUpdate{Node: "nonempty", Completed: 2, Total: 1, Failures: []string{"c"}, Message: "bar"},
p: ProgressUpdate{Node: "nonempty", Completed: 2, Total: 1, Failures: []string{"c"}, Message: "bar"},
expect: "Passed: 2, Failed: 1",
}, {
desc: "When Total is more than failures+completed, Remaining SHOULD be printed",
p: ProgressUpdate{Node: "nonempty", Completed: 2, Total: 50, Failures: []string{"c", "d"}, Message: "bar"},
p: ProgressUpdate{Node: "nonempty", Completed: 2, Total: 50, Failures: []string{"c", "d"}, Message: "bar"},
expect: "Passed: 2, Failed: 2, Remaining: 46",
}, {
desc: "When total is negative, Remaining should NOT be printed",
p: ProgressUpdate{Node: "nonempty", Completed: 2, Total: -1, Failures: []string{"c", "d"}, Message: "bar"},
p: ProgressUpdate{Node: "nonempty", Completed: 2, Total: -1, Failures: []string{"c", "d"}, Message: "bar"},
expect: "Passed: 2, Failed: 2",
},
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
if got := tc.p.FormatPluginProgress(); got != tc.expect{
if got := tc.p.FormatPluginProgress(); got != tc.expect {
t.Fatalf("\n\n%s: expected '%s', got '%s'\n", tc.desc, tc.expect, got)
}
})
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_funcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,4 @@ update_cli_docs() {
mkdir -p "${output}"
echo "Generating new docs..."
./sonobuoy gen cli "${output}"
}
}
2 changes: 1 addition & 1 deletion test/integration/testdata/issue1688.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ spec:
targetPort: 8080
selector:
sonobuoy-component: aggregator
type: ClusterIP
type: ClusterIP

0 comments on commit a4cf1b5

Please sign in to comment.