Make a public ValidateAnnotationsSize
Kubernetes-commit: 2e771b8e745c4a3be0d5bae3a6dc94087284c73b
This commit is contained in:
parent
a01d02b7fd
commit
f753bce9f8
|
@ -93,7 +93,7 @@ func setLastApplied(obj runtime.Object, value string) error {
|
|||
annotations = map[string]string{}
|
||||
}
|
||||
annotations[corev1.LastAppliedConfigAnnotation] = value
|
||||
if isAnnotationsValid(annotations) != nil {
|
||||
if err := apimachineryvalidation.ValidateAnnotationsSize(annotations); err != nil {
|
||||
delete(annotations, corev1.LastAppliedConfigAnnotation)
|
||||
}
|
||||
accessor.SetAnnotations(annotations)
|
||||
|
@ -119,14 +119,3 @@ func buildLastApplied(obj runtime.Object) (string, error) {
|
|||
}
|
||||
return string(lastApplied), nil
|
||||
}
|
||||
|
||||
func isAnnotationsValid(annotations map[string]string) error {
|
||||
var totalSize int64
|
||||
for k, v := range annotations {
|
||||
totalSize += (int64)(len(k)) + (int64)(len(v))
|
||||
}
|
||||
if totalSize > (int64)(apimachineryvalidation.TotalAnnotationSizeLimitB) {
|
||||
return fmt.Errorf("annotations size %d is larger than limit %d", totalSize, apimachineryvalidation.TotalAnnotationSizeLimitB)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue