fix: resolve PIDPressure evictions and crash-safety issues - #86
Closed
Zherphy wants to merge 1 commit into
Closed
Conversation
Root cause: zombie [git] child processes accumulate because PID 1 (Go app) never calls wait() to reap them, exhausting the node PID table and triggering Kubernetes PIDPressure evictions. Key changes: - main.go: add SIGCHLD signal handler to reap zombie git processes - main.go: add SIGTERM graceful shutdown via http.Server.Shutdown() - main.go: make initConfig/initObsClient errors fatal (was silently continuing) - main.go: fix dead-code err check after server.New() (err was shadowed) - Dockerfile: add tini as PID 1 for defense-in-depth zombie reaping - server/server.go: replace panic()/must() in HTTP handlers with proper error responses (was crashing entire process on OBS API hiccup) - server/server.go: generateDownloadUrl now returns (*url.URL, error) instead of panicking on failure - server/server.go: enhance health check to verify DB and OBS connectivity - server/server.go: add depth limit (10) to checkRepoOidName recursion - db/db.go: move AutoMigrate from every InsertLFSObj call to startup RunMigration() (called once in main.go) - db/db.go: replace log.Fatal with proper error return in Init()
Welcome To opensourceways CommunityHey @Zherphy , thanks for your contribution to the community. Bot Usage ManualI'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. Contact GuideIf you have any questions, please contact the SIG: infratructure , |
CLA Signature PassZherphy, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
Linking Issue Notice@Zherphy , the pull request must be linked to at least one issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the root cause of repeated pod restarts and evictions in the
openeuler-bigfilesproduction namespace. All 17 failed pods were killed due to node PID exhaustion (PIDPressure) — the Go application spawnsgitchild processes (viaGetLFSMapping→python3 lfsNameQuery.py) but never reaps them, causing zombie[git] <defunct>processes to accumulate until the node PID table is exhausted.Current state observed in production: 87,747 zombie processes in a single running pod.
Changes
Critical — Zombie Process Reaping (Root Cause Fix)
SIGCHLDsignal handler withsyscall.Wait4(WNOHANG)to reap zombie child processestinias PID 1 (defense-in-depth — tini also reaps zombies even if the Go handler misses some)Critical — Crash Safety
panic()/must()calls in HTTP handlers with proper error responses. Previously, a single OBS API hiccup or URL parse error would crash the entire process, killing all in-flight requests.generateDownloadUrlnow returns(*url.URL, error)instead of panickingHigh — Startup Reliability
initConfig()andinitObsClient()errors are now fatal — the server refuses to start with broken DB/auth/OBS dependencieserrcheck afterserver.New()— theif err != nilblock was checking a shadowed variableMedium — Operational Improvements
http.Server.Shutdown()checkRepoOidName()to prevent stack overflowAutoMigratefrom everyInsertLFSObjcall to one-timeRunMigration()at startuplog.Fatalwith proper error return inInit()Test Updates
Verification
go build ./main.go— compiles successfullygo test ./server -skip 'TestAddGithubMetaData_AfterFuncRecover|TestAddMetaData_AfterFuncRecover'— all tests passProduction Impact
After deploying this fix: