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

Clean up and fix for NIC Pod failing to bind when NGINX exits unexpectedly #7121

Merged
merged 3 commits into from
Jan 14, 2025
Merged
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
16 changes: 16 additions & 0 deletions cmd/nginx-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"net/http"
"os"
"os/signal"
"path/filepath"
"regexp"
"runtime"
"strings"
Expand Down Expand Up @@ -788,6 +789,21 @@
select {
case err := <-cpcfg.nginxDone:
if err != nil {
// removes .sock files after nginx exits
socketPath := "/var/lib/nginx/"
files, readErr := os.ReadDir(socketPath)
if readErr != nil {
nl.Errorf(lbc.Logger, "error trying to read directory %s: %v", socketPath, readErr)
} else {
for _, f := range files {
if !f.IsDir() && strings.HasSuffix(f.Name(), ".sock") {
fullPath := filepath.Join(socketPath, f.Name())
if removeErr := os.Remove(fullPath); removeErr != nil {
nl.Errorf(lbc.Logger, "error trying to remove file %s: %v", fullPath, removeErr)
}

Check warning on line 803 in cmd/nginx-ingress/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/nginx-ingress/main.go#L792-L803

Added lines #L792 - L803 were not covered by tests
}
}
}
nl.Fatalf(lbc.Logger, "nginx command exited unexpectedly with status: %v", err)
} else {
nl.Info(lbc.Logger, "nginx command exited successfully")
Expand Down
Loading