mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Introduce terminationMessagePath to Container, and update conversion code
to assign the default path. Move default setting for terminationMessagePath to conversion from validation. Addressed other comments.
This commit is contained in:
parent
5342bb4306
commit
8ffbced280
@ -34,6 +34,14 @@ func init() {
|
|||||||
out.Spec.RestartPolicy = in.RestartPolicy
|
out.Spec.RestartPolicy = in.RestartPolicy
|
||||||
out.Name = in.ID
|
out.Name = in.ID
|
||||||
out.UID = in.UUID
|
out.UID = in.UUID
|
||||||
|
// TODO(dchen1107): Move this conversion to pkg/api/v1beta[123]/conversion.go
|
||||||
|
// along with fixing #1502
|
||||||
|
for i := range out.Spec.Containers {
|
||||||
|
ctr := &out.Spec.Containers[i]
|
||||||
|
if len(ctr.TerminationMessagePath) == 0 {
|
||||||
|
ctr.TerminationMessagePath = TerminationMessagePathDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *BoundPod, out *ContainerManifest, s conversion.Scope) error {
|
func(in *BoundPod, out *ContainerManifest, s conversion.Scope) error {
|
||||||
@ -43,6 +51,12 @@ func init() {
|
|||||||
out.Version = "v1beta2"
|
out.Version = "v1beta2"
|
||||||
out.ID = in.Name
|
out.ID = in.Name
|
||||||
out.UUID = in.UID
|
out.UUID = in.UID
|
||||||
|
for i := range out.Containers {
|
||||||
|
ctr := &out.Containers[i]
|
||||||
|
if len(ctr.TerminationMessagePath) == 0 {
|
||||||
|
ctr.TerminationMessagePath = TerminationMessagePathDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *ContainerManifestList, out *BoundPods, s conversion.Scope) error {
|
func(in *ContainerManifestList, out *BoundPods, s conversion.Scope) error {
|
||||||
|
@ -121,6 +121,8 @@ const (
|
|||||||
NamespaceDefault string = "default"
|
NamespaceDefault string = "default"
|
||||||
// NamespaceAll is the default argument to specify on a context when you want to list or filter resources across all namespaces
|
// NamespaceAll is the default argument to specify on a context when you want to list or filter resources across all namespaces
|
||||||
NamespaceAll string = ""
|
NamespaceAll string = ""
|
||||||
|
// TerminationMessagePathDefault means the default path to capture the application termination message running in a container
|
||||||
|
TerminationMessagePathDefault string = "/dev/termination-log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Volume represents a named volume in a pod that may be accessed by any containers in the pod.
|
// Volume represents a named volume in a pod that may be accessed by any containers in the pod.
|
||||||
@ -301,6 +303,8 @@ type Container struct {
|
|||||||
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty" yaml:"volumeMounts,omitempty"`
|
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty" yaml:"volumeMounts,omitempty"`
|
||||||
LivenessProbe *LivenessProbe `json:"livenessProbe,omitempty" yaml:"livenessProbe,omitempty"`
|
LivenessProbe *LivenessProbe `json:"livenessProbe,omitempty" yaml:"livenessProbe,omitempty"`
|
||||||
Lifecycle *Lifecycle `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
|
Lifecycle *Lifecycle `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
|
||||||
|
// Optional: Defaults to /dev/termination-log
|
||||||
|
TerminationMessagePath string `json:"terminationMessagePath,omitempty" yaml:"terminationMessagePath,omitempty"`
|
||||||
// Optional: Default to false.
|
// Optional: Default to false.
|
||||||
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
||||||
// Optional: Policy for pulling images for this container
|
// Optional: Policy for pulling images for this container
|
||||||
|
@ -256,6 +256,8 @@ type Container struct {
|
|||||||
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
|
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
|
||||||
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
|
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
|
||||||
Lifecycle *Lifecycle `yaml:"lifecycle,omitempty" json:"lifecycle,omitempty"`
|
Lifecycle *Lifecycle `yaml:"lifecycle,omitempty" json:"lifecycle,omitempty"`
|
||||||
|
// Optional: Defaults to /dev/termination-log
|
||||||
|
TerminationMessagePath string `yaml:"terminationMessagePath,omitempty" json:"terminationMessagePath,omitempty"`
|
||||||
// Optional: Default to false.
|
// Optional: Default to false.
|
||||||
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
||||||
// Optional: Policy for pulling images for this container
|
// Optional: Policy for pulling images for this container
|
||||||
|
@ -222,6 +222,8 @@ type Container struct {
|
|||||||
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
|
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
|
||||||
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
|
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
|
||||||
Lifecycle *Lifecycle `yaml:"lifecycle,omitempty" json:"lifecycle,omitempty"`
|
Lifecycle *Lifecycle `yaml:"lifecycle,omitempty" json:"lifecycle,omitempty"`
|
||||||
|
// Optional: Defaults to /dev/termination-log
|
||||||
|
TerminationMessagePath string `yaml:"terminationMessagePath,omitempty" json:"terminationMessagePath,omitempty"`
|
||||||
// Optional: Default to false.
|
// Optional: Default to false.
|
||||||
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
||||||
// Optional: Policy for pulling images for this container
|
// Optional: Policy for pulling images for this container
|
||||||
|
@ -334,6 +334,8 @@ type Container struct {
|
|||||||
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty" yaml:"volumeMounts,omitempty"`
|
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty" yaml:"volumeMounts,omitempty"`
|
||||||
LivenessProbe *LivenessProbe `json:"livenessProbe,omitempty" yaml:"livenessProbe,omitempty"`
|
LivenessProbe *LivenessProbe `json:"livenessProbe,omitempty" yaml:"livenessProbe,omitempty"`
|
||||||
Lifecycle *Lifecycle `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
|
Lifecycle *Lifecycle `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
|
||||||
|
// Optional: Defaults to /dev/termination-log
|
||||||
|
TerminationMessagePath string `json:"terminationMessagePath,omitempty" yaml:"terminationMessagePath,omitempty"`
|
||||||
// Optional: Default to false.
|
// Optional: Default to false.
|
||||||
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
||||||
// Optional: Policy for pulling images for this container
|
// Optional: Policy for pulling images for this container
|
||||||
|
@ -40,6 +40,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
|
|||||||
{
|
{
|
||||||
Name: "c" + id,
|
Name: "c" + id,
|
||||||
Image: "foo",
|
Image: "foo",
|
||||||
|
TerminationMessagePath: "/somepath",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Volumes: []api.Volume{
|
Volumes: []api.Volume{
|
||||||
@ -62,6 +63,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
|
|||||||
{
|
{
|
||||||
Name: "c" + id,
|
Name: "c" + id,
|
||||||
Image: "foo",
|
Image: "foo",
|
||||||
|
TerminationMessagePath: "/somepath",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Volumes: []api.Volume{
|
Volumes: []api.Volume{
|
||||||
@ -124,7 +126,7 @@ func TestReadFromFile(t *testing.T) {
|
|||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{{Image: "test/image"}},
|
Containers: []api.Container{{Image: "test/image", TerminationMessagePath: "/dev/termination-log"}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if !reflect.DeepEqual(expected, update) {
|
if !reflect.DeepEqual(expected, update) {
|
||||||
|
@ -146,14 +146,24 @@ func TestExtractFromHTTP(t *testing.T) {
|
|||||||
Name: "1",
|
Name: "1",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{Containers: []api.Container{{Name: "1", Image: "foo"}}},
|
Spec: api.PodSpec{
|
||||||
|
Containers: []api.Container{{
|
||||||
|
Name: "1",
|
||||||
|
Image: "foo",
|
||||||
|
TerminationMessagePath: "/dev/termination-log"}},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
api.BoundPod{
|
api.BoundPod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{Containers: []api.Container{{Name: "1", Image: "foo"}}},
|
Spec: api.PodSpec{
|
||||||
|
Containers: []api.Container{{
|
||||||
|
Name: "1",
|
||||||
|
Image: "foo",
|
||||||
|
TerminationMessagePath: "/dev/termination-log"}},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user