Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion pkg/cmd/openshift-sdn-node/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package openshift_sdn_node

import (
"fmt"
"github.com/spf13/pflag"
"io"
"os"
"path/filepath"
"time"

"github.com/spf13/pflag"

"github.com/fsnotify/fsnotify"
"github.com/spf13/cobra"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -120,6 +121,10 @@ func (sdn *openShiftSDN) run(c *cobra.Command, errout io.Writer, stopCh chan str
}

<-stopCh
err = sdn.deleteConfigFile()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we delete before the Sleep?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, moved deleting the file before the sleep, this may help to improve the scenario.

if err != nil {
klog.Errorf("unable to delete sdn cni configuration file: %v", err)
}
time.Sleep(500 * time.Millisecond) // gracefully shut down
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/openshift-sdn-node/sdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package openshift_sdn_node

import (
"io/ioutil"
"os"

corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -56,3 +57,8 @@ func (sdn *openShiftSDN) writeConfigFile() error {
}
`), 0600)
}

func (sdn *openShiftSDN) deleteConfigFile() error {
// Delete CNI config file from disk if it's no longer able to serve CNI requests.
return os.Remove(openshiftCNIFile)
}