mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-21 18:11:22 +00:00
Send pod spec warnings when creating or changing workload objects
This commit is contained in:
@@ -168,7 +168,8 @@ func (daemonSetStrategy) Validate(ctx context.Context, obj runtime.Object) field
|
||||
|
||||
// WarningsOnCreate returns warnings for the creation of the given object.
|
||||
func (daemonSetStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
|
||||
return nil
|
||||
newDaemonSet := obj.(*apps.DaemonSet)
|
||||
return pod.GetWarningsForPodTemplate(ctx, field.NewPath("spec", "template"), &newDaemonSet.Spec.Template, nil)
|
||||
}
|
||||
|
||||
// Canonicalize normalizes the object after validation.
|
||||
@@ -210,7 +211,13 @@ func (daemonSetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Ob
|
||||
|
||||
// WarningsOnUpdate returns warnings for the given update.
|
||||
func (daemonSetStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
|
||||
return nil
|
||||
var warnings []string
|
||||
newDaemonSet := obj.(*apps.DaemonSet)
|
||||
oldDaemonSet := old.(*apps.DaemonSet)
|
||||
if newDaemonSet.Spec.TemplateGeneration != oldDaemonSet.Spec.TemplateGeneration {
|
||||
warnings = pod.GetWarningsForPodTemplate(ctx, field.NewPath("spec", "template"), &newDaemonSet.Spec.Template, &oldDaemonSet.Spec.Template)
|
||||
}
|
||||
return warnings
|
||||
}
|
||||
|
||||
// AllowUnconditionalUpdate is the default update policy for daemon set objects.
|
||||
|
@@ -98,7 +98,8 @@ func (deploymentStrategy) Validate(ctx context.Context, obj runtime.Object) fiel
|
||||
|
||||
// WarningsOnCreate returns warnings for the creation of the given object.
|
||||
func (deploymentStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
|
||||
return nil
|
||||
newDeployment := obj.(*apps.Deployment)
|
||||
return pod.GetWarningsForPodTemplate(ctx, field.NewPath("spec", "template"), &newDeployment.Spec.Template, nil)
|
||||
}
|
||||
|
||||
// Canonicalize normalizes the object after validation.
|
||||
@@ -156,7 +157,13 @@ func (deploymentStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.O
|
||||
|
||||
// WarningsOnUpdate returns warnings for the given update.
|
||||
func (deploymentStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
|
||||
return nil
|
||||
var warnings []string
|
||||
newDeployment := obj.(*apps.Deployment)
|
||||
oldDeployment := old.(*apps.Deployment)
|
||||
if newDeployment.Generation != oldDeployment.Generation {
|
||||
warnings = pod.GetWarningsForPodTemplate(ctx, field.NewPath("spec", "template"), &newDeployment.Spec.Template, &oldDeployment.Spec.Template)
|
||||
}
|
||||
return warnings
|
||||
}
|
||||
|
||||
func (deploymentStrategy) AllowUnconditionalUpdate() bool {
|
||||
|
@@ -126,7 +126,10 @@ func (rsStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorL
|
||||
}
|
||||
|
||||
// WarningsOnCreate returns warnings for the creation of the given object.
|
||||
func (rsStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { return nil }
|
||||
func (rsStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
|
||||
newRS := obj.(*apps.ReplicaSet)
|
||||
return pod.GetWarningsForPodTemplate(ctx, field.NewPath("spec", "template"), &newRS.Spec.Template, nil)
|
||||
}
|
||||
|
||||
// Canonicalize normalizes the object after validation.
|
||||
func (rsStrategy) Canonicalize(obj runtime.Object) {
|
||||
@@ -166,7 +169,15 @@ func (rsStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) f
|
||||
}
|
||||
|
||||
// WarningsOnUpdate returns warnings for the given update.
|
||||
func (rsStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { return nil }
|
||||
func (rsStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
|
||||
var warnings []string
|
||||
newReplicaSet := obj.(*apps.ReplicaSet)
|
||||
oldReplicaSet := old.(*apps.ReplicaSet)
|
||||
if newReplicaSet.Generation != oldReplicaSet.Generation {
|
||||
warnings = pod.GetWarningsForPodTemplate(ctx, field.NewPath("spec", "template"), &newReplicaSet.Spec.Template, &oldReplicaSet.Spec.Template)
|
||||
}
|
||||
return warnings
|
||||
}
|
||||
|
||||
func (rsStrategy) AllowUnconditionalUpdate() bool {
|
||||
return true
|
||||
|
@@ -115,7 +115,8 @@ func (statefulSetStrategy) Validate(ctx context.Context, obj runtime.Object) fie
|
||||
|
||||
// WarningsOnCreate returns warnings for the creation of the given object.
|
||||
func (statefulSetStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
|
||||
return nil
|
||||
newStatefulSet := obj.(*apps.StatefulSet)
|
||||
return pod.GetWarningsForPodTemplate(ctx, field.NewPath("spec", "template"), &newStatefulSet.Spec.Template, nil)
|
||||
}
|
||||
|
||||
// Canonicalize normalizes the object after validation.
|
||||
@@ -140,7 +141,13 @@ func (statefulSetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.
|
||||
|
||||
// WarningsOnUpdate returns warnings for the given update.
|
||||
func (statefulSetStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
|
||||
return nil
|
||||
var warnings []string
|
||||
newStatefulSet := obj.(*apps.StatefulSet)
|
||||
oldStatefulSet := old.(*apps.StatefulSet)
|
||||
if newStatefulSet.Generation != oldStatefulSet.Generation {
|
||||
warnings = pod.GetWarningsForPodTemplate(ctx, field.NewPath("spec", "template"), &newStatefulSet.Spec.Template, &oldStatefulSet.Spec.Template)
|
||||
}
|
||||
return warnings
|
||||
}
|
||||
|
||||
// AllowUnconditionalUpdate is the default update policy for StatefulSet objects.
|
||||
|
Reference in New Issue
Block a user