break guest provision when container exists prematurely
parent
9db3ae665c
commit
9c9934879c
|
@ -1510,5 +1510,8 @@ func exitGuestProvision(err error) {
|
|||
if errors.Cause(err) == oci.ErrInsufficientDockerStorage {
|
||||
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
|
||||
}
|
||||
if errors.Cause(err) == oci.ErrGetSSHPortContainerNotRunning {
|
||||
exit.Message(reason.GuestProvisionContainerExited, "Docker container exited permaturely after it was created, consider investigating Docker's performance/health.")
|
||||
}
|
||||
exit.Error(reason.GuestProvision, "error provisioning host", err)
|
||||
}
|
||||
|
|
|
@ -69,6 +69,12 @@ var ErrNetworkGatewayTaken = errors.New("network gateway is taken")
|
|||
// ErrNetworkInUse is when trying to delete a network which is attached to another container
|
||||
var ErrNetworkInUse = errors.New("unable to delete a network that is attached to a running container")
|
||||
|
||||
// ErrGetSSHPortContainerNotRunning happens when you try to inspect a container (in order to get SSH port) that "exists" but is no longer running
|
||||
var ErrGetSSHPortContainerNotRunning = errors.New("unable to inspect a not running container to get SSH port")
|
||||
|
||||
// ErrGetPortContainerNotRunning happens when you try to inspect a container (in order to get Port) that "exists" but is no longer running
|
||||
var ErrGetPortContainerNotRunning = errors.New("unable to inspect a not running container to get port")
|
||||
|
||||
// LogContainerDebug will print relevant docker/podman infos after a container fails
|
||||
func LogContainerDebug(ociBin string, name string) string {
|
||||
rr, err := containerInspect(ociBin, name)
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
)
|
||||
|
||||
// RoutableHostIPFromInside returns the ip/dns of the host that container lives on
|
||||
|
@ -150,6 +151,14 @@ func ForwardedPort(ociBin string, ociID string, contPort int) (int, error) {
|
|||
} else {
|
||||
rr, err = runCmd(exec.Command(ociBin, "container", "inspect", "-f", fmt.Sprintf("'{{(index (index .NetworkSettings.Ports \"%d/tcp\") 0).HostPort}}'", contPort), ociID))
|
||||
if err != nil {
|
||||
|
||||
// Error: "Template parsing error: template: :1:3: executing "" at <index (index .NetworkSettings.Ports "22/tcp") 0>: error calling index: index of untyped nil"
|
||||
if strings.Contains(rr.Output(), `<index (index .NetworkSettings.Ports "22/tcp") 0>: error calling index: index of untyped nil`) && contPort == constants.SSHPort {
|
||||
return 0, ErrGetSSHPortContainerNotRunning
|
||||
}
|
||||
if strings.Contains(rr.Output(), "error calling index: index of untyped nil") {
|
||||
return 0, ErrGetPortContainerNotRunning
|
||||
}
|
||||
return 0, errors.Wrapf(err, "get port %d for %q", contPort, ociID)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -480,7 +480,7 @@ func startMachine(cfg *config.ClusterConfig, node *config.Node, delOnFail bool)
|
|||
if err != nil {
|
||||
return runner, preExists, m, host, errors.Wrap(err, "Failed to get machine client")
|
||||
}
|
||||
host, preExists, err = startHost(m, cfg, node, delOnFail)
|
||||
host, preExists, err = startHostInternal(m, cfg, node, delOnFail)
|
||||
if err != nil {
|
||||
return runner, preExists, m, host, errors.Wrap(err, "Failed to start host")
|
||||
}
|
||||
|
@ -503,8 +503,8 @@ func startMachine(cfg *config.ClusterConfig, node *config.Node, delOnFail bool)
|
|||
return runner, preExists, m, host, err
|
||||
}
|
||||
|
||||
// startHost starts a new minikube host using a VM or None
|
||||
func startHost(api libmachine.API, cc *config.ClusterConfig, n *config.Node, delOnFail bool) (*host.Host, bool, error) {
|
||||
// startHostInternal starts a new minikube host using a VM or None
|
||||
func startHostInternal(api libmachine.API, cc *config.ClusterConfig, n *config.Node, delOnFail bool) (*host.Host, bool, error) {
|
||||
host, exists, err := machine.StartHost(api, cc, n)
|
||||
if err == nil {
|
||||
return host, exists, nil
|
||||
|
|
|
@ -229,32 +229,33 @@ var (
|
|||
DrvNeedsRoot = Kind{ID: "DRV_NEEDS_ROOT", ExitCode: ExDriverPermission}
|
||||
DrvNeedsAdministrator = Kind{ID: "DRV_NEEDS_ADMINISTRATOR", ExitCode: ExDriverPermission}
|
||||
|
||||
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}
|
||||
GuestImageList = Kind{ID: "GUEST_IMAGE_LIST", ExitCode: ExGuestError}
|
||||
GuestImageLoad = Kind{ID: "GUEST_IMAGE_LOAD", ExitCode: ExGuestError}
|
||||
GuestImageRemove = Kind{ID: "GUEST_IMAGE_REMOVE", ExitCode: ExGuestError}
|
||||
GuestImageBuild = Kind{ID: "GUEST_IMAGE_BUILD", ExitCode: ExGuestError}
|
||||
GuestLoadHost = Kind{ID: "GUEST_LOAD_HOST", ExitCode: ExGuestError}
|
||||
GuestMount = Kind{ID: "GUEST_MOUNT", ExitCode: ExGuestError}
|
||||
GuestMountConflict = Kind{ID: "GUEST_MOUNT_CONFLICT", ExitCode: ExGuestConflict}
|
||||
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}
|
||||
GuestCheckPaused = Kind{ID: "GUEST_CHECK_PAUSED", ExitCode: ExGuestError}
|
||||
GuestDrvMismatch = Kind{ID: "GUEST_DRIVER_MISMATCH", ExitCode: ExGuestConflict, Style: style.Conflict}
|
||||
GuestMissingConntrack = Kind{ID: "GUEST_MISSING_CONNTRACK", ExitCode: ExGuestUnsupported}
|
||||
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}
|
||||
GuestImageList = Kind{ID: "GUEST_IMAGE_LIST", ExitCode: ExGuestError}
|
||||
GuestImageLoad = Kind{ID: "GUEST_IMAGE_LOAD", ExitCode: ExGuestError}
|
||||
GuestImageRemove = Kind{ID: "GUEST_IMAGE_REMOVE", ExitCode: ExGuestError}
|
||||
GuestImageBuild = Kind{ID: "GUEST_IMAGE_BUILD", ExitCode: ExGuestError}
|
||||
GuestLoadHost = Kind{ID: "GUEST_LOAD_HOST", ExitCode: ExGuestError}
|
||||
GuestMount = Kind{ID: "GUEST_MOUNT", ExitCode: ExGuestError}
|
||||
GuestMountConflict = Kind{ID: "GUEST_MOUNT_CONFLICT", ExitCode: ExGuestConflict}
|
||||
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}
|
||||
GuestProvisionContainerExited = Kind{ID: "GUEST_PROVISION_CONTAINER_EXITED", 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}
|
||||
GuestCheckPaused = Kind{ID: "GUEST_CHECK_PAUSED", 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}
|
||||
|
|
Loading…
Reference in New Issue