Skip to content

[release-4.16] OCPBUGS-51017: Delete CNI configuration file when SDN pod is stopped #653

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

Open
wants to merge 1 commit into
base: release-4.16
Choose a base branch
from
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 @@ -121,6 +122,10 @@ func (sdn *openShiftSDN) run(c *cobra.Command, errout io.Writer, stopCh chan str

<-stopCh
time.Sleep(500 * time.Millisecond) // gracefully shut down
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?

if err != nil {
klog.Errorf("unable to delete sdn cni configuration file: %v", err)
}
}

// validateAndParse validates the command line options, parses the node
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)
}