-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: zhangzujian <[email protected]>
- Loading branch information
1 parent
7537eb9
commit 0300251
Showing
4 changed files
with
64 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,49 @@ | ||
package controller_health_check | ||
|
||
import ( | ||
"net" | ||
"flag" | ||
"os" | ||
"time" | ||
|
||
"github.com/spf13/pflag" | ||
"k8s.io/klog/v2" | ||
|
||
"github.com/kubeovn/kube-ovn/pkg/util" | ||
) | ||
|
||
func CmdMain() { | ||
var tls = pflag.Bool("tls", false, "Whether kube-ovn-controller uses TLS") | ||
|
||
klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) | ||
klog.InitFlags(klogFlags) | ||
|
||
// sync the glog and klog flags. | ||
pflag.CommandLine.VisitAll(func(f1 *pflag.Flag) { | ||
f2 := klogFlags.Lookup(f1.Name) | ||
if f2 != nil { | ||
value := f1.Value.String() | ||
if err := f2.Value.Set(value); err != nil { | ||
util.LogFatalAndExit(err, "failed to set pflag") | ||
} | ||
} | ||
}) | ||
|
||
pflag.CommandLine.AddGoFlagSet(klogFlags) | ||
pflag.CommandLine.AddGoFlagSet(flag.CommandLine) | ||
pflag.Parse() | ||
|
||
addr := "127.0.0.1:10660" | ||
if os.Getenv("ENABLE_BIND_LOCAL_IP") == "true" { | ||
addr = util.JoinHostPort(os.Getenv("POD_IP"), 10660) | ||
} | ||
|
||
conn, err := net.DialTimeout("tcp", addr, 3*time.Second) | ||
if err != nil { | ||
util.LogFatalAndExit(err, "failed to probe the socket") | ||
if *tls { | ||
addr = "tls://" + addr | ||
} else { | ||
addr = "tcp://" + addr | ||
} | ||
err = conn.Close() | ||
if err != nil { | ||
util.LogFatalAndExit(err, "failed to close connection") | ||
|
||
if err := util.DialTCP(addr, time.Second, false); err != nil { | ||
util.LogFatalAndExit(err, "failed to probe the socket") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters