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"
@@ -785,6 +786,21 @@ func handleTermination(lbc *k8s.LoadBalancerController, nginxManager nginx.Manag
785786 select {
786787 case err := <- cpcfg .nginxDone :
787788 if err != nil {
789+ // removes .sock files after nginx exits
790+ socketPath := "/var/lib/nginx/"
791+ files , readErr := os .ReadDir (socketPath )
792+ if readErr != nil {
793+ nl .Errorf (lbc .Logger , "error trying to read directory %s: %v" , socketPath , readErr )
794+ } else {
795+ for _ , f := range files {
796+ if ! f .IsDir () && strings .HasSuffix (f .Name (), ".sock" ) {
797+ fullPath := filepath .Join (socketPath , f .Name ())
798+ if removeErr := os .Remove (fullPath ); removeErr != nil {
799+ nl .Errorf (lbc .Logger , "error trying to remove file %s: %v" , fullPath , removeErr )
800+ }
801+ }
802+ }
803+ }
788804 nl .Fatalf (lbc .Logger , "nginx command exited unexpectedly with status: %v" , err )
789805 } else {
790806 nl .Info (lbc .Logger , "nginx command exited successfully" )
You can’t perform that action at this time.
0 commit comments