File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010 "net/http"
1111 "os"
1212 "os/signal"
13+ "path/filepath"
1314 "regexp"
1415 "runtime"
1516 "strings"
@@ -788,6 +789,21 @@ func handleTermination(lbc *k8s.LoadBalancerController, nginxManager nginx.Manag
788789 select {
789790 case err := <- cpcfg .nginxDone :
790791 if err != nil {
792+ // removes .sock files after nginx exits
793+ socketPath := "/var/lib/nginx/"
794+ files , readErr := os .ReadDir (socketPath )
795+ if readErr != nil {
796+ nl .Errorf (lbc .Logger , "error trying to read directory %s: %v" , socketPath , readErr )
797+ } else {
798+ for _ , f := range files {
799+ if ! f .IsDir () && strings .HasSuffix (f .Name (), ".sock" ) {
800+ fullPath := filepath .Join (socketPath , f .Name ())
801+ if removeErr := os .Remove (fullPath ); removeErr != nil {
802+ nl .Errorf (lbc .Logger , "error trying to remove file %s: %v" , fullPath , removeErr )
803+ }
804+ }
805+ }
806+ }
791807 nl .Fatalf (lbc .Logger , "nginx command exited unexpectedly with status: %v" , err )
792808 } else {
793809 nl .Info (lbc .Logger , "nginx command exited successfully" )
You can’t perform that action at this time.
0 commit comments