Skip to content

Commit 484bf1d

Browse files
committed
Merge branch 'refactor/health-check' into 'master'
只要声明ports,就免费赠送tcp健康检查,如需http健康检查,需自定义url以及expected_codes,相应地agent也需要修改 agent 配套改动见 http://gitlab.ricebook.net/platform/agent/merge_requests/12 @platform See merge request !34
2 parents 50c54ec + 190e203 commit 484bf1d

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.7.10
1+
0.7.11

cluster/calcium/create_container.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package calcium
33
import (
44
"fmt"
55
"path/filepath"
6+
"strconv"
67
"strings"
78
"sync"
89
"time"
@@ -594,10 +595,15 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
594595
"version": utils.GetVersion(opts.Image),
595596
"ports": strings.Join(ports, ","),
596597
}
597-
// 支持健康检测, 但是只支持tcp和http
598-
if entry.HealthCheck == "tcp" || entry.HealthCheck == "http" {
599-
containerLabels["healthcheck"] = entry.HealthCheck
598+
// 只要声明了ports,就免费赠送tcp健康检查,如果需要http健康检查,还要单独声明 healthcheck_url
599+
if entry.HealthCheckUrl != "" {
600+
containerLabels["healthcheck"] = "http"
601+
containerLabels["healthcheck_url"] = entry.HealthCheckUrl
602+
containerLabels["healthcheck_expected_code"] = strconv.Itoa(entry.HealthCheckExpectedCode)
603+
} else {
604+
containerLabels["healthcheck"] = "tcp"
600605
}
606+
601607
// 要把after_start和before_stop写进去
602608
containerLabels[AFTER_START] = entry.AfterStart
603609
containerLabels[BEFORE_STOP] = entry.BeforeStop

devtools/upgrade-eru-core.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ then
1313
elif [ $deploy_mode == "prod" ]
1414
then
1515
ssh c2-eru-1.ricebook.link -t 'sudo yum --enablerepo=ricebook clean metadata'
16-
ssh c1-eru-1.ricebook.link -t 'sudo yum makecache'
16+
ssh c2-eru-1.ricebook.link -t 'sudo yum makecache'
1717
ssh c2-eru-1.ricebook.link -t 'sudo yum reinstall -y eru-core'
1818
ssh c2-eru-1.ricebook.link -t 'sudo systemctl daemon-reload'
1919
ssh c2-eru-1.ricebook.link -t 'sudo systemctl restart eru-core.service'

types/config.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
package types
22

3+
// Config holds eru-core config
34
type Config struct {
45
Bind string `yaml:"bind"` // HTTP API address
56
AgentPort string `yaml:"agent_port"` // Agent HTTP port, may not be used
67
PermDir string `yaml:"permdir"` // Permanent dir on host
78
EtcdMachines []string `yaml:"etcd"` // etcd cluster addresses
89
EtcdLockPrefix string `yaml:"etcd_lock_prefix"` // etcd lock prefix, all locks will be created under this dir
9-
ResourceAlloc string `yaml:"resource_alloc` // scheduler or cpu-period TODO give it a good name
10+
ResourceAlloc string `yaml:"resource_alloc"` // scheduler or cpu-period TODO give it a good name
1011

1112
Git GitConfig `yaml:"git"`
1213
Docker DockerConfig `yaml:"docker"`
1314
Scheduler SchedConfig `yaml:"scheduler"`
1415
Syslog SyslogConfig `yaml:"syslog"`
1516
}
1617

18+
// GitConfig holds eru-core git config
1719
type GitConfig struct {
1820
PublicKey string `yaml:"public_key"` // public key to clone code
1921
PrivateKey string `yaml:"private_key"` // private key to clone code
2022
GitlabToken string `yaml:"gitlab_token"` // GitLab token to call GitLab API
2123
}
2224

25+
// DockerConfig holds eru-core docker config
2326
type DockerConfig struct {
2427
APIVersion string `yaml:"version"` // docker API version
2528
LogDriver string `yaml:"log_driver"` // docker log driver, can be "json-file", "none"
@@ -31,13 +34,14 @@ type DockerConfig struct {
3134
UseLocalDNS bool `yaml:"local_dns"` // use node IP as dns
3235
}
3336

37+
// SchedConfig holds scheduler config
3438
type SchedConfig struct {
3539
LockKey string `yaml:"lock_key"` // key for etcd lock
3640
LockTTL int `yaml:"lock_ttl"` // TTL for etcd lock
3741
Type string `yaml:"type"` // choose simple or complex scheduler
3842
}
3943

40-
// 用于debug模式容器的日志收集
44+
// SyslogConfig 用于debug模式容器的日志收集
4145
type SyslogConfig struct {
4246
Address string `yaml:"address"`
4347
Facility string `yaml:"facility"`

types/specs.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ type Specs struct {
2222

2323
// single entrypoint
2424
type Entrypoint struct {
25-
Command string `yaml:"cmd,omitempty"`
26-
AfterStart string `yaml:"after_start,omitempty"`
27-
BeforeStop string `yaml:"before_stop,omitempty"`
28-
Ports []Port `yaml:"ports,omitempty,flow"`
29-
Exposes []Expose `yaml:"exposes,omitempty,flow"`
30-
NetworkMode string `yaml:"network_mode,omitempty"`
31-
RestartPolicy string `yaml:"restart,omitempty"`
32-
HealthCheck string `yaml:"health_check,omitempty"`
33-
ExtraHosts []string `yaml:"hosts,omitempty,flow"`
34-
PermDir bool `yaml:"permdir,omitempty"`
35-
Privileged string `yaml:"privileged,omitempty"`
36-
LogConfig string `yaml:"log_config,omitempty"`
37-
WorkingDir string `yaml:"working_dir,omitempty"`
25+
Command string `yaml:"cmd,omitempty"`
26+
AfterStart string `yaml:"after_start,omitempty"`
27+
BeforeStop string `yaml:"before_stop,omitempty"`
28+
Ports []Port `yaml:"ports,omitempty,flow"`
29+
Exposes []Expose `yaml:"exposes,omitempty,flow"`
30+
NetworkMode string `yaml:"network_mode,omitempty"`
31+
RestartPolicy string `yaml:"restart,omitempty"`
32+
HealthCheckUrl string `yaml:"healthcheck_url,omitempty"`
33+
HealthCheckExpectedCode int `yaml:"healthcheck_expected_code,omitempty"`
34+
ExtraHosts []string `yaml:"hosts,omitempty,flow"`
35+
PermDir bool `yaml:"permdir,omitempty"`
36+
Privileged string `yaml:"privileged,omitempty"`
37+
LogConfig string `yaml:"log_config,omitempty"`
38+
WorkingDir string `yaml:"working_dir,omitempty"`
3839
}
3940

4041
// single bind

0 commit comments

Comments
 (0)