reason.go 16.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
/*
Copyright 2020 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
Copyright 2020 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the Kind{ID: "License", ExitCode: });
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an Kind{ID: "AS IS", ExitCode: } BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package reason

import (
	"fmt"

	"k8s.io/minikube/pkg/minikube/style"
)

const issueBase = "https://github.com/kubernetes/minikube/issues"

// Kind describes reason metadata
type Kind struct {
	// ID is an unique and stable string describing a reason
	ID string
	// ExitCode to be used (defaults to 1)
	ExitCode int
	// Style is what emoji prefix to use for this reason
	Style style.Enum

	// Advice is actionable text that the user should follow
	Advice string
	// URL is a reference URL for more information
	URL string
	// Issues are a list of related issues to this issue
	Issues []int
	// Show the new issue link
	NewIssueLink bool
	// Do not attempt to match this reason to a specific known issue
	NoMatch bool
}

64
// IssueURLs returns URLs for issues
65 66 67 68 69 70 71 72 73 74
func (k *Kind) IssueURLs() []string {
	is := []string{}
	for _, i := range k.Issues {
		is = append(is, fmt.Sprintf("%s/%d", issueBase, i))
	}
	return is
}

// Sections are ordered roughly by stack dependencies
var (
M
Medya Gh 已提交
75 76 77 78 79 80
	Usage                 = Kind{ID: "MK_USAGE", ExitCode: ExProgramUsage}
	UsageNoProfileRunning = Kind{ID: "MK_USAGE_NO_PROFILE", ExitCode: ExProgramUsage,
		Advice: `You can create one using 'minikube start'.
		`,
		Style: style.Caching,
	}
81 82
	Interrupted = Kind{ID: "MK_INTERRUPTED", ExitCode: ExProgramConflict}

83 84
	WrongBinaryWSL = Kind{ID: "MK_WRONG_BINARY_WSL", ExitCode: ExProgramUnsupported}

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
	NewAPIClient             = Kind{ID: "MK_NEW_APICLIENT", ExitCode: ExProgramError}
	InternalAddonEnable      = Kind{ID: "MK_ADDON_ENABLE", ExitCode: ExProgramError}
	InternalAddConfig        = Kind{ID: "MK_ADD_CONFIG", ExitCode: ExProgramError}
	InternalBindFlags        = Kind{ID: "MK_BIND_FLAGS", ExitCode: ExProgramError}
	InternalBootstrapper     = Kind{ID: "MK_BOOTSTRAPPER", ExitCode: ExProgramError}
	InternalCacheList        = Kind{ID: "MK_CACHE_LIST", ExitCode: ExProgramError}
	InternalCacheLoad        = Kind{ID: "MK_CACHE_LOAD", ExitCode: ExProgramError}
	InternalCommandRunner    = Kind{ID: "MK_COMMAND_RUNNER", ExitCode: ExProgramError}
	InternalCompletion       = Kind{ID: "MK_COMPLETION", ExitCode: ExProgramError}
	InternalConfigSet        = Kind{ID: "MK_CONFIG_SET", ExitCode: ExProgramError}
	InternalConfigUnset      = Kind{ID: "MK_CONFIG_UNSET", ExitCode: ExProgramError}
	InternalConfigView       = Kind{ID: "MK_CONFIG_VIEW", ExitCode: ExProgramError}
	InternalDelConfig        = Kind{ID: "MK_DEL_CONFIG", ExitCode: ExProgramError}
	InternalDisable          = Kind{ID: "MK_DISABLE", ExitCode: ExProgramError}
	InternalDockerScript     = Kind{ID: "MK_DOCKER_SCRIPT", ExitCode: ExProgramError}
	InternalEnable           = Kind{ID: "MK_ENABLE", ExitCode: ExProgramError}
	InternalFlagsBind        = Kind{ID: "MK_FLAGS_BIND", ExitCode: ExProgramError}
	InternalFlagSet          = Kind{ID: "MK_FLAGS_SET", ExitCode: ExProgramError}
	InternalFormatUsage      = Kind{ID: "MK_FORMAT_USAGE", ExitCode: ExProgramError}
	InternalGenerateDocs     = Kind{ID: "MK_GENERATE_DOCS", ExitCode: ExProgramError}
	InternalJSONMarshal      = Kind{ID: "MK_JSON_MARSHAL", ExitCode: ExProgramError}
	InternalKubernetesClient = Kind{ID: "MK_K8S_CLIENT", ExitCode: ExControlPlaneUnavailable}
	InternalListConfig       = Kind{ID: "MK_LIST_CONFIG", ExitCode: ExProgramError}
	InternalLogtostderrFlag  = Kind{ID: "MK_LOGTOSTDERR_FLAG", ExitCode: ExProgramError}
	InternalLogFollow        = Kind{ID: "MK_LOG_FOLLOW", ExitCode: ExProgramError}
	InternalNewRuntime       = Kind{ID: "MK_NEW_RUNTIME", ExitCode: ExProgramError}
	InternalOutputUsage      = Kind{ID: "MK_OUTPUT_USAGE", ExitCode: ExProgramError}
	InternalRuntime          = Kind{ID: "MK_RUNTIME", ExitCode: ExProgramError}
	InternalReservedProfile  = Kind{ID: "MK_RESERVED_PROFILE", ExitCode: ExProgramConflict}
	InternalEnvScript        = Kind{ID: "MK_ENV_SCRIPT", ExitCode: ExProgramError}
	InternalShellDetect      = Kind{ID: "MK_SHELL_DETECT", ExitCode: ExProgramError}
	InternalStatusJSON       = Kind{ID: "MK_STATUS_JSON", ExitCode: ExProgramError}
	InternalStatusText       = Kind{ID: "MK_STATUS_TEXT", ExitCode: ExProgramError}
	InternalUnsetScript      = Kind{ID: "MK_UNSET_SCRIPT", ExitCode: ExProgramError}
	InternalViewExec         = Kind{ID: "MK_VIEW_EXEC", ExitCode: ExProgramError}
	InternalViewTmpl         = Kind{ID: "MK_VIEW_TMPL", ExitCode: ExProgramError}
	InternalYamlMarshal      = Kind{ID: "MK_YAML_MARSHAL", ExitCode: ExProgramError}
	InternalCredsNotFound    = Kind{ID: "MK_CREDENTIALS_NOT_FOUND", ExitCode: ExProgramNotFound, Style: style.Shrug}
123
	InternalCredsNotNeeded   = Kind{ID: "MK_CREDENTIALS_NOT_NEEDED", ExitCode: ExProgramNotFound, Style: style.Shrug}
124
	InternalSemverParse      = Kind{ID: "MK_SEMVER_PARSE", ExitCode: ExProgramError}
P
Priya Wadhwa 已提交
125
	DaemonizeError           = Kind{ID: "MK_DAEMONIZE", ExitCode: ExProgramError}
126

127
	RsrcInsufficientCores             = Kind{ID: "RSRC_INSUFFICIENT_CORES", ExitCode: ExInsufficientCores, Style: style.UnmetRequirement}
128 129 130 131 132 133 134 135
	RsrcInsufficientDarwinDockerCores = Kind{
		ID:       "RSRC_DOCKER_CORES",
		ExitCode: ExInsufficientCores,
		Advice: `1. Click on "Docker for Desktop" menu icon
			2. Click "Preferences"
			3. Click "Resources"
			4. Increase "CPUs" slider bar to 2 or higher
			5. Click "Apply & Restart"`,
136
		Style: style.UnmetRequirement,
137 138 139 140 141 142 143 144 145 146 147 148
		URL:   "https://docs.docker.com/docker-for-mac/#resources",
	}

	RsrcInsufficientWindowsDockerCores = Kind{
		ID:       "RSRC_DOCKER_CORES",
		ExitCode: ExInsufficientCores,
		Advice: `1. Open the "Docker Desktop" menu by clicking the Docker icon in the system tray
		2. Click "Settings"
		3. Click "Resources"
		4. Increase "CPUs" slider bar to 2 or higher
		5. Click "Apply & Restart"`,
		URL:   "https://docs.docker.com/docker-for-windows/#resources",
149
		Style: style.UnmetRequirement,
150 151
	}

152 153 154
	RsrcInsufficientReqMemory           = Kind{ID: "RSRC_INSUFFICIENT_REQ_MEMORY", ExitCode: ExInsufficientMemory, Style: style.UnmetRequirement}
	RsrcInsufficientSysMemory           = Kind{ID: "RSRC_INSUFFICIENT_SYS_MEMORY", ExitCode: ExInsufficientMemory, Style: style.UnmetRequirement}
	RsrcInsufficientContainerMemory     = Kind{ID: "RSRC_INSUFFICIENT_CONTAINER_MEMORY", ExitCode: ExInsufficientMemory, Style: style.UnmetRequirement}
155 156 157 158 159 160 161 162 163
	RsrcInsufficientWindowsDockerMemory = Kind{
		ID:       "RSRC_DOCKER_MEMORY",
		ExitCode: ExInsufficientMemory,
		Advice: `1. Open the "Docker Desktop" menu by clicking the Docker icon in the system tray
		2. Click "Settings"
		3. Click "Resources"
		4. Increase "Memory" slider bar to {{.recommend}} or higher
		5. Click "Apply & Restart"`,
		URL:   "https://docs.docker.com/docker-for-windows/#resources",
164
		Style: style.UnmetRequirement,
165 166 167
	}
	RsrcInsufficientDarwinDockerMemory = Kind{
		ID:       "RSRC_DOCKER_MEMORY",
168
		ExitCode: ExInsufficientMemory,
169 170 171 172 173
		Advice: `1. Click on "Docker for Desktop" menu icon
			2. Click "Preferences"
			3. Click "Resources"
			4. Increase "Memory" slider bar to {{.recommend}} or higher
			5. Click "Apply & Restart"`,
174
		Style: style.UnmetRequirement,
175 176 177 178 179 180
		URL:   "https://docs.docker.com/docker-for-mac/#resources",
	}

	RsrcInsufficientDockerStorage = Kind{
		ID:       "RSRC_DOCKER_STORAGE",
		ExitCode: ExInsufficientStorage,
181
		Advice: `Try one or more of the following to free up space on the device:
182
	
183 184
			1. Run "docker system prune" to remove unused Docker data (optionally with "-a")
			2. Increase the storage allocated to Docker for Desktop by clicking on:
185
				Docker icon > Preferences > Resources > Disk Image Size
186
			3. Run "minikube ssh -- docker system prune" if using the Docker container runtime`,
187 188
		Issues: []int{9024},
	}
189 190 191
	RsrcInsufficientPodmanStorage = Kind{
		ID:       "RSRC_PODMAN_STORAGE",
		ExitCode: ExInsufficientStorage,
T
Thomas Stromberg 已提交
192
		Advice: `Try one or more of the following to free up space on the device:
193 194
	
			1. Run "sudo podman system prune" to remove unused podman data
195
			2. Run "minikube ssh -- docker system prune" if using the Docker container runtime`,
196 197
		Issues: []int{9024},
	}
198

199
	RsrcInsufficientStorage = Kind{ID: "RSRC_INSUFFICIENT_STORAGE", ExitCode: ExInsufficientStorage, Style: style.UnmetRequirement}
200

201 202 203 204 205 206 207 208 209 210 211
	HostHomeMkdir      = Kind{ID: "HOST_HOME_MKDIR", ExitCode: ExHostPermission}
	HostHomeChown      = Kind{ID: "HOST_HOME_CHOWN", ExitCode: ExHostPermission}
	HostBrowser        = Kind{ID: "HOST_BROWSER", ExitCode: ExHostError}
	HostConfigLoad     = Kind{ID: "HOST_CONFIG_LOAD", ExitCode: ExHostConfig}
	HostHomePermission = Kind{
		ID:       "HOST_HOME_PERMISSION",
		ExitCode: ExHostPermission,
		Advice:   "Your user lacks permissions to the minikube profile directory. Run: 'sudo chown -R $USER $HOME/.minikube; chmod -R u+wrx $HOME/.minikube' to fix",
		Issues:   []int{9165},
	}

212 213 214 215 216 217 218 219 220 221 222 223
	HostCurrentUser         = Kind{ID: "HOST_CURRENT_USER", ExitCode: ExHostConfig}
	HostDelCache            = Kind{ID: "HOST_DEL_CACHE", ExitCode: ExHostError}
	HostKillMountProc       = Kind{ID: "HOST_KILL_MOUNT_PROC", ExitCode: ExHostError}
	HostKubeconfigUnset     = Kind{ID: "HOST_KUBECNOFIG_UNSET", ExitCode: ExHostConfig}
	HostKubeconfigUpdate    = Kind{ID: "HOST_KUBECONFIG_UPDATE", ExitCode: ExHostConfig}
	HostKubeconfigDeleteCtx = Kind{ID: "HOST_KUBECONFIG_DELETE_CTX", ExitCode: ExHostConfig}
	HostKubectlProxy        = Kind{ID: "HOST_KUBECTL_PROXY", ExitCode: ExHostError}
	HostMountPid            = Kind{ID: "HOST_MOUNT_PID", ExitCode: ExHostError}
	HostPathMissing         = Kind{ID: "HOST_PATH_MISSING", ExitCode: ExHostNotFound}
	HostPathStat            = Kind{ID: "HOST_PATH_STAT", ExitCode: ExHostError}
	HostPurge               = Kind{ID: "HOST_PURGE", ExitCode: ExHostError}
	HostSaveProfile         = Kind{ID: "HOST_SAVE_PROFILE", ExitCode: ExHostConfig}
224 225 226 227

	ProviderNotFound    = Kind{ID: "PROVIDER_NOT_FOUND", ExitCode: ExProviderNotFound}
	ProviderUnavailable = Kind{ID: "PROVIDER_UNAVAILABLE", ExitCode: ExProviderNotFound, Style: style.Shrug}

228 229
	DrvCPEndpoint = Kind{ID: "DRV_CP_ENDPOINT",
		Advice: `Recreate the cluster by running:
P
Priya Wadhwa 已提交
230 231
		minikube delete {{.profileArg}}
		minikube start {{.profileArg}}`,
232 233 234
		ExitCode: ExDriverError,
		Style:    style.Failure,
	}
235 236 237 238 239 240 241 242
	DrvPortForward        = Kind{ID: "DRV_PORT_FORWARD", ExitCode: ExDriverError}
	DrvUnsupportedMulti   = Kind{ID: "DRV_UNSUPPORTED_MULTINODE", ExitCode: ExDriverConflict}
	DrvUnsupportedOS      = Kind{ID: "DRV_UNSUPPORTED_OS", ExitCode: ExDriverUnsupported}
	DrvUnsupportedProfile = Kind{ID: "DRV_UNSUPPORTED_PROFILE", ExitCode: ExDriverUnsupported}
	DrvNotFound           = Kind{ID: "DRV_NOT_FOUND", ExitCode: ExDriverNotFound}
	DrvNotDetected        = Kind{ID: "DRV_NOT_DETECTED", ExitCode: ExDriverNotFound}
	DrvAsRoot             = Kind{ID: "DRV_AS_ROOT", ExitCode: ExDriverPermission}
	DrvNeedsRoot          = Kind{ID: "DRV_NEEDS_ROOT", ExitCode: ExDriverPermission}
243
	DrvNeedsAdministrator = Kind{ID: "DRV_NEEDS_ADMINISTRATOR", ExitCode: ExDriverPermission}
244 245 246 247 248

	GuestCacheLoad        = Kind{ID: "GUEST_CACHE_LOAD", ExitCode: ExGuestError}
	GuestCert             = Kind{ID: "GUEST_CERT", ExitCode: ExGuestError}
	GuestCpConfig         = Kind{ID: "GUEST_CP_CONFIG", ExitCode: ExGuestConfig}
	GuestDeletion         = Kind{ID: "GUEST_DELETION", ExitCode: ExGuestError}
P
Priya Wadhwa 已提交
249
	GuestImageLoad        = Kind{ID: "GUEST_IMAGE_LOAD", ExitCode: ExGuestError}
T
Tharun 已提交
250
	GuestImageRemove      = Kind{ID: "GUEST_IMAGE_REMOVE", ExitCode: ExGuestError}
251 252
	GuestLoadHost         = Kind{ID: "GUEST_LOAD_HOST", ExitCode: ExGuestError}
	GuestMount            = Kind{ID: "GUEST_MOUNT", ExitCode: ExGuestError}
A
Asare Worae 已提交
253
	GuestMountConflict    = Kind{ID: "GUEST_MOUNT_CONFLICT", ExitCode: ExGuestConflict}
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
	GuestNodeAdd          = Kind{ID: "GUEST_NODE_ADD", ExitCode: ExGuestError}
	GuestNodeDelete       = Kind{ID: "GUEST_NODE_DELETE", ExitCode: ExGuestError}
	GuestNodeProvision    = Kind{ID: "GUEST_NODE_PROVISION", ExitCode: ExGuestError}
	GuestNodeRetrieve     = Kind{ID: "GUEST_NODE_RETRIEVE", ExitCode: ExGuestNotFound}
	GuestNodeStart        = Kind{ID: "GUEST_NODE_START", ExitCode: ExGuestError}
	GuestPause            = Kind{ID: "GUEST_PAUSE", ExitCode: ExGuestError}
	GuestProfileDeletion  = Kind{ID: "GUEST_PROFILE_DELETION", ExitCode: ExGuestError}
	GuestProvision        = Kind{ID: "GUEST_PROVISION", ExitCode: ExGuestError}
	GuestStart            = Kind{ID: "GUEST_START", ExitCode: ExGuestError}
	GuestStatus           = Kind{ID: "GUEST_STATUS", ExitCode: ExGuestError}
	GuestStopTimeout      = Kind{ID: "GUEST_STOP_TIMEOUT", ExitCode: ExGuestTimeout}
	GuestUnpause          = Kind{ID: "GUEST_UNPAUSE", ExitCode: ExGuestError}
	GuestDrvMismatch      = Kind{ID: "GUEST_DRIVER_MISMATCH", ExitCode: ExGuestConflict, Style: style.Conflict}
	GuestMissingConntrack = Kind{ID: "GUEST_MISSING_CONNTRACK", ExitCode: ExGuestUnsupported}

	IfHostIP    = Kind{ID: "IF_HOST_IP", ExitCode: ExLocalNetworkError}
	IfMountIP   = Kind{ID: "IF_MOUNT_IP", ExitCode: ExLocalNetworkError}
	IfMountPort = Kind{ID: "IF_MOUNT_PORT", ExitCode: ExLocalNetworkError}
	IfSSHClient = Kind{ID: "IF_SSH_CLIENT", ExitCode: ExLocalNetworkError}

	InetCacheBinaries      = Kind{ID: "INET_CACHE_BINARIES", ExitCode: ExInternetError}
	InetCacheKubectl       = Kind{ID: "INET_CACHE_KUBECTL", ExitCode: ExInternetError}
	InetCacheTar           = Kind{ID: "INET_CACHE_TAR", ExitCode: ExInternetError}
	InetGetVersions        = Kind{ID: "INET_GET_VERSIONS", ExitCode: ExInternetError}
	InetRepo               = Kind{ID: "INET_REPO", ExitCode: ExInternetError}
	InetReposUnavailable   = Kind{ID: "INET_REPOS_UNAVAILABLE", ExitCode: ExInternetError}
	InetVersionUnavailable = Kind{ID: "INET_VERSION_UNAVAILABLE", ExitCode: ExInternetUnavailable}
	InetVersionEmpty       = Kind{ID: "INET_VERSION_EMPTY", ExitCode: ExInternetConfig}

	RuntimeEnable  = Kind{ID: "RUNTIME_ENABLE", ExitCode: ExRuntimeError}
	RuntimeCache   = Kind{ID: "RUNTIME_CACHE", ExitCode: ExRuntimeError}
	RuntimeRestart = Kind{ID: "RUNTIME_RESTART", ExitCode: ExRuntimeError}

	SvcCheckTimeout = Kind{ID: "SVC_CHECK_TIMEOUT", ExitCode: ExSvcTimeout}
	SvcTimeout      = Kind{ID: "SVC_TIMEOUT", ExitCode: ExSvcTimeout}
	SvcList         = Kind{ID: "SVC_LIST", ExitCode: ExSvcError}
	SvcTunnelStart  = Kind{ID: "SVC_TUNNEL_START", ExitCode: ExSvcError}
	SvcTunnelStop   = Kind{ID: "SVC_TUNNEL_STOP", ExitCode: ExSvcError}
	SvcURLTimeout   = Kind{ID: "SVC_URL_TIMEOUT", ExitCode: ExSvcTimeout}
	SvcNotFound     = Kind{ID: "SVC_NOT_FOUND", ExitCode: ExSvcNotFound}

	EnvDriverConflict    = Kind{ID: "ENV_DRIVER_CONFLICT", ExitCode: ExDriverConflict}
	EnvMultiConflict     = Kind{ID: "ENV_MULTINODE_CONFLICT", ExitCode: ExGuestConflict}
	EnvDockerUnavailable = Kind{ID: "ENV_DOCKER_UNAVAILABLE", ExitCode: ExRuntimeUnavailable}
	EnvPodmanUnavailable = Kind{ID: "ENV_PODMAN_UNAVAILABLE", ExitCode: ExRuntimeUnavailable}

	AddonUnsupported = Kind{ID: "SVC_ADDON_UNSUPPORTED", ExitCode: ExSvcUnsupported}
	AddonNotEnabled  = Kind{ID: "SVC_ADDON_NOT_ENABLED", ExitCode: ExProgramConflict}

303 304 305 306
	KubernetesInstallFailed                  = Kind{ID: "K8S_INSTALL_FAILED", ExitCode: ExControlPlaneError}
	KubernetesInstallFailedRuntimeNotRunning = Kind{ID: "K8S_INSTALL_FAILED_CONTAINER_RUNTIME_NOT_RUNNING", ExitCode: ExRuntimeNotRunning}
	KubernetesTooOld                         = Kind{ID: "K8S_OLD_UNSUPPORTED", ExitCode: ExControlPlaneUnsupported}
	KubernetesDowngrade                      = Kind{
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
		ID:       "K8S_DOWNGRADE_UNSUPPORTED",
		ExitCode: ExControlPlaneUnsupported,
		Advice: `1) Recreate the cluster with Kubernetes {{.new}}, by running:
	  
		  minikube delete{{.profile}}
		  minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}
	  
		2) Create a second cluster with Kubernetes {{.new}}, by running:
	  
		  minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}
	  
		3) Use the existing cluster at version Kubernetes {{.old}}, by running:
	  
		  minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}
		`,
		Style: style.SeeNoEvil,
	}
)