Skip to content

Commit 6b33849

Browse files
committed
node: fix SetKubeletNodeIP when kubeletEnvFile does not exists
1 parent 98ca36a commit 6b33849

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/network/network.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ limitations under the License.
1717
package network
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"github.com/txn2/txeh"
2223
"github.com/vishvananda/netlink"
2324
"golang.org/x/sys/unix"
2425
"io/ioutil"
2526
"net"
27+
"os"
2628
"os/exec"
2729
"strings"
2830
)
@@ -82,6 +84,9 @@ func SetHostname(hostname string) {
8284

8385
// SetKubeletNodeIP sets the node IP in the kubelet configuration.
8486
func SetKubeletNodeIP(kubeletEnvFile string, ip net.IP) {
87+
if _, err := os.Stat(kubeletEnvFile); errors.Is(err, os.ErrNotExist) {
88+
return
89+
}
8590
// TODO: Do not override existing content?
8691
s := fmt.Sprintf("KUBELET_EXTRA_ARGS=\"--node-ip=%s\"\n", ip.String())
8792
check(ioutil.WriteFile(kubeletEnvFile, []byte(s), 0644))

0 commit comments

Comments
 (0)