Skip to content

Commit c29cf16

Browse files
authored
Merge pull request #902 from luomingmeng/dev/fix-sidecar-memory-state
fix(memory): copy missing annotations in sidecar allocation
2 parents db78712 + 9145dc4 commit c29cf16

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

pkg/agent/qrm-plugins/cpu/dynamicpolicy/cpueviction/strategy/pressure_suppression.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,17 @@ func (p *CPUPressureSuppression) evictPodsByReclaimMetrics(now time.Time, filter
236236

237237
// a pod will only be evicted if its cpu suppression lasts longer than minToleranceDuration
238238
if lastDuration > evictionConfiguration.MinSuppressionToleranceDuration {
239-
evictPods = append(evictPods, &v1alpha1.EvictPod{
239+
evictPod := &v1alpha1.EvictPod{
240240
Pod: pod,
241241
Reason: fmt.Sprintf("current pool suppression rate %.2f is over than the "+
242242
"pod suppression tolerance rate %.2f", poolSuppressionRate, podToleranceRate),
243-
})
243+
}
244+
if evictionConfiguration.GracePeriod > 0 {
245+
evictPod.DeletionOptions = &v1alpha1.DeletionOptions{
246+
GracePeriodSeconds: evictionConfiguration.GracePeriod,
247+
}
248+
}
249+
evictPods = append(evictPods, evictPod)
244250
totalCPURequest.Sub(native.CPUQuantityGetter()(native.SumUpPodRequestResources(pod)))
245251
}
246252
} else {

pkg/agent/qrm-plugins/memory/dynamicpolicy/util.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,19 @@ func getReservedMemory(conf *config.Configuration, metaServer *metaserver.MetaSe
9797
}
9898

9999
func applySidecarAllocationInfoFromMainContainer(sidecarAllocationInfo, mainAllocationInfo *state.AllocationInfo) bool {
100+
changed := false
100101
if !sidecarAllocationInfo.NumaAllocationResult.Equals(mainAllocationInfo.NumaAllocationResult) {
101102
sidecarAllocationInfo.NumaAllocationResult = mainAllocationInfo.NumaAllocationResult.Clone()
102-
return true
103+
changed = true
103104
}
104-
return false
105+
106+
// Copy missing annotations from main container
107+
for key, value := range mainAllocationInfo.Annotations {
108+
if _, ok := sidecarAllocationInfo.Annotations[key]; !ok {
109+
sidecarAllocationInfo.Annotations[key] = value
110+
changed = true
111+
}
112+
}
113+
114+
return changed
105115
}

0 commit comments

Comments
 (0)