vpaUpdateModeForResource searches the resource's annotations and labels for a vpa-update-mode key/value and uses that key/value to return the proper UpdateMode type
(obj runtime.Object)
| 388 | // vpaUpdateModeForResource searches the resource's annotations and labels for a vpa-update-mode |
| 389 | // key/value and uses that key/value to return the proper UpdateMode type |
| 390 | func vpaUpdateModeForResource(obj runtime.Object) (*vpav1.UpdateMode, bool) { |
| 391 | requestedVPAMode := vpav1.UpdateModeOff |
| 392 | explicit := false |
| 393 | |
| 394 | requestStr := "" |
| 395 | accessor, _ := meta.Accessor(obj) |
| 396 | if val, ok := accessor.GetAnnotations()[utils.VpaUpdateModeKey]; ok { |
| 397 | requestStr = val |
| 398 | } else if val, ok := accessor.GetLabels()[utils.VpaUpdateModeKey]; ok { |
| 399 | requestStr = val |
| 400 | } |
| 401 | if requestStr != "" { |
| 402 | requestStrLower := strings.ToLower(requestStr) |
| 403 | for _, mode := range allowedUpdateModes { |
| 404 | if requestStrLower == strings.ToLower(string(mode)) { |
| 405 | requestedVPAMode = mode |
| 406 | explicit = true |
| 407 | break |
| 408 | } |
| 409 | } |
| 410 | if !explicit { |
| 411 | klog.Warningf("Invalid vpa-update-mode value: %s, defaulting to Off", requestStr) |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | return &requestedVPAMode, explicit |
| 416 | } |
| 417 | |
| 418 | // vpaResourcePolicyForResource get the resource's annotation for the vpa pod resource policy |
| 419 | // key/value and the value is the json definition of the pod resource policy |
no outgoing calls