summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKubeEdge Bot <48982446+kubeedge-bot@users.noreply.github.com>2023-07-27 11:44:11 +0800
committerGitHub <noreply@github.com>2023-07-27 11:44:11 +0800
commitf33d7b7ec37b6f725a60b1a3f91aa267019d12c9 (patch)
tree0d14d237cee60ca43f6db9ae46855d3815ab1e2f
parentMerge pull request #4891 from Shelley-BaoYue/automated-cherry-pick-of-#4696-u... (diff)
parentbugfix nodeip in edgestream (diff)
downloadkubeedge-f33d7b7ec37b6f725a60b1a3f91aa267019d12c9.tar.gz
Merge pull request #4894 from Shelley-BaoYue/automated-cherry-pick-of-#4641-upstream-release-1.13
Automated cherry pick of #4641: replace nodeIP initialization in edged
-rw-r--r--edge/cmd/edgecore/app/server.go16
-rw-r--r--edge/pkg/edgestream/edgestream.go23
-rw-r--r--pkg/apis/componentconfig/edgecore/v1alpha2/default.go2
3 files changed, 20 insertions, 21 deletions
diff --git a/edge/cmd/edgecore/app/server.go b/edge/cmd/edgecore/app/server.go
index 562780ebf..0030ce7fe 100644
--- a/edge/cmd/edgecore/app/server.go
+++ b/edge/cmd/edgecore/app/server.go
@@ -3,7 +3,6 @@ package app
import (
"errors"
"fmt"
- "net"
"os"
"github.com/mitchellh/go-ps"
@@ -125,21 +124,6 @@ offering HTTP client capabilities to components of cloud to reach HTTP servers r
}
config.Modules.Edged.NodeIP = ip.String()
klog.Infof("Get IP address by custom interface successfully, %s: %s", config.Modules.Edged.CustomInterfaceName, config.Modules.Edged.NodeIP)
- } else {
- if net.ParseIP(config.Modules.Edged.NodeIP) != nil {
- klog.Infof("Use node IP address from config: %s", config.Modules.Edged.NodeIP)
- } else if config.Modules.Edged.NodeIP != "" {
- klog.Errorf("invalid node IP address specified: %s", config.Modules.Edged.NodeIP)
- os.Exit(1)
- } else {
- nodeIP, err := util.GetLocalIP(util.GetHostname())
- if err != nil {
- klog.Errorf("Failed to get Local IP address: %v", err)
- os.Exit(1)
- }
- config.Modules.Edged.NodeIP = nodeIP
- klog.Infof("Get node local IP address successfully: %s", nodeIP)
- }
}
registerModules(config)
diff --git a/edge/pkg/edgestream/edgestream.go b/edge/pkg/edgestream/edgestream.go
index e646d7333..03e318865 100644
--- a/edge/pkg/edgestream/edgestream.go
+++ b/edge/pkg/edgestream/edgestream.go
@@ -20,6 +20,7 @@ import (
"crypto/tls"
"net/http"
"net/url"
+ "os"
"time"
"github.com/gorilla/websocket"
@@ -32,6 +33,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/edgestream/config"
"github.com/kubeedge/kubeedge/pkg/apis/componentconfig/edgecore/v1alpha2"
"github.com/kubeedge/kubeedge/pkg/stream"
+ "github.com/kubeedge/kubeedge/pkg/util"
)
type edgestream struct {
@@ -42,18 +44,33 @@ type edgestream struct {
var _ core.Module = (*edgestream)(nil)
-func newEdgeStream(enable bool, hostnameOverride, nodeIP string) *edgestream {
+func newEdgeStream(enable bool, hostnameOverride, nodeIP string) (*edgestream, error) {
+ var err error
+ if nodeIP == "" {
+ nodeIP, err = util.GetLocalIP(util.GetHostname())
+ if err != nil {
+ klog.Errorf("Failed to get Local IP address: %v", err)
+ return nil, err
+ }
+ klog.Infof("Get node local IP address successfully: %s", nodeIP)
+ }
+
return &edgestream{
enable: enable,
hostnameOverride: hostnameOverride,
nodeIP: nodeIP,
- }
+ }, nil
}
// Register register edgestream
func Register(s *v1alpha2.EdgeStream, hostnameOverride, nodeIP string) {
config.InitConfigure(s)
- core.Register(newEdgeStream(s.Enable, hostnameOverride, nodeIP))
+ edgeStream, err := newEdgeStream(s.Enable, hostnameOverride, nodeIP)
+ if err != nil {
+ klog.Errorf("init new edged error, %v", err)
+ os.Exit(1)
+ }
+ core.Register(edgeStream)
}
func (e *edgestream) Name() string {
diff --git a/pkg/apis/componentconfig/edgecore/v1alpha2/default.go b/pkg/apis/componentconfig/edgecore/v1alpha2/default.go
index 7ee335c69..9f2560489 100644
--- a/pkg/apis/componentconfig/edgecore/v1alpha2/default.go
+++ b/pkg/apis/componentconfig/edgecore/v1alpha2/default.go
@@ -54,7 +54,6 @@ func NewDefaultEdgeCoreConfig() *EdgeCoreConfig {
TailoredKubeletConfig: &defaultTailedKubeletConfig,
TailoredKubeletFlag: TailoredKubeletFlag{
HostnameOverride: hostnameOverride,
- NodeIP: localIP,
ContainerRuntimeOptions: ContainerRuntimeOptions{
ContainerRuntime: constants.DefaultRuntimeType,
PodSandboxImage: constants.DefaultPodSandboxImage,
@@ -190,7 +189,6 @@ func NewMinEdgeCoreConfig() *EdgeCoreConfig {
TailoredKubeletConfig: &defaultTailedKubeletConfig,
TailoredKubeletFlag: TailoredKubeletFlag{
HostnameOverride: hostnameOverride,
- NodeIP: localIP,
ContainerRuntimeOptions: ContainerRuntimeOptions{
ContainerRuntime: constants.DefaultRuntimeType,
PodSandboxImage: constants.DefaultPodSandboxImage,