mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 04:52:08 +00:00
don't pass CRI error through to waiting state reason
This commit is contained in:
parent
8316bbc14c
commit
9fcc25d1ed
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package kuberuntime
|
package kuberuntime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@ -48,6 +49,12 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/util/tail"
|
"k8s.io/kubernetes/pkg/util/tail"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrCreateContainerConfig = errors.New("CreateContainerConfigError")
|
||||||
|
ErrCreateContainer = errors.New("CreateContainerError")
|
||||||
|
ErrPostStartHook = errors.New("PostStartHookError")
|
||||||
|
)
|
||||||
|
|
||||||
// recordContainerEvent should be used by the runtime manager for all container related events.
|
// recordContainerEvent should be used by the runtime manager for all container related events.
|
||||||
// it has sanity checks to ensure that we do not write events that can abuse our masters.
|
// it has sanity checks to ensure that we do not write events that can abuse our masters.
|
||||||
// in particular, it ensures that a containerID never appears in an event message as that
|
// in particular, it ensures that a containerID never appears in an event message as that
|
||||||
@ -102,12 +109,12 @@ func (m *kubeGenericRuntimeManager) startContainer(podSandboxID string, podSandb
|
|||||||
containerConfig, err := m.generateContainerConfig(container, pod, restartCount, podIP, imageRef)
|
containerConfig, err := m.generateContainerConfig(container, pod, restartCount, podIP, imageRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.recordContainerEvent(pod, container, "", v1.EventTypeWarning, events.FailedToCreateContainer, "Error: %v", grpc.ErrorDesc(err))
|
m.recordContainerEvent(pod, container, "", v1.EventTypeWarning, events.FailedToCreateContainer, "Error: %v", grpc.ErrorDesc(err))
|
||||||
return "Generate Container Config Failed", err
|
return grpc.ErrorDesc(err), ErrCreateContainerConfig
|
||||||
}
|
}
|
||||||
containerID, err := m.runtimeService.CreateContainer(podSandboxID, containerConfig, podSandboxConfig)
|
containerID, err := m.runtimeService.CreateContainer(podSandboxID, containerConfig, podSandboxConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.recordContainerEvent(pod, container, containerID, v1.EventTypeWarning, events.FailedToCreateContainer, "Error: %v", grpc.ErrorDesc(err))
|
m.recordContainerEvent(pod, container, containerID, v1.EventTypeWarning, events.FailedToCreateContainer, "Error: %v", grpc.ErrorDesc(err))
|
||||||
return "Create Container Failed", err
|
return grpc.ErrorDesc(err), ErrCreateContainer
|
||||||
}
|
}
|
||||||
m.recordContainerEvent(pod, container, containerID, v1.EventTypeNormal, events.CreatedContainer, "Created container")
|
m.recordContainerEvent(pod, container, containerID, v1.EventTypeNormal, events.CreatedContainer, "Created container")
|
||||||
|
|
||||||
@ -122,7 +129,7 @@ func (m *kubeGenericRuntimeManager) startContainer(podSandboxID string, podSandb
|
|||||||
err = m.runtimeService.StartContainer(containerID)
|
err = m.runtimeService.StartContainer(containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.recordContainerEvent(pod, container, containerID, v1.EventTypeWarning, events.FailedToStartContainer, "Error: %v", grpc.ErrorDesc(err))
|
m.recordContainerEvent(pod, container, containerID, v1.EventTypeWarning, events.FailedToStartContainer, "Error: %v", grpc.ErrorDesc(err))
|
||||||
return "Start Container Failed", err
|
return grpc.ErrorDesc(err), kubecontainer.ErrRunContainer
|
||||||
}
|
}
|
||||||
m.recordContainerEvent(pod, container, containerID, v1.EventTypeNormal, events.StartedContainer, "Started container")
|
m.recordContainerEvent(pod, container, containerID, v1.EventTypeNormal, events.StartedContainer, "Started container")
|
||||||
|
|
||||||
@ -149,7 +156,7 @@ func (m *kubeGenericRuntimeManager) startContainer(podSandboxID string, podSandb
|
|||||||
if handlerErr != nil {
|
if handlerErr != nil {
|
||||||
m.recordContainerEvent(pod, container, kubeContainerID.ID, v1.EventTypeWarning, events.FailedPostStartHook, msg)
|
m.recordContainerEvent(pod, container, kubeContainerID.ID, v1.EventTypeWarning, events.FailedPostStartHook, msg)
|
||||||
m.killContainer(pod, kubeContainerID, container.Name, "FailedPostStartHook", nil)
|
m.killContainer(pod, kubeContainerID, container.Name, "FailedPostStartHook", nil)
|
||||||
return "PostStart Hook Failed", err
|
return msg, ErrPostStartHook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user