mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
Merge pull request #79623 from aaronbbrown/abb-quote-container-in-use
quote container name in container already use error matching
This commit is contained in:
commit
40b31794ab
@ -248,7 +248,7 @@ func TestContainerCreationConflict(t *testing.T) {
|
||||
containerName := makeContainerName(sConfig, config)
|
||||
const sandboxId = "sandboxid"
|
||||
const containerId = "containerid"
|
||||
conflictError := fmt.Errorf("Error response from daemon: Conflict. The name \"/%s\" is already in use by container %s. You have to remove (or rename) that container to be able to reuse that name.",
|
||||
conflictError := fmt.Errorf("Error response from daemon: Conflict. The name \"/%s\" is already in use by container %q. You have to remove (or rename) that container to be able to reuse that name.",
|
||||
containerName, containerId)
|
||||
noContainerError := fmt.Errorf("Error response from daemon: No such container: %s", containerId)
|
||||
randomError := fmt.Errorf("random error")
|
||||
|
@ -43,7 +43,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
conflictRE = regexp.MustCompile(`Conflict. (?:.)+ is already in use by container ([0-9a-z]+)`)
|
||||
conflictRE = regexp.MustCompile(`Conflict. (?:.)+ is already in use by container \"?([0-9a-z]+)\"?`)
|
||||
|
||||
// this is hacky, but extremely common.
|
||||
// if a container starts but the executable file is not found, runc gives a message that matches
|
||||
|
@ -118,11 +118,16 @@ func TestGetUserFromImageUser(t *testing.T) {
|
||||
|
||||
func TestParsingCreationConflictError(t *testing.T) {
|
||||
// Expected error message from docker.
|
||||
msg := "Conflict. The name \"/k8s_POD_pfpod_e2e-tests-port-forwarding-dlxt2_81a3469e-99e1-11e6-89f2-42010af00002_0\" is already in use by container 24666ab8c814d16f986449e504ea0159468ddf8da01897144a770f66dce0e14e. You have to remove (or rename) that container to be able to reuse that name."
|
||||
msgs := []string{
|
||||
"Conflict. The name \"/k8s_POD_pfpod_e2e-tests-port-forwarding-dlxt2_81a3469e-99e1-11e6-89f2-42010af00002_0\" is already in use by container 24666ab8c814d16f986449e504ea0159468ddf8da01897144a770f66dce0e14e. You have to remove (or rename) that container to be able to reuse that name.",
|
||||
"Conflict. The name \"/k8s_POD_pfpod_e2e-tests-port-forwarding-dlxt2_81a3469e-99e1-11e6-89f2-42010af00002_0\" is already in use by container \"24666ab8c814d16f986449e504ea0159468ddf8da01897144a770f66dce0e14e\". You have to remove (or rename) that container to be able to reuse that name.",
|
||||
}
|
||||
|
||||
matches := conflictRE.FindStringSubmatch(msg)
|
||||
require.Len(t, matches, 2)
|
||||
require.Equal(t, matches[1], "24666ab8c814d16f986449e504ea0159468ddf8da01897144a770f66dce0e14e")
|
||||
for _, msg := range msgs {
|
||||
matches := conflictRE.FindStringSubmatch(msg)
|
||||
require.Len(t, matches, 2)
|
||||
require.Equal(t, matches[1], "24666ab8c814d16f986449e504ea0159468ddf8da01897144a770f66dce0e14e")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnsureSandboxImageExists(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user