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
2 changes: 1 addition & 1 deletion bcs-services/bcs-cluster-manager/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ func (cm *ClusterManager) initMicro() error { // nolint
if err := dualStackListener.AddListener(ipv4, port); err != nil { // 添加主地址监听
return err
}
if ipv6 != ipv4 {
if ipv6 != "" && ipv6 != ipv4 {
err := dualStackListener.AddListener(ipv6, port) // 添加副地址监听
if err != nil {
return err
Expand Down
4 changes: 3 additions & 1 deletion bcs-services/bcs-cluster-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ func main() { // nolint
}

// init serverConfig Ipv6Address
opt.ServerConfig.Ipv6Address = util.InitIPv6Address(opt.ServerConfig.Ipv6Address)
if opt.ServerConfig.Ipv6Address != "" && opt.Address != opt.ServerConfig.Ipv6Address {
opt.ServerConfig.Ipv6Address = util.InitIPv6Address(opt.ServerConfig.Ipv6Address)
}
blog.Infof("service ipv6 server address: %s", opt.ServerConfig.Ipv6Address)

clusterManager := app.NewClusterManager(opt)
Expand Down
8 changes: 5 additions & 3 deletions bcs-services/bcs-project-manager/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (p *ProjectService) initPermClient() error {
}

// initMicro init micro service
// NOCC:golint/fnsize(设计如此)
// nolint:funlen //(设计如此)
func (p *ProjectService) initMicro() error {

// server listen ip
Expand Down Expand Up @@ -359,8 +359,10 @@ func (p *ProjectService) initMicro() error {
if err := dualStackListener.AddListener(ipv4, port); err != nil {
return err
}
if err := dualStackListener.AddListener(ipv6, port); err != nil {
return err
if ipv6 == "" && ipv4 != ipv6 {
if err := dualStackListener.AddListener(ipv6, port); err != nil {
return err
}
}
// get grpc server
grpcServer := svc.Server()
Expand Down
8 changes: 6 additions & 2 deletions bcs-services/bcs-storage/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ func initCert(op *options.StorageOptions) {
op.ClientCert.IsSSL = true
}

// 初始化IPv6Address字段
op.ServiceConfig.InitIPv6AddressFiled()
if op.IPv6Address == "" {
blog.Infof("op.IPv6Address is empty")
} else {
// 初始化IPv6Address字段
op.ServiceConfig.InitIPv6AddressFiled()
}
}
13 changes: 9 additions & 4 deletions bcs-services/bcs-storage/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ func (m *MicroServer) initHTTPServer() error {
strconv.FormatUint(m.op.GRPCPort, 10)), grpcDialOpts); err != nil {
return errors.Wrapf(err, "register http gateway failed")
}

m.httpServer = ipv6server.NewTlsIPv6Server([]string{m.op.Address, m.op.IPv6Address},
addresses := []string{m.op.Address}
if m.op.IPv6Address != "" && m.op.Address != m.op.IPv6Address {
addresses = append(addresses, m.op.Address)
}
m.httpServer = ipv6server.NewTlsIPv6Server(addresses,
strconv.FormatUint(m.op.HttpPort, 10), "tcp", m.serverTLSConfig, gMux,
)

Expand Down Expand Up @@ -120,8 +123,10 @@ func (m *MicroServer) initGrpcServer() (err error) {
if err = dualStackListener.AddListener(ipv4, port); err != nil { // 添加IPv4地址监听
return errors.Wrapf(err, "add IPv4 address failed")
}
if err = dualStackListener.AddListener(ipv6, port); err != nil { // 添加IPv6地址监听
return errors.Wrapf(err, "add IPv6 address failed")
if ipv6 != "" && ipv6 != ipv4 {
if err = dualStackListener.AddListener(ipv6, port); err != nil { // 添加IPv6地址监听
return errors.Wrapf(err, "add IPv6 address failed")
}
}

// 创建go-micro服务
Expand Down
5 changes: 4 additions & 1 deletion bcs-services/bcs-storage/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ func (s *StorageServer) close() {
func runPrometheusMetrics(op *options.StorageOptions) {
http.Handle("/metrics", promhttp.Handler())
// ipv4 ipv6
ips := []string{op.Address, op.IPv6Address}
ips := []string{op.Address}
if op.IPv6Address != "" && op.IPv6Address != op.Address {
ips = append(ips, op.IPv6Address)
}
ipv6Server := ipv6server.NewIPv6Server(ips, strconv.Itoa(int(op.MetricPort)), "", nil)
// 启动server,同时监听v4、v6地址
// nolint
Expand Down
11 changes: 10 additions & 1 deletion bcs-services/bcs-user-manager/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ package app

import (
"fmt"
"net"
"os"

"github.com/Tencent/bk-bcs/bcs-common/common"
"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/Tencent/bk-bcs/bcs-common/common/encrypt"
"github.com/Tencent/bk-bcs/bcs-common/common/ssl"
"github.com/Tencent/bk-bcs/bcs-common/common/types"
"github.com/Tencent/bk-bcs/bcs-common/common/util"

"github.com/Tencent/bk-bcs/bcs-services/bcs-user-manager/app/pkg/component"
Expand Down Expand Up @@ -87,11 +89,18 @@ func Run(op *options.UserManagerOptions) {
}

// parseConfig parse the option to config
// nolint:funlen
func parseConfig(op *options.UserManagerOptions) (*config.UserMgrConfig, error) {
userMgrConfig := config.NewUserMgrConfig()

userMgrConfig.Address = op.Address
userMgrConfig.IPv6Address = util.InitIPv6Address(op.IPv6Address)
ipv6Address := util.InitIPv6Address(op.IPv6Address)
// 如果没有主动配置IPv6,同时也没有从环境变量解析出可用IPv6,则不监听IPv6地址
if op.IPv6Address == "" && ipv6Address == net.IPv6loopback.String() &&
util.GetIPv6Address(os.Getenv(types.LOCALIPV6)) == "" {
ipv6Address = ""
}
userMgrConfig.IPv6Address = ipv6Address
userMgrConfig.Port = op.Port
userMgrConfig.InsecureAddress = op.InsecureAddress
userMgrConfig.InsecurePort = op.InsecurePort
Expand Down
Loading