Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick for release-1.9]fix PodGroup being incorrectly deleted due to frequent creation and deletion of pods #3376

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/controllers/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/klog/v2"

"volcano.sh/apis/pkg/apis/batch/v1alpha1"

"volcano.sh/volcano/pkg/controllers/apis"
)

Expand Down
4 changes: 3 additions & 1 deletion pkg/scheduler/api/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ type NodeResourceMap map[string]*Resource

// JobInfo will have all info of a Job
type JobInfo struct {
UID JobID
UID JobID
PgUID types.UID

Name string
Namespace string
Expand Down Expand Up @@ -396,6 +397,7 @@ func (ji *JobInfo) SetPodGroup(pg *PodGroup) {
}
ji.TaskMinAvailableTotal = taskMinAvailableTotal

ji.PgUID = pg.UID
ji.PodGroup = pg
}

Expand Down
17 changes: 14 additions & 3 deletions pkg/scheduler/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,20 @@ func (sc *SchedulerCache) processCleanupJob() {
defer sc.Mutex.Unlock()

if schedulingapi.JobTerminated(job) {
delete(sc.Jobs, job.UID)
metrics.DeleteJobMetrics(job.Name, string(job.Queue), job.Namespace)
klog.V(3).Infof("Job <%v:%v/%v> was deleted.", job.UID, job.Namespace, job.Name)
oldJob, found := sc.Jobs[job.UID]
if !found {
klog.V(3).Infof("Failed to find Job <%v:%v/%v>, ignore it", job.UID, job.Namespace, job.Name)
sc.DeletedJobs.Forget(obj)
return
}
newPgVersion := oldJob.PgUID
oldPgVersion := job.PgUID
klog.V(5).Infof("Just add pguid:%v, try to delete pguid:%v", newPgVersion, oldPgVersion)
if oldPgVersion == newPgVersion {
delete(sc.Jobs, job.UID)
metrics.DeleteJobMetrics(job.Name, string(job.Queue), job.Namespace)
klog.V(3).Infof("Job <%v:%v/%v> was deleted.", job.UID, job.Namespace, job.Name)
}
sc.DeletedJobs.Forget(obj)
} else {
// Retry
Expand Down
Loading