Move support logs to admin logs (#4381)
This commit is contained in:
@@ -47,12 +47,12 @@ var adminConsoleCmd = cli.Command{
|
||||
Flags: append(adminConsoleFlags, globalFlags...),
|
||||
Hidden: true,
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: "This command is not supported now and replaced by 'support logs show' command. Please use 'mc support logs show'.\n",
|
||||
CustomHelpTemplate: "This command is not supported now and replaced by 'admin logs' command. Please use 'mc admin logs'.\n",
|
||||
}
|
||||
|
||||
// mainAdminConsole - the entry function of console command
|
||||
func mainAdminConsole(ctx *cli.Context) error {
|
||||
newCmd := []string{"mc support logs show"}
|
||||
newCmd := []string{"mc admin logs"}
|
||||
|
||||
var flgStr string
|
||||
|
||||
|
||||
@@ -46,6 +46,31 @@ var logsShowFlags = []cli.Flag{
|
||||
},
|
||||
}
|
||||
|
||||
var adminLogsCmd = cli.Command{
|
||||
Name: "logs",
|
||||
Usage: "show MinIO logs",
|
||||
OnUsageError: onUsageError,
|
||||
Action: mainAdminLogs,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(logsShowFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
USAGE:
|
||||
{{.HelpName}} [FLAGS] TARGET [NODENAME]
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Show logs for a MinIO server with alias 'myminio'
|
||||
{{.Prompt}} {{.HelpName}} myminio
|
||||
2. Show last 5 log entries for node 'node1' for a MinIO server with alias 'myminio'
|
||||
{{.Prompt}} {{.HelpName}} --last 5 myminio node1
|
||||
3. Show application errors in logs for a MinIO server with alias 'myminio'
|
||||
{{.Prompt}} {{.HelpName}} --type application myminio
|
||||
`,
|
||||
}
|
||||
|
||||
func checkLogsShowSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) == 0 || len(ctx.Args()) > 3 {
|
||||
showCommandHelpAndExit(ctx, 1) // last argument is exit code
|
||||
@@ -139,8 +164,8 @@ func (l logMessage) String() string {
|
||||
return fmt.Sprintf("%s\n", logMsg)
|
||||
}
|
||||
|
||||
// mainLogsShowConsole - the entry function of support logs show
|
||||
func mainLogsShowConsole(ctx *cli.Context) error {
|
||||
// mainAdminLogs - the entry function of admin logs
|
||||
func mainAdminLogs(ctx *cli.Context) error {
|
||||
// Check for command syntax
|
||||
checkLogsShowSyntax(ctx)
|
||||
console.SetColor("LogMessage", color.New(color.Bold, color.FgRed))
|
||||
@@ -55,6 +55,7 @@ var adminCmdSubcommands = []cli.Command{
|
||||
adminConsoleCmd,
|
||||
adminClusterCmd,
|
||||
adminRebalanceCmd,
|
||||
adminLogsCmd,
|
||||
}
|
||||
|
||||
var adminCmd = cli.Command{
|
||||
|
||||
@@ -310,6 +310,7 @@ var completeCmds = map[string]complete.Predictor{
|
||||
"/admin/heal": s3Completer,
|
||||
|
||||
"/admin/info": aliasCompleter,
|
||||
"/admin/logs": aliasCompleter,
|
||||
|
||||
"/admin/config/get": adminConfigCompleter,
|
||||
"/admin/config/set": adminConfigCompleter,
|
||||
@@ -449,7 +450,6 @@ var completeCmds = map[string]complete.Predictor{
|
||||
"/alias/import": nil,
|
||||
|
||||
"/support/callhome": aliasCompleter,
|
||||
"/support/logs": aliasCompleter,
|
||||
"/support/register": aliasCompleter,
|
||||
"/support/diag": aliasCompleter,
|
||||
"/support/profile": aliasCompleter,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/minio/cli"
|
||||
@@ -213,3 +214,26 @@ func setCallhomeConfig(alias string, enableCallhome bool) {
|
||||
_, e := client.SetConfigKV(globalContext, configStr)
|
||||
fatalIf(probe.NewError(e), "Unable to set callhome config on minio")
|
||||
}
|
||||
|
||||
func configureSubnetWebhook(alias string, enable bool) {
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(alias)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
var input string
|
||||
if enable {
|
||||
apiKey := validateClusterRegistered(alias, true)
|
||||
input = fmt.Sprintf("logger_webhook:subnet endpoint=%s auth_token=%s enable=on",
|
||||
subnetLogWebhookURL(), apiKey)
|
||||
} else {
|
||||
input = "logger_webhook:subnet enable=off"
|
||||
}
|
||||
|
||||
// Call set config API
|
||||
_, e := client.SetConfigKV(globalContext, input)
|
||||
fatalIf(probe.NewError(e), "Unable to set '%s' to server", input)
|
||||
}
|
||||
|
||||
func isLogsCallhomeEnabled(alias string) bool {
|
||||
return isFeatureEnabled(alias, "logger_webhook", "subnet")
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
// Copyright (c) 2015-2022 MinIO, Inc.
|
||||
//
|
||||
// This file is part of MinIO Object Storage stack
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var supportLogsCmd = cli.Command{
|
||||
Name: "logs",
|
||||
Usage: "show MinIO logs",
|
||||
OnUsageError: onUsageError,
|
||||
Action: mainLogsShowConsole,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(logsShowFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
USAGE:
|
||||
{{.HelpName}} [FLAGS] TARGET [NODENAME]
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Show logs for a MinIO server with alias 'myminio'
|
||||
{{.Prompt}} {{.HelpName}} myminio
|
||||
2. Show last 5 log entries for node 'node1' for a MinIO server with alias 'myminio'
|
||||
{{.Prompt}} {{.HelpName}} --last 5 myminio node1
|
||||
3. Show application errors in logs for a MinIO server with alias 'myminio'
|
||||
{{.Prompt}} {{.HelpName}} --type application myminio
|
||||
`,
|
||||
}
|
||||
|
||||
func configureSubnetWebhook(alias string, enable bool) {
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(alias)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
var input string
|
||||
if enable {
|
||||
apiKey := validateClusterRegistered(alias, true)
|
||||
input = fmt.Sprintf("logger_webhook:subnet endpoint=%s auth_token=%s enable=on",
|
||||
subnetLogWebhookURL(), apiKey)
|
||||
} else {
|
||||
input = "logger_webhook:subnet enable=off"
|
||||
}
|
||||
|
||||
// Call set config API
|
||||
_, e := client.SetConfigKV(globalContext, input)
|
||||
fatalIf(probe.NewError(e), "Unable to set '%s' to server", input)
|
||||
}
|
||||
|
||||
func isLogsCallhomeEnabled(alias string) bool {
|
||||
return isFeatureEnabled(alias, "logger_webhook", "subnet")
|
||||
}
|
||||
@@ -40,7 +40,6 @@ var supportGlobalFlags = append(globalFlags, cli.BoolFlag{
|
||||
var supportSubcommands = []cli.Command{
|
||||
supportRegisterCmd,
|
||||
supportCallhomeCmd,
|
||||
supportLogsCmd,
|
||||
supportDiagCmd,
|
||||
supportPerfCmd,
|
||||
supportInspectCmd,
|
||||
|
||||
Reference in New Issue
Block a user