mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
CLOUD-535 gopath added, changed suumary func name
This commit is contained in:
@@ -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
|
||||||
|
Reference in New Issue
Block a user