Skip to content

Commit

Permalink
fix: kcctl add kcServerHealthCheckTimeout flag to speicfy health check (
Browse files Browse the repository at this point in the history
#685)

Signed-off-by: lixd <xueduan.li@gmail.com>
  • Loading branch information
lixd committed Mar 5, 2024
1 parent 34a23e7 commit 400c3ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
52 changes: 28 additions & 24 deletions cmd/kcctl/app/options/options.go
Expand Up @@ -25,6 +25,7 @@ import (
"io"
"os"
"path/filepath"
"time"

"github.com/subosito/gotenv"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -270,28 +271,29 @@ type Metadata struct {
}

type DeployConfig struct {
Config string `json:"-" yaml:"-"`
SSHConfig *sshutils.SSH `json:"ssh" yaml:"ssh,omitempty"`
EtcdConfig *Etcd `json:"etcd" yaml:"etcd,omitempty"`
ServerIPs []string `json:"serverIPs" yaml:"serverIPs,omitempty"`
Agents Agents `json:"agents" yaml:"agents,omitempty"`
Proxys []string `json:"proxys" yaml:"proxys,omitempty"`
IPDetect string `json:"ipDetect" yaml:"ipDetect,omitempty"`
NodeIPDetect string `json:"nodeIPDetect" yaml:"nodeIPDetect,omitempty"`
Debug bool `json:"debug" yaml:"debug,omitempty"`
DefaultRegion string `json:"defaultRegion" yaml:"defaultRegion,omitempty"`
ServerPort int `json:"serverPort" yaml:"serverPort,omitempty"`
TLS bool `json:"tls" yaml:"tls,omitempty"`
StaticServerPort int `json:"staticServerPort" yaml:"staticServerPort,omitempty"`
StaticServerPath string `json:"staticServerPath" yaml:"staticServerPath,omitempty"`
Pkg string `json:"pkg" yaml:"pkg,omitempty"`
ConsolePort int `json:"consolePort" yaml:"consolePort,omitempty"`
JWTSecret string `json:"jwtSecret" yaml:"jwtSecret,omitempty"`
AuditOpts *option.AuditOptions `json:"audit" yaml:"audit,omitempty"`
MQ *MQ `json:"mq" yaml:"mq,omitempty"`
OpLog *OpLog `json:"opLog" yaml:"opLog,omitempty"`
ImageProxy *ImageProxy `json:"imageProxy" yaml:"imageProxy,omitempty"`
AuthenticationOpts *options.AuthenticationOptions `json:"authentication" yaml:"authentication,omitempty"`
Config string `json:"-" yaml:"-"`
SSHConfig *sshutils.SSH `json:"ssh" yaml:"ssh,omitempty"`
EtcdConfig *Etcd `json:"etcd" yaml:"etcd,omitempty"`
ServerIPs []string `json:"serverIPs" yaml:"serverIPs,omitempty"`
Agents Agents `json:"agents" yaml:"agents,omitempty"`
Proxys []string `json:"proxys" yaml:"proxys,omitempty"`
IPDetect string `json:"ipDetect" yaml:"ipDetect,omitempty"`
NodeIPDetect string `json:"nodeIPDetect" yaml:"nodeIPDetect,omitempty"`
Debug bool `json:"debug" yaml:"debug,omitempty"`
DefaultRegion string `json:"defaultRegion" yaml:"defaultRegion,omitempty"`
ServerPort int `json:"serverPort" yaml:"serverPort,omitempty"`
TLS bool `json:"tls" yaml:"tls,omitempty"`
StaticServerPort int `json:"staticServerPort" yaml:"staticServerPort,omitempty"`
StaticServerPath string `json:"staticServerPath" yaml:"staticServerPath,omitempty"`
Pkg string `json:"pkg" yaml:"pkg,omitempty"`
ConsolePort int `json:"consolePort" yaml:"consolePort,omitempty"`
JWTSecret string `json:"jwtSecret" yaml:"jwtSecret,omitempty"`
AuditOpts *option.AuditOptions `json:"audit" yaml:"audit,omitempty"`
MQ *MQ `json:"mq" yaml:"mq,omitempty"`
OpLog *OpLog `json:"opLog" yaml:"opLog,omitempty"`
ImageProxy *ImageProxy `json:"imageProxy" yaml:"imageProxy,omitempty"`
AuthenticationOpts *options.AuthenticationOptions `json:"authentication" yaml:"authentication,omitempty"`
KCServerHealthCheckTimeout time.Duration `json:"kcServerHealthCheckTimeout" yaml:"kcServerHealthCheckTimeout,omitempty"`
}

type AgentRegions map[string][]string // key: region, value: ips
Expand Down Expand Up @@ -363,8 +365,9 @@ func NewDeployOptions() *DeployConfig {
ImageProxy: &ImageProxy{
KcImageRepoMirror: getRepoMirror(),
},
AuthenticationOpts: options.NewAuthenticateOptions(),
Agents: make(Agents),
AuthenticationOpts: options.NewAuthenticateOptions(),
Agents: make(Agents),
KCServerHealthCheckTimeout: time.Second * 30,
}
}

Expand Down Expand Up @@ -486,6 +489,7 @@ func (c *DeployConfig) AddFlags(flags *pflag.FlagSet) {
flags.StringVar(&c.OpLog.Dir, "oplog-dir", c.OpLog.Dir, "kc agent operation log dir")
flags.IntVar(&c.OpLog.Threshold, "oplog-threshold", c.OpLog.Threshold, "kc agent operation log single threshold")
flags.StringVar(&c.ImageProxy.KcImageRepoMirror, "kc-image-repo-mirror", c.ImageProxy.KcImageRepoMirror, "K8s image repository mirror")
flags.DurationVar(&c.KCServerHealthCheckTimeout, "kc-server-health-check-timeout", c.KCServerHealthCheckTimeout, "kc server health check timeout, default is 30s")

AddFlagsToSSH(c.SSHConfig, flags)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/deploy/deploy.go
Expand Up @@ -729,7 +729,7 @@ func (d *DeployOptions) deployKcServer() {
}

// wait kc-server start
ctx, cancel := context.WithTimeout(context.Background(), 21*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), d.deployConfig.KCServerHealthCheckTimeout)
defer cancel()
err = retryFunc(ctx, 3*time.Second, "waitServiceRunning", host, d.waitServerRunning)
if err != nil {
Expand Down

0 comments on commit 400c3ee

Please sign in to comment.