Merge pull request #6964 from ialidzhikov/automated-cherry-pick-of-#6903-origin-vpa-release-1.1
[vpa-release-1.1] Automated cherry pick of #6903: vpa-updater: Log the Pod namespace when evicting a Pod
This commit is contained in:
commit
635eba1c63
|
|
@ -125,11 +125,11 @@ func (e *podsEvictionRestrictionImpl) CanEvict(pod *apiv1.Pod) bool {
|
|||
func (e *podsEvictionRestrictionImpl) Evict(podToEvict *apiv1.Pod, eventRecorder record.EventRecorder) error {
|
||||
cr, present := e.podToReplicaCreatorMap[getPodID(podToEvict)]
|
||||
if !present {
|
||||
return fmt.Errorf("pod not suitable for eviction %v : not in replicated pods map", podToEvict.Name)
|
||||
return fmt.Errorf("pod not suitable for eviction %s/%s: not in replicated pods map", podToEvict.Namespace, podToEvict.Name)
|
||||
}
|
||||
|
||||
if !e.CanEvict(podToEvict) {
|
||||
return fmt.Errorf("cannot evict pod %v : eviction budget exceeded", podToEvict.Name)
|
||||
return fmt.Errorf("cannot evict pod %s/%s: eviction budget exceeded", podToEvict.Namespace, podToEvict.Name)
|
||||
}
|
||||
|
||||
eviction := &policyv1.Eviction{
|
||||
|
|
@ -199,7 +199,7 @@ func (f *podsEvictionRestrictionFactoryImpl) NewPodsEvictionRestriction(pods []*
|
|||
for _, pod := range pods {
|
||||
creator, err := getPodReplicaCreator(pod)
|
||||
if err != nil {
|
||||
klog.Errorf("failed to obtain replication info for pod %s: %v", pod.Name, err)
|
||||
klog.Errorf("failed to obtain replication info for pod %s: %v", klog.KObj(pod), err)
|
||||
continue
|
||||
}
|
||||
if creator == nil {
|
||||
|
|
@ -216,8 +216,8 @@ func (f *podsEvictionRestrictionFactoryImpl) NewPodsEvictionRestriction(pods []*
|
|||
required := f.minReplicas
|
||||
if vpa.Spec.UpdatePolicy != nil && vpa.Spec.UpdatePolicy.MinReplicas != nil {
|
||||
required = int(*vpa.Spec.UpdatePolicy.MinReplicas)
|
||||
klog.V(3).Infof("overriding minReplicas from global %v to per-VPA %v for VPA %v/%v",
|
||||
f.minReplicas, required, vpa.Namespace, vpa.Name)
|
||||
klog.V(3).Infof("overriding minReplicas from global %v to per-VPA %v for VPA %s",
|
||||
f.minReplicas, required, klog.KObj(vpa))
|
||||
}
|
||||
|
||||
for creator, replicas := range livePods {
|
||||
|
|
|
|||
|
|
@ -139,12 +139,12 @@ func (u *updater) RunOnce(ctx context.Context) {
|
|||
for _, vpa := range vpaList {
|
||||
if vpa_api_util.GetUpdateMode(vpa) != vpa_types.UpdateModeRecreate &&
|
||||
vpa_api_util.GetUpdateMode(vpa) != vpa_types.UpdateModeAuto {
|
||||
klog.V(3).Infof("skipping VPA object %v because its mode is not \"Recreate\" or \"Auto\"", vpa.Name)
|
||||
klog.V(3).Infof("skipping VPA object %s because its mode is not \"Recreate\" or \"Auto\"", klog.KObj(vpa))
|
||||
continue
|
||||
}
|
||||
selector, err := u.selectorFetcher.Fetch(vpa)
|
||||
if err != nil {
|
||||
klog.V(3).Infof("skipping VPA object %v because we cannot fetch selector", vpa.Name)
|
||||
klog.V(3).Infof("skipping VPA object %s because we cannot fetch selector", klog.KObj(vpa))
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -214,13 +214,13 @@ func (u *updater) RunOnce(ctx context.Context) {
|
|||
}
|
||||
err := u.evictionRateLimiter.Wait(ctx)
|
||||
if err != nil {
|
||||
klog.Warningf("evicting pod %v failed: %v", pod.Name, err)
|
||||
klog.Warningf("evicting pod %s failed: %v", klog.KObj(pod), err)
|
||||
return
|
||||
}
|
||||
klog.V(2).Infof("evicting pod %v", pod.Name)
|
||||
klog.V(2).Infof("evicting pod %s", klog.KObj(pod))
|
||||
evictErr := evictionLimiter.Evict(pod, u.eventRecorder)
|
||||
if evictErr != nil {
|
||||
klog.Warningf("evicting pod %v failed: %v", pod.Name, evictErr)
|
||||
klog.Warningf("evicting pod %s failed: %v", klog.KObj(pod), evictErr)
|
||||
} else {
|
||||
withEvicted = true
|
||||
metrics_updater.AddEvictedPod(vpaSize)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func NewUpdatePriorityCalculator(vpa *vpa_types.VerticalPodAutoscaler,
|
|||
func (calc *UpdatePriorityCalculator) AddPod(pod *apiv1.Pod, now time.Time) {
|
||||
processedRecommendation, _, err := calc.recommendationProcessor.Apply(calc.vpa.Status.Recommendation, calc.vpa.Spec.ResourcePolicy, calc.vpa.Status.Conditions, pod)
|
||||
if err != nil {
|
||||
klog.V(2).Infof("cannot process recommendation for pod %s/%s: %v", pod.Namespace, pod.Name, err)
|
||||
klog.V(2).Infof("cannot process recommendation for pod %s: %v", klog.KObj(pod), err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ func (calc *UpdatePriorityCalculator) AddPod(pod *apiv1.Pod, now time.Time) {
|
|||
terminationState.Terminated.Reason == "OOMKilled" &&
|
||||
terminationState.Terminated.FinishedAt.Time.Sub(terminationState.Terminated.StartedAt.Time) < *evictAfterOOMThreshold {
|
||||
quickOOM = true
|
||||
klog.V(2).Infof("quick OOM detected in pod %v/%v, container %v", pod.Namespace, pod.Name, cs.Name)
|
||||
klog.V(2).Infof("quick OOM detected in pod %s, container %v", klog.KObj(pod), cs.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -122,25 +122,25 @@ func (calc *UpdatePriorityCalculator) AddPod(pod *apiv1.Pod, now time.Time) {
|
|||
if !updatePriority.OutsideRecommendedRange && !quickOOM {
|
||||
if pod.Status.StartTime == nil {
|
||||
// TODO: Set proper condition on the VPA.
|
||||
klog.V(4).Infof("not updating pod %v/%v, missing field pod.Status.StartTime", pod.Namespace, pod.Name)
|
||||
klog.V(4).Infof("not updating pod %s, missing field pod.Status.StartTime", klog.KObj(pod))
|
||||
return
|
||||
}
|
||||
if now.Before(pod.Status.StartTime.Add(*podLifetimeUpdateThreshold)) {
|
||||
klog.V(4).Infof("not updating a short-lived pod %v/%v, request within recommended range", pod.Namespace, pod.Name)
|
||||
klog.V(4).Infof("not updating a short-lived pod %s, request within recommended range", klog.KObj(pod))
|
||||
return
|
||||
}
|
||||
if updatePriority.ResourceDiff < calc.config.MinChangePriority {
|
||||
klog.V(4).Infof("not updating pod %v/%v, resource diff too low: %v", pod.Namespace, pod.Name, updatePriority)
|
||||
klog.V(4).Infof("not updating pod %s, resource diff too low: %v", klog.KObj(pod), updatePriority)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// If the pod has quick OOMed then evict only if the resources will change
|
||||
if quickOOM && updatePriority.ResourceDiff == 0 {
|
||||
klog.V(4).Infof("not updating pod %v/%v because resource would not change", pod.Namespace, pod.Name)
|
||||
klog.V(4).Infof("not updating pod %s because resource would not change", klog.KObj(pod))
|
||||
return
|
||||
}
|
||||
klog.V(2).Infof("pod accepted for update %v/%v with priority %v", pod.Namespace, pod.Name, updatePriority.ResourceDiff)
|
||||
klog.V(2).Infof("pod accepted for update %s with priority %v", klog.KObj(pod), updatePriority.ResourceDiff)
|
||||
calc.pods = append(calc.pods, prioritizedPod{
|
||||
pod: pod,
|
||||
priority: updatePriority,
|
||||
|
|
|
|||
Loading…
Reference in New Issue