PT-2302 - pt-k8s-debug-collector cannot pass properly to pt-mysql-summary PXC root password with special characters

- Merge branch '3.x' into PT-2302_pt-k8s-debug-collector_cannot_pass_properly_to_pt-mysql-summary_PXC_root_password_with_special_characters
- Implement fix for MongoDB
This commit is contained in:
Sveta Smirnova
2024-04-19 14:50:38 +03:00
32 changed files with 311 additions and 46 deletions

View File

@@ -186,7 +186,7 @@ services:
image: ${TEST_MONGODB_IMAGE:-mongo:4.2}
ports:
- "${TEST_MONGODB_STANDALONE_PORT:-27017}:27017"
command: mongod --replSet rs1 --shardsvr --port 27017 --oplogSize 16
command: mongod --port 27017 --oplogSize 16
postgres9:
image: ${POSTGRE_IMAGE:-postgres:9.6}
container_name: go_postgres9_1

View File

@@ -73,15 +73,15 @@ func checkUpdates(url string, timeout time.Duration, toolName, version string) (
if err != nil {
return "", err
}
advices := []Advice{}
err = json.Unmarshal(body, &advices)
var advice []Advice
err = json.Unmarshal(body, &advice)
if err != nil {
return "", err
}
for _, advice := range advices {
if advice.ToolName == PERCONA_TOOLKIT {
return advice.Advice, nil
for _, a := range advice {
if a.ToolName == PERCONA_TOOLKIT {
return a.Advice, nil
}
}

View File

@@ -16,7 +16,7 @@ func TestCheckUpdates(t *testing.T) {
body, _ := ioutil.ReadAll(r.Body)
m := strings.Split(string(body), ";")
advices := []Advice{
advice := []Advice{
{
Hash: m[0],
ToolName: m[1],
@@ -24,7 +24,7 @@ func TestCheckUpdates(t *testing.T) {
},
}
buf, _ := json.Marshal(advices)
buf, _ := json.Marshal(advice)
w.Header().Set("Content-Type", "application/json")
fmt.Fprint(w, string(buf))
}))

View File

@@ -451,7 +451,7 @@ func (d *Dumper) getPodSummary(resource, podName, crName string, namespace strin
}
ports = port + ":27017"
summCmdName = "pt-mongodb-summary"
summCmdArgs = []string{"--username='" + user + "'", "--password=" + pass, "--authenticationDatabase=admin", "127.0.0.1:" + port}
summCmdArgs = []string{"--username=" + user, "--password=" + string(pass), "--authenticationDatabase=admin", "127.0.0.1:" + port}
}
cmdPortFwd := exec.Command(d.cmd, "port-forward", "pod/"+podName, ports, "-n", namespace, "--kubeconfig", d.kubeconfig)

View File

@@ -374,14 +374,14 @@ func getHostInfo(ctx context.Context, client *mongo.Client) (*hostInfo, error) {
}
cmdOpts := proto.CommandLineOptions{}
query := primitive.D{{Key: "getCmdLineOpts", Value: 1}, {Key: "recordStats", Value: 1}}
query := primitive.D{{Key: "getCmdLineOpts", Value: 1}}
err := client.Database("admin").RunCommand(ctx, query).Decode(&cmdOpts)
if err != nil {
return nil, errors.Wrap(err, "cannot get command line options")
}
ss := proto.ServerStatus{}
query = primitive.D{{Key: "serverStatus", Value: 1}, {Key: "recordStats", Value: 1}}
query = primitive.D{{Key: "serverStatus", Value: 1}}
if err := client.Database("admin").RunCommand(ctx, query).Decode(&ss); err != nil {
return nil, errors.Wrap(err, "GetHostInfo.serverStatus")
}
@@ -528,7 +528,6 @@ func getSecuritySettings(ctx context.Context, client *mongo.Client, ver string)
cmdOpts := proto.CommandLineOptions{}
err = client.Database("admin").RunCommand(ctx, primitive.D{
{Key: "getCmdLineOpts", Value: 1},
{Key: "recordStats", Value: 1},
}).Decode(&cmdOpts)
if err != nil {
return nil, errors.Wrap(err, "cannot get command line options")
@@ -633,7 +632,6 @@ func getOpCountersStats(ctx context.Context, client *mongo.Client, count int,
err := client.Database("admin").RunCommand(ctx, primitive.D{
{Key: "serverStatus", Value: 1},
{Key: "recordStats", Value: 1},
}).Decode(&ss)
if err != nil {
return nil, err