Send pod spec warnings when creating or changing workload objects

This commit is contained in:
Jordan Liggitt
2021-05-01 01:09:04 -04:00
parent ecdecafdc8
commit f669796dfd
9 changed files with 87 additions and 17 deletions

View File

@@ -108,7 +108,9 @@ func (podStrategy) Validate(ctx context.Context, obj runtime.Object) field.Error
}
// WarningsOnCreate returns warnings for the creation of the given object.
func (podStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { return nil }
func (podStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
return podutil.GetWarningsForPod(ctx, obj.(*api.Pod), nil)
}
// Canonicalize normalizes the object after validation.
func (podStrategy) Canonicalize(obj runtime.Object) {
@@ -130,6 +132,8 @@ func (podStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object)
// WarningsOnUpdate returns warnings for the given update.
func (podStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
// skip warnings on pod update, since humans don't typically interact directly with pods,
// and we don't want to pay the evaluation cost on what might be a high-frequency update path
return nil
}