Skip to content

Commit

Permalink
Add anonymize flag to support-diag (#4742)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjalshireesh authored Nov 8, 2023
1 parent 011c61b commit a5adf14
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions cmd/support-diag.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ import (
"github.com/tidwall/gjson"
)

const (
anonymizeFlag = "anonymize"
anonymizeStandard = "standard"
anonymizeStrict = "strict"
)

var supportDiagFlags = append([]cli.Flag{
HealthDataTypeFlag{
Name: "test",
Expand All @@ -54,6 +60,11 @@ var supportDiagFlags = append([]cli.Flag{
Value: 1 * time.Hour,
Hidden: true,
},
cli.StringFlag{
Name: anonymizeFlag,
Usage: "Data anonymization mode (standard|strict)",
Value: anonymizeStandard,
},
}, subnetCommonFlags...)

var supportDiagCmd = cli.Command{
Expand All @@ -79,6 +90,9 @@ EXAMPLES:
2. Generate MinIO diagnostics report for cluster with alias 'myminio', save and upload to SUBNET manually
{{.Prompt}} {{.HelpName}} myminio --airgap
3. Upload MinIO diagnostics report for cluster with alias 'myminio' to SUBNET, with strict anonymization
{{.Prompt}} {{.HelpName}} myminio --anonymize=strict
`,
}

Expand All @@ -87,6 +101,11 @@ func checkSupportDiagSyntax(ctx *cli.Context) {
if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 {
showCommandHelpAndExit(ctx, 1) // last argument is exit code
}

anon := ctx.String(anonymizeFlag)
if anon != anonymizeStandard && anon != anonymizeStrict {
fatal(errDummy().Trace(), "Invalid anonymization mode. Valid options are 'standard' or 'strict'.")
}
}

// compress and tar MinIO diagnostics output
Expand Down Expand Up @@ -326,8 +345,7 @@ func fetchServerDiagInfo(ctx *cli.Context, client *madmin.AdminClient) (interfac
}

// Fetch info of all servers (cluster or single server)
// TODO: allow configurable "anonymize" inputs
resp, version, e := client.ServerHealthInfo(cont, *opts, ctx.Duration("deadline"), "standard")
resp, version, e := client.ServerHealthInfo(cont, *opts, ctx.Duration("deadline"), ctx.String(anonymizeFlag))
if e != nil {
cancel()
return nil, "", e
Expand Down

0 comments on commit a5adf14

Please sign in to comment.