mirror of
https://github.com/minio/minio.git
synced 2025-11-06 20:33:07 -05:00
remove safeMode behavior in startup (#10645)
In almost all scenarios MinIO now is mostly ready for all sub-systems independently, safe-mode is not useful anymore and do not serve its original intended purpose. allow server to be fully functional even with config partially configured, this is to cater for availability of actual I/O v/s manually fixing the server. In k8s like environments it will never make sense to take pod into safe-mode state, because there is no real access to perform any remote operation on them.
This commit is contained in:
@@ -32,13 +32,12 @@ import (
|
||||
|
||||
// Documentation links, these are part of message printing code.
|
||||
const (
|
||||
mcQuickStartGuide = "https://docs.min.io/docs/minio-client-quickstart-guide"
|
||||
mcAdminQuickStartGuide = "https://docs.min.io/docs/minio-admin-complete-guide.html"
|
||||
goQuickStartGuide = "https://docs.min.io/docs/golang-client-quickstart-guide"
|
||||
jsQuickStartGuide = "https://docs.min.io/docs/javascript-client-quickstart-guide"
|
||||
javaQuickStartGuide = "https://docs.min.io/docs/java-client-quickstart-guide"
|
||||
pyQuickStartGuide = "https://docs.min.io/docs/python-client-quickstart-guide"
|
||||
dotnetQuickStartGuide = "https://docs.min.io/docs/dotnet-client-quickstart-guide"
|
||||
mcQuickStartGuide = "https://docs.min.io/docs/minio-client-quickstart-guide"
|
||||
goQuickStartGuide = "https://docs.min.io/docs/golang-client-quickstart-guide"
|
||||
jsQuickStartGuide = "https://docs.min.io/docs/javascript-client-quickstart-guide"
|
||||
javaQuickStartGuide = "https://docs.min.io/docs/java-client-quickstart-guide"
|
||||
pyQuickStartGuide = "https://docs.min.io/docs/python-client-quickstart-guide"
|
||||
dotnetQuickStartGuide = "https://docs.min.io/docs/dotnet-client-quickstart-guide"
|
||||
)
|
||||
|
||||
// generates format string depending on the string length and padding.
|
||||
@@ -52,65 +51,13 @@ func mustGetStorageInfo(objAPI ObjectLayer) StorageInfo {
|
||||
return storageInfo
|
||||
}
|
||||
|
||||
func printStartupSafeModeMessage(apiEndpoints []string, err error) {
|
||||
logStartupMessage(color.RedBold("Server startup failed with '%v'", err))
|
||||
logStartupMessage(color.RedBold("Server switching to safe mode"))
|
||||
logStartupMessage(color.RedBold("Please use 'mc admin config' commands fix this issue"))
|
||||
|
||||
// Object layer is initialized then print StorageInfo in safe mode.
|
||||
objAPI := newObjectLayerWithoutSafeModeFn()
|
||||
if objAPI != nil {
|
||||
if msg := getStorageInfoMsgSafeMode(mustGetStorageInfo(objAPI)); msg != "" {
|
||||
logStartupMessage(msg)
|
||||
}
|
||||
}
|
||||
|
||||
// Get saved credentials.
|
||||
cred := globalActiveCred
|
||||
|
||||
// Get saved region.
|
||||
region := globalServerRegion
|
||||
|
||||
strippedAPIEndpoints := stripStandardPorts(apiEndpoints)
|
||||
|
||||
apiEndpointStr := strings.Join(strippedAPIEndpoints, " ")
|
||||
|
||||
// Colorize the message and print.
|
||||
logStartupMessage(color.Red("Endpoint: ") + color.Bold(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 1), apiEndpointStr)))
|
||||
if color.IsTerminal() && !globalCLIContext.Anonymous {
|
||||
logStartupMessage(color.Red("AccessKey: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey)))
|
||||
logStartupMessage(color.Red("SecretKey: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey)))
|
||||
if region != "" {
|
||||
logStartupMessage(color.Red("Region: ") + color.Bold(fmt.Sprintf(getFormatStr(len(region), 3), region)))
|
||||
}
|
||||
}
|
||||
|
||||
// Prints `mc` cli configuration message chooses
|
||||
// first endpoint as default.
|
||||
alias := "myminio"
|
||||
endPoint := strippedAPIEndpoints[0]
|
||||
|
||||
// Configure 'mc', following block prints platform specific information for minio client admin commands.
|
||||
if color.IsTerminal() && !globalCLIContext.Anonymous {
|
||||
logStartupMessage(color.RedBold("\nCommand-line Access: ") + mcAdminQuickStartGuide)
|
||||
if runtime.GOOS == globalWindowsOSName {
|
||||
mcMessage := fmt.Sprintf("> mc.exe alias set %s %s %s %s --api s3v4", alias,
|
||||
endPoint, cred.AccessKey, cred.SecretKey)
|
||||
logStartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
|
||||
mcMessage = "> mc.exe admin config --help"
|
||||
logStartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
|
||||
} else {
|
||||
mcMessage := fmt.Sprintf("$ mc alias set %s %s %s %s --api s3v4", alias,
|
||||
endPoint, cred.AccessKey, cred.SecretKey)
|
||||
logStartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
|
||||
mcMessage = "$ mc admin config --help"
|
||||
logStartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prints the formatted startup message.
|
||||
func printStartupMessage(apiEndpoints []string) {
|
||||
func printStartupMessage(apiEndpoints []string, err error) {
|
||||
if err != nil {
|
||||
logStartupMessage(color.RedBold("Server startup failed with '%v'", err))
|
||||
logStartupMessage(color.RedBold("Not all features may be available on this server"))
|
||||
logStartupMessage(color.RedBold("Please use 'mc admin' commands to further investigate this issue"))
|
||||
}
|
||||
|
||||
strippedAPIEndpoints := stripStandardPorts(apiEndpoints)
|
||||
// If cache layer is enabled, print cache capacity.
|
||||
@@ -254,23 +201,6 @@ func printObjectAPIMsg() {
|
||||
logStartupMessage(color.Blue(" .NET: ") + fmt.Sprintf(getFormatStr(len(dotnetQuickStartGuide), 6), dotnetQuickStartGuide))
|
||||
}
|
||||
|
||||
// Get formatted disk/storage info message.
|
||||
func getStorageInfoMsgSafeMode(storageInfo StorageInfo) string {
|
||||
var msg string
|
||||
var mcMessage string
|
||||
if storageInfo.Backend.Type == BackendErasure {
|
||||
if storageInfo.Backend.OfflineDisks.Sum() > 0 {
|
||||
mcMessage = "Use `mc admin info` to look for latest server/disk info\n"
|
||||
}
|
||||
diskInfo := fmt.Sprintf(" %d Online, %d Offline. ", storageInfo.Backend.OnlineDisks.Sum(), storageInfo.Backend.OfflineDisks.Sum())
|
||||
msg += color.Red("Status:") + fmt.Sprintf(getFormatStr(len(diskInfo), 8), diskInfo)
|
||||
}
|
||||
if len(mcMessage) > 0 {
|
||||
msg = fmt.Sprintf("%s %s", mcMessage, msg)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
// Get formatted disk/storage info message.
|
||||
func getStorageInfoMsg(storageInfo StorageInfo) string {
|
||||
var msg string
|
||||
|
||||
Reference in New Issue
Block a user