mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Merge pull request #764 from jobinau/3.x
All complexities and failure senarios are removed, No more dependancies
This commit is contained in:
@@ -422,76 +422,14 @@ func (d *Dumper) getPodSummary(resource, podName, crName string, namespace strin
|
|||||||
ports = port + ":3306"
|
ports = port + ":3306"
|
||||||
summCmdName = "pt-mysql-summary"
|
summCmdName = "pt-mysql-summary"
|
||||||
summCmdArgs = []string{"--host=127.0.0.1", "--port=" + port, "--user=root", "--password='" + string(pass) + "'"}
|
summCmdArgs = []string{"--host=127.0.0.1", "--port=" + port, "--user=root", "--password='" + string(pass) + "'"}
|
||||||
case "pg":
|
case "pg","pgv2":
|
||||||
var user, pass, port string
|
var kubeconfig string=""
|
||||||
if d.forwardport != "" {
|
if d.kubeconfig != "" {
|
||||||
port = d.forwardport
|
kubeconfig=" --kubeconfig=" + d.kubeconfig
|
||||||
} else {
|
|
||||||
port = "5432"
|
|
||||||
}
|
}
|
||||||
cr, err := d.getCR("pgclusters", namespace)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "get cr")
|
|
||||||
}
|
|
||||||
if cr.Spec.SecretName != "" {
|
|
||||||
user, err = d.getDataFromSecret(cr.Spec.SecretName, "username", namespace)
|
|
||||||
} else {
|
|
||||||
user, err = d.getDataFromSecret(crName+"-postgres-secret", "username", namespace)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "get user from PostgreSQL users secret")
|
|
||||||
}
|
|
||||||
if cr.Spec.SecretName != "" {
|
|
||||||
pass, err = d.getDataFromSecret(cr.Spec.SecretName, "password", namespace)
|
|
||||||
} else {
|
|
||||||
pass, err = d.getDataFromSecret(crName+"-postgres-secret", "password", namespace)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "get password from PostgreSQL users secret")
|
|
||||||
}
|
|
||||||
ports = port + ":5432"
|
|
||||||
summCmdName = "sh"
|
summCmdName = "sh"
|
||||||
summCmdArgs = []string{"-c", "curl https://raw.githubusercontent.com/percona/support-snippets/master/postgresql/pg_gather/gather.sql" +
|
summCmdArgs = []string{"-c", "curl https://raw.githubusercontent.com/percona/support-snippets/master/postgresql/pg_gather/gather.sql 2>/dev/null | " +
|
||||||
" 2>/dev/null | PGPASSWORD='" + string(pass) + "' psql -X --host=127.0.0.1 --port=" + port + " --user='" + user + "'"}
|
d.cmd + kubeconfig + " -n "+ namespace + " exec -i "+ podName +" -- psql -X -f - "}
|
||||||
case "pgv2":
|
|
||||||
var user, pass, port string
|
|
||||||
if d.forwardport != "" {
|
|
||||||
port = d.forwardport
|
|
||||||
} else {
|
|
||||||
port = "5432"
|
|
||||||
}
|
|
||||||
cr, err := d.getCR("perconapgclusters/"+crName, namespace)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "get cr")
|
|
||||||
}
|
|
||||||
if cr.Spec.SecretName != "" {
|
|
||||||
user, err = d.getDataFromSecret(cr.Spec.SecretName, "user", namespace)
|
|
||||||
} else if len(cr.Spec.Users) > 0 && cr.Spec.Users[0].Name != "" {
|
|
||||||
user = cr.Spec.Users[0].Name
|
|
||||||
} else {
|
|
||||||
user, err = d.getDataFromSecret(crName+"-pguser-"+crName, "user", namespace)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "get user from PostgreSQL users secret")
|
|
||||||
}
|
|
||||||
if cr.Spec.SecretName != "" {
|
|
||||||
pass, err = d.getDataFromSecret(cr.Spec.SecretName, "password", namespace)
|
|
||||||
} else if len(cr.Spec.Users) > 0 {
|
|
||||||
if cr.Spec.Users[0].SecretName != "" {
|
|
||||||
pass, err = d.getDataFromSecret(cr.Spec.Users[0].SecretName, "password", namespace)
|
|
||||||
} else {
|
|
||||||
pass, err = d.getDataFromSecret(crName+"-pguser-"+user, "password", namespace)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pass, err = d.getDataFromSecret(crName+"-pguser-"+crName, "password", namespace)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "get password from PostgreSQL users secret")
|
|
||||||
}
|
|
||||||
ports = port + ":5432"
|
|
||||||
summCmdName = "sh"
|
|
||||||
summCmdArgs = []string{"-c", "curl https://raw.githubusercontent.com/percona/support-snippets/master/postgresql/pg_gather/gather.sql" +
|
|
||||||
" 2>/dev/null | PGPASSWORD='" + string(pass) + "' psql -X --host=127.0.0.1 --port=" + port + " --user='" + user + "'"}
|
|
||||||
case "psmdb":
|
case "psmdb":
|
||||||
var port string
|
var port string
|
||||||
if d.forwardport != "" {
|
if d.forwardport != "" {
|
||||||
|
@@ -244,11 +244,11 @@ func TestPT_2169(t *testing.T) {
|
|||||||
kubeconfig string
|
kubeconfig string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "pg with busy port",
|
name: "pxc with busy port",
|
||||||
resource: "pg",
|
resource: "pxc",
|
||||||
want: "3",
|
want: "3",
|
||||||
port: busyport,
|
port: busyport,
|
||||||
kubeconfig: os.Getenv("KUBECONFIG_PG"),
|
kubeconfig: os.Getenv("KUBECONFIG_PXC"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pg no error",
|
name: "pg no error",
|
||||||
|
Reference in New Issue
Block a user