This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 558
Move artifacts gathering around #3154
Merged
acs-bot
merged 4 commits into
Azure:master
from
0xmichalis:move-artifacts-gathering-around
Jun 5, 2018
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,39 +107,25 @@ func TestHost(host string, maxRetries int, retryDelay time.Duration) error { | |
} | ||
|
||
// DumpNodes dumps information about nodes. | ||
func DumpNodes() (string, error) { | ||
func DumpNodes() string { | ||
cmd := exec.Command("oc", "get", "nodes", "-o", "wide") | ||
printCmd(cmd) | ||
out, err := cmd.CombinedOutput() | ||
if err != nil { | ||
log.Printf("Error trying to list nodes: %s", string(out)) | ||
return "", err | ||
log.Printf("Error trying to list nodes: %v", err) | ||
} | ||
return string(out), nil | ||
return string(out) | ||
} | ||
|
||
// DumpPods dumps the pods from all namespaces. | ||
func DumpPods() (string, error) { | ||
func DumpPods() string { | ||
cmd := exec.Command("oc", "get", "pods", "--all-namespaces", "-o", "wide") | ||
printCmd(cmd) | ||
out, err := cmd.CombinedOutput() | ||
if err != nil { | ||
log.Printf("Error trying to list pods from all namespaces: %s", string(out)) | ||
return "", err | ||
} | ||
return string(out), nil | ||
} | ||
|
||
// RunDiagnostics runs the openshift diagnostics command. | ||
func RunDiagnostics() (string, error) { | ||
cmd := exec.Command("oc", "adm", "diagnostics") | ||
printCmd(cmd) | ||
out, err := cmd.CombinedOutput() | ||
if err != nil { | ||
log.Printf("Error trying to run diagnostics: %s", string(out)) | ||
return "", err | ||
log.Printf("Error trying to list pods from all namespaces: %v", err) | ||
} | ||
return string(out), nil | ||
return string(out) | ||
} | ||
|
||
// FetchLogs returns logs for the provided kind/name in namespace. | ||
|
@@ -153,6 +139,27 @@ func FetchLogs(kind, namespace, name string) string { | |
return string(out) | ||
} | ||
|
||
// FetchClusterInfo returns node and pod information about the cluster. | ||
func FetchClusterInfo(logPath string) { | ||
needsLog := map[string]string{ | ||
"node-info": DumpNodes(), | ||
"pod-info": DumpPods(), | ||
} | ||
|
||
var errs []error | ||
for base, log := range needsLog { | ||
path := filepath.Join(logPath, base) | ||
err := ioutil.WriteFile(path, []byte(log), 0644) | ||
if err != nil { | ||
errs = append(errs, err) | ||
} | ||
} | ||
|
||
if err := kerrors.NewAggregate(errs); err != nil { | ||
log.Printf("Cannot fetch node and pod info: %v", err) | ||
} | ||
} | ||
|
||
// FetchOpenShiftLogs returns logs for all OpenShift components | ||
// (control plane and infra). | ||
func FetchOpenShiftLogs(distro, version, sshKeyPath, adminName, name, location, logPath string) { | ||
|
@@ -174,7 +181,8 @@ func fetchControlPlaneLogs(distro, version, sshKeyPath, adminName, name, locatio | |
case common.OpenShiftVersionUnstable: | ||
return fetchUnstableControlPlaneLogs(distro, sshKeyPath, sshAddress, name, logPath) | ||
default: | ||
panic(fmt.Sprintf("BUG: invalid OpenShift version %s", version)) | ||
log.Printf("Invalid OpenShift version %q - won't gather logs from the control plane", version) | ||
return nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as discussed - return fmt.Errorf() here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy for this to merge, but you don't think
map[string]func() error
would be a better foundation here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strong either way, updated to your suggestion (which needs to be
map[string]func() string
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apols, I meant
map[string]func() (string, error)
- in which case the changes to the other functions aren't needed and they're more reusableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack, updated