tigerquoll opened a new pull request, #1070: URL: https://github.com/apache/yunikorn-k8shim/pull/1070
### What is this PR for? `Task.checkPodMetadataBeforeScheduling` read `task.pod` without the task lock on the shim scheduling goroutine (`Application.Schedule` -> `scheduleTasks`), concurrently with `SetTaskPod`, which replaces the same field under `task.lock` from the informer handler (`Context.updateYuniKornPod`). The neighbouring `checkPodPVCs` takes `RLock` for exactly the same field, so this was a missed lock, not a lock-free design choice. Confirmed with the race detector under bind churn (the YUNIKORN-3377 fault-injection scenarios): read frame `scheduleTasks` via the `wait.BackoffUntil` scheduling loop, write frame `SetTaskPod` via `Context.UpdatePod` -- both production paths. An audit of every other `task.pod` access in the file found them correctly protected, so this was the only gap. The fix takes one reference under the lock at the top of the check (`pod := task.GetTaskPod()`) and uses it throughout, including in `logIgnoredPodMetadata`, which now receives the pod instead of re-reading the field. The consequences of the race were limited -- the function is diagnostic-only (a warning log and a k8s event) and both racing values are complete informer objects -- but it is undefined behaviour under the Go memory model and intermittently fails any race-enabled CI run (~1 in 9-18 chaos-scenario runs). ### How was this patch tested? - Race-hunt soak (bind churn under `-race`, the tool that found the defect): before the fix it fires in roughly every 60s run; with the fix, three consecutive runs show zero occurrences of this race (the only remaining reports are the separate YUNIKORN-3355 informer-object mutation, fixed in #1066). - Full `pkg/cache` suite green with `-race` and deadlock detection; `make lint` and `make license-check` clean. Generated by the Author with assistance from Claude Code -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
