CLOUD-535 gopath added, changed suumary func name

This commit is contained in:
Max Dudin
2020-08-05 13:59:46 +03:00
parent 212d2032ed
commit 61ba3c729e

View File

@@ -10,6 +10,7 @@ import (
"log" "log"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"strings" "strings"
"time" "time"
@@ -145,7 +146,7 @@ func (d *Dumper) DumpCluster() error {
} }
for _, pod := range pods.Items { for _, pod := range pods.Items {
location := d.location + "/" + ns.Name + "/" + pod.Name + "/logs.txt" location := filepath.Join(d.location, ns.Name, pod.Name, "logs.txt")
args := []string{"logs", pod.Name, "--namespace", ns.Name, "--all-containers"} args := []string{"logs", pod.Name, "--namespace", ns.Name, "--all-containers"}
output, err = d.runCmd(args...) output, err = d.runCmd(args...)
if err != nil { if err != nil {
@@ -164,14 +165,13 @@ func (d *Dumper) DumpCluster() error {
if len(pod.Labels) == 0 { if len(pod.Labels) == 0 {
continue continue
} }
location = filepath.Join(d.location, ns.Name, pod.Name, "/pt-summary.txt")
location = d.location + "/" + ns.Name + "/" + pod.Name + "/pt-summary.txt"
component := d.crType component := d.crType
if d.crType == "psmdb" { if d.crType == "psmdb" {
component = "mongod" component = "mongod"
} }
if pod.Labels["app.kubernetes.io/component"] == component { if pod.Labels["app.kubernetes.io/component"] == component {
output, err = d.getPTSummury(d.crType, pod.Name, pod.Labels["app.kubernetes.io/instance"], tw) output, err = d.getPodSummury(d.crType, pod.Name, pod.Labels["app.kubernetes.io/instance"], tw)
if err != nil { if err != nil {
d.logError(err.Error(), d.crType, pod.Name) d.logError(err.Error(), d.crType, pod.Name)
err = addToArchive(location, d.mode, []byte(err.Error()), tw) err = addToArchive(location, d.mode, []byte(err.Error()), tw)
@@ -223,9 +223,9 @@ func (d *Dumper) getResource(name, namespace string, tw *tar.Writer) error {
args := []string{"get", name, "-o", "yaml"} args := []string{"get", name, "-o", "yaml"}
if len(namespace) > 0 { if len(namespace) > 0 {
args = append(args, "--namespace", namespace) args = append(args, "--namespace", namespace)
location = d.location + "/" + namespace location = filepath.Join(d.location, namespace)
} }
location += "/" + name + ".yaml" location = filepath.Join(location, name+".yaml")
output, err := d.runCmd(args...) output, err := d.runCmd(args...)
if err != nil { if err != nil {
d.logError(err.Error(), args...) d.logError(err.Error(), args...)
@@ -265,7 +265,7 @@ type crSecrets struct {
} `json:"spec"` } `json:"spec"`
} }
func (d *Dumper) getPTSummury(resource, podName, crName string, tw *tar.Writer) ([]byte, error) { func (d *Dumper) getPodSummury(resource, podName, crName string, tw *tar.Writer) ([]byte, error) {
var ( var (
summCmdName string summCmdName string
ports string ports string