mirror of https://github.com/status-im/consul.git
Remove the script field from checks in favor of args
This commit is contained in:
parent
cc214d45b6
commit
b73323aa42
|
@ -1823,11 +1823,6 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *structs.CheckType,
|
|||
check.CheckID, checks.MinInterval))
|
||||
chkType.Interval = checks.MinInterval
|
||||
}
|
||||
if chkType.Script != "" {
|
||||
a.logger.Printf("[WARN] agent: check %q has the 'script' field, which has been deprecated "+
|
||||
"and replaced with the 'args' field. See https://www.consul.io/docs/agent/checks.html",
|
||||
check.CheckID)
|
||||
}
|
||||
|
||||
if a.dockerClient == nil {
|
||||
dc, err := checks.NewDockerClient(os.Getenv("DOCKER_HOST"), checks.BufSize)
|
||||
|
@ -1844,7 +1839,6 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *structs.CheckType,
|
|||
CheckID: check.CheckID,
|
||||
DockerContainerID: chkType.DockerContainerID,
|
||||
Shell: chkType.Shell,
|
||||
Script: chkType.Script,
|
||||
ScriptArgs: chkType.ScriptArgs,
|
||||
Interval: chkType.Interval,
|
||||
Logger: a.logger,
|
||||
|
@ -1866,16 +1860,10 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *structs.CheckType,
|
|||
check.CheckID, checks.MinInterval)
|
||||
chkType.Interval = checks.MinInterval
|
||||
}
|
||||
if chkType.Script != "" {
|
||||
a.logger.Printf("[WARN] agent: check %q has the 'script' field, which has been deprecated "+
|
||||
"and replaced with the 'args' field. See https://www.consul.io/docs/agent/checks.html",
|
||||
check.CheckID)
|
||||
}
|
||||
|
||||
monitor := &checks.CheckMonitor{
|
||||
Notify: a.State,
|
||||
CheckID: check.CheckID,
|
||||
Script: chkType.Script,
|
||||
ScriptArgs: chkType.ScriptArgs,
|
||||
Interval: chkType.Interval,
|
||||
Timeout: chkType.Timeout,
|
||||
|
|
|
@ -716,14 +716,6 @@ func TestAgent_RegisterCheck_Scripts(t *testing.T) {
|
|||
name string
|
||||
check map[string]interface{}
|
||||
}{
|
||||
{
|
||||
"< Consul 1.0.0",
|
||||
map[string]interface{}{
|
||||
"Name": "test",
|
||||
"Interval": "2s",
|
||||
"Script": "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
"== Consul 1.0.0",
|
||||
map[string]interface{}{
|
||||
|
|
|
@ -651,8 +651,8 @@ func TestAgent_AddCheck(t *testing.T) {
|
|||
Status: api.HealthCritical,
|
||||
}
|
||||
chk := &structs.CheckType{
|
||||
Script: "exit 0",
|
||||
Interval: 15 * time.Second,
|
||||
ScriptArgs: []string{"exit", "0"},
|
||||
Interval: 15 * time.Second,
|
||||
}
|
||||
err := a.AddCheck(health, chk, false, "")
|
||||
if err != nil {
|
||||
|
@ -690,8 +690,8 @@ func TestAgent_AddCheck_StartPassing(t *testing.T) {
|
|||
Status: api.HealthPassing,
|
||||
}
|
||||
chk := &structs.CheckType{
|
||||
Script: "exit 0",
|
||||
Interval: 15 * time.Second,
|
||||
ScriptArgs: []string{"exit", "0"},
|
||||
Interval: 15 * time.Second,
|
||||
}
|
||||
err := a.AddCheck(health, chk, false, "")
|
||||
if err != nil {
|
||||
|
@ -729,8 +729,8 @@ func TestAgent_AddCheck_MinInterval(t *testing.T) {
|
|||
Status: api.HealthCritical,
|
||||
}
|
||||
chk := &structs.CheckType{
|
||||
Script: "exit 0",
|
||||
Interval: time.Microsecond,
|
||||
ScriptArgs: []string{"exit", "0"},
|
||||
Interval: time.Microsecond,
|
||||
}
|
||||
err := a.AddCheck(health, chk, false, "")
|
||||
if err != nil {
|
||||
|
@ -764,8 +764,8 @@ func TestAgent_AddCheck_MissingService(t *testing.T) {
|
|||
ServiceID: "baz",
|
||||
}
|
||||
chk := &structs.CheckType{
|
||||
Script: "exit 0",
|
||||
Interval: time.Microsecond,
|
||||
ScriptArgs: []string{"exit", "0"},
|
||||
Interval: time.Microsecond,
|
||||
}
|
||||
err := a.AddCheck(health, chk, false, "")
|
||||
if err == nil || err.Error() != `ServiceID "baz" does not exist` {
|
||||
|
@ -829,8 +829,8 @@ func TestAgent_AddCheck_ExecDisable(t *testing.T) {
|
|||
Status: api.HealthCritical,
|
||||
}
|
||||
chk := &structs.CheckType{
|
||||
Script: "exit 0",
|
||||
Interval: 15 * time.Second,
|
||||
ScriptArgs: []string{"exit", "0"},
|
||||
Interval: 15 * time.Second,
|
||||
}
|
||||
err := a.AddCheck(health, chk, false, "")
|
||||
if err == nil || !strings.Contains(err.Error(), "Scripts are disabled on this agent") {
|
||||
|
@ -904,8 +904,8 @@ func TestAgent_RemoveCheck(t *testing.T) {
|
|||
Status: api.HealthCritical,
|
||||
}
|
||||
chk := &structs.CheckType{
|
||||
Script: "exit 0",
|
||||
Interval: 15 * time.Second,
|
||||
ScriptArgs: []string{"exit", "0"},
|
||||
Interval: 15 * time.Second,
|
||||
}
|
||||
err := a.AddCheck(health, chk, false, "")
|
||||
if err != nil {
|
||||
|
@ -1315,8 +1315,8 @@ func TestAgent_PersistCheck(t *testing.T) {
|
|||
Status: api.HealthPassing,
|
||||
}
|
||||
chkType := &structs.CheckType{
|
||||
Script: "/bin/true",
|
||||
Interval: 10 * time.Second,
|
||||
ScriptArgs: []string{"/bin/true"},
|
||||
Interval: 10 * time.Second,
|
||||
}
|
||||
|
||||
file := filepath.Join(a.Config.DataDir, checksDir, checkIDHash(check.CheckID))
|
||||
|
@ -1473,7 +1473,7 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
|
|||
id = "mem"
|
||||
name = "memory check"
|
||||
notes = "my cool notes"
|
||||
script = "/bin/check-redis.py"
|
||||
args = ["/bin/check-redis.py"]
|
||||
interval = "30s"
|
||||
}
|
||||
`)
|
||||
|
|
|
@ -967,7 +967,6 @@ func (b *Builder) checkVal(v *CheckDefinition) *structs.CheckDefinition {
|
|||
ServiceID: b.stringVal(v.ServiceID),
|
||||
Token: b.stringVal(v.Token),
|
||||
Status: b.stringVal(v.Status),
|
||||
Script: b.stringVal(v.Script),
|
||||
ScriptArgs: v.ScriptArgs,
|
||||
HTTP: b.stringVal(v.HTTP),
|
||||
Header: v.Header,
|
||||
|
|
|
@ -331,7 +331,6 @@ type CheckDefinition struct {
|
|||
ServiceID *string `json:"service_id,omitempty" hcl:"service_id" mapstructure:"service_id"`
|
||||
Token *string `json:"token,omitempty" hcl:"token" mapstructure:"token"`
|
||||
Status *string `json:"status,omitempty" hcl:"status" mapstructure:"status"`
|
||||
Script *string `json:"script,omitempty" hcl:"script" mapstructure:"script"`
|
||||
ScriptArgs []string `json:"args,omitempty" hcl:"args" mapstructure:"args"`
|
||||
HTTP *string `json:"http,omitempty" hcl:"http" mapstructure:"http"`
|
||||
Header map[string][]string `json:"header,omitempty" hcl:"header" mapstructure:"header"`
|
||||
|
|
|
@ -1883,17 +1883,17 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
|
|||
`-data-dir=` + dataDir,
|
||||
},
|
||||
json: []string{
|
||||
`{ "check": { "name": "a", "script": "/bin/true" } }`,
|
||||
`{ "check": { "name": "b", "script": "/bin/false" } }`,
|
||||
`{ "check": { "name": "a", "args": ["/bin/true"] } }`,
|
||||
`{ "check": { "name": "b", "args": ["/bin/false"] } }`,
|
||||
},
|
||||
hcl: []string{
|
||||
`check = { name = "a" script = "/bin/true" }`,
|
||||
`check = { name = "b" script = "/bin/false" }`,
|
||||
`check = { name = "a" args = ["/bin/true"] }`,
|
||||
`check = { name = "b" args = ["/bin/false"] }`,
|
||||
},
|
||||
patch: func(rt *RuntimeConfig) {
|
||||
rt.Checks = []*structs.CheckDefinition{
|
||||
&structs.CheckDefinition{Name: "a", Script: "/bin/true"},
|
||||
&structs.CheckDefinition{Name: "b", Script: "/bin/false"},
|
||||
&structs.CheckDefinition{Name: "a", ScriptArgs: []string{"/bin/true"}},
|
||||
&structs.CheckDefinition{Name: "b", ScriptArgs: []string{"/bin/false"}},
|
||||
}
|
||||
rt.DataDir = dataDir
|
||||
},
|
||||
|
@ -2265,7 +2265,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"service_id": "L8G0QNmR",
|
||||
"token": "oo4BCTgJ",
|
||||
"status": "qLykAl5u",
|
||||
"script": "dhGfIF8n",
|
||||
"args": ["f3BemRjy", "e5zgpef7"],
|
||||
"http": "29B93haH",
|
||||
"header": {
|
||||
|
@ -2290,7 +2289,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"service_id": "lSulPcyz",
|
||||
"token": "toO59sh8",
|
||||
"status": "9RlWsXMV",
|
||||
"script": "8qbd8tWw",
|
||||
"args": ["4BAJttck", "4D2NPtTQ"],
|
||||
"http": "dohLcyQ2",
|
||||
"header": {
|
||||
|
@ -2314,7 +2312,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"service_id": "CmUUcRna",
|
||||
"token": "a3nQzHuy",
|
||||
"status": "irj26nf3",
|
||||
"script": "FJsI1oXt",
|
||||
"args": ["9s526ogY", "gSlOHj1w"],
|
||||
"http": "yzhgsQ7Y",
|
||||
"header": {
|
||||
|
@ -2449,7 +2446,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"name": "iehanzuq",
|
||||
"status": "rCvn53TH",
|
||||
"notes": "fti5lfF3",
|
||||
"script": "rtj34nfd",
|
||||
"args": ["16WRUmwS", "QWk7j7ae"],
|
||||
"http": "dl3Fgme3",
|
||||
"header": {
|
||||
|
@ -2472,7 +2468,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"name": "sgV4F7Pk",
|
||||
"notes": "yP5nKbW0",
|
||||
"status": "7oLMEyfu",
|
||||
"script": "NlUQ3nTE",
|
||||
"args": ["5wEZtZpv", "0Ihyk8cS"],
|
||||
"http": "KyDjGY9H",
|
||||
"header": {
|
||||
|
@ -2494,7 +2489,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"name": "IEqrzrsd",
|
||||
"notes": "SVqApqeM",
|
||||
"status": "XXkVoZXt",
|
||||
"script": "IXLZTM6E",
|
||||
"args": ["wD05Bvao", "rLYB7kQC"],
|
||||
"http": "kyICZsn8",
|
||||
"header": {
|
||||
|
@ -2527,7 +2521,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"name": "atDGP7n5",
|
||||
"status": "pDQKEhWL",
|
||||
"notes": "Yt8EDLev",
|
||||
"script": "MDu7wjlD",
|
||||
"args": ["81EDZLPa", "bPY5X8xd"],
|
||||
"http": "qzHYvmJO",
|
||||
"header": {
|
||||
|
@ -2559,7 +2552,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"name": "9OOS93ne",
|
||||
"notes": "CQy86DH0",
|
||||
"status": "P0SWDvrk",
|
||||
"script": "6BhLJ7R9",
|
||||
"args": ["EXvkYIuG", "BATOyt6h"],
|
||||
"http": "u97ByEiW",
|
||||
"header": {
|
||||
|
@ -2581,7 +2573,6 @@ func TestFullConfig(t *testing.T) {
|
|||
"name": "PQSaPWlT",
|
||||
"notes": "jKChDOdl",
|
||||
"status": "5qFz6OZn",
|
||||
"script": "PbdxFZ3K",
|
||||
"args": ["NMtYWlT9", "vj74JXsm"],
|
||||
"http": "1LBDJhw4",
|
||||
"header": {
|
||||
|
@ -2706,7 +2697,6 @@ func TestFullConfig(t *testing.T) {
|
|||
service_id = "L8G0QNmR"
|
||||
token = "oo4BCTgJ"
|
||||
status = "qLykAl5u"
|
||||
script = "dhGfIF8n"
|
||||
args = ["f3BemRjy", "e5zgpef7"]
|
||||
http = "29B93haH"
|
||||
header = {
|
||||
|
@ -2731,7 +2721,6 @@ func TestFullConfig(t *testing.T) {
|
|||
service_id = "lSulPcyz"
|
||||
token = "toO59sh8"
|
||||
status = "9RlWsXMV"
|
||||
script = "8qbd8tWw"
|
||||
args = ["4BAJttck", "4D2NPtTQ"]
|
||||
http = "dohLcyQ2"
|
||||
header = {
|
||||
|
@ -2755,7 +2744,6 @@ func TestFullConfig(t *testing.T) {
|
|||
service_id = "CmUUcRna"
|
||||
token = "a3nQzHuy"
|
||||
status = "irj26nf3"
|
||||
script = "FJsI1oXt"
|
||||
args = ["9s526ogY", "gSlOHj1w"]
|
||||
http = "yzhgsQ7Y"
|
||||
header = {
|
||||
|
@ -2890,7 +2878,6 @@ func TestFullConfig(t *testing.T) {
|
|||
name = "iehanzuq"
|
||||
status = "rCvn53TH"
|
||||
notes = "fti5lfF3"
|
||||
script = "rtj34nfd"
|
||||
args = ["16WRUmwS", "QWk7j7ae"]
|
||||
http = "dl3Fgme3"
|
||||
header = {
|
||||
|
@ -2913,7 +2900,6 @@ func TestFullConfig(t *testing.T) {
|
|||
name = "sgV4F7Pk"
|
||||
notes = "yP5nKbW0"
|
||||
status = "7oLMEyfu"
|
||||
script = "NlUQ3nTE"
|
||||
args = ["5wEZtZpv", "0Ihyk8cS"]
|
||||
http = "KyDjGY9H"
|
||||
header = {
|
||||
|
@ -2935,7 +2921,6 @@ func TestFullConfig(t *testing.T) {
|
|||
name = "IEqrzrsd"
|
||||
notes = "SVqApqeM"
|
||||
status = "XXkVoZXt"
|
||||
script = "IXLZTM6E"
|
||||
args = ["wD05Bvao", "rLYB7kQC"]
|
||||
http = "kyICZsn8"
|
||||
header = {
|
||||
|
@ -2968,7 +2953,6 @@ func TestFullConfig(t *testing.T) {
|
|||
name = "atDGP7n5"
|
||||
status = "pDQKEhWL"
|
||||
notes = "Yt8EDLev"
|
||||
script = "MDu7wjlD"
|
||||
args = ["81EDZLPa", "bPY5X8xd"]
|
||||
http = "qzHYvmJO"
|
||||
header = {
|
||||
|
@ -3000,7 +2984,6 @@ func TestFullConfig(t *testing.T) {
|
|||
name = "9OOS93ne"
|
||||
notes = "CQy86DH0"
|
||||
status = "P0SWDvrk"
|
||||
script = "6BhLJ7R9"
|
||||
args = ["EXvkYIuG", "BATOyt6h"]
|
||||
http = "u97ByEiW"
|
||||
header = {
|
||||
|
@ -3022,7 +3005,6 @@ func TestFullConfig(t *testing.T) {
|
|||
name = "PQSaPWlT"
|
||||
notes = "jKChDOdl"
|
||||
status = "5qFz6OZn"
|
||||
script = "PbdxFZ3K"
|
||||
args = ["NMtYWlT9", "vj74JXsm"]
|
||||
http = "1LBDJhw4"
|
||||
header = {
|
||||
|
@ -3286,7 +3268,6 @@ func TestFullConfig(t *testing.T) {
|
|||
ServiceID: "lSulPcyz",
|
||||
Token: "toO59sh8",
|
||||
Status: "9RlWsXMV",
|
||||
Script: "8qbd8tWw",
|
||||
ScriptArgs: []string{"4BAJttck", "4D2NPtTQ"},
|
||||
HTTP: "dohLcyQ2",
|
||||
Header: map[string][]string{
|
||||
|
@ -3310,7 +3291,6 @@ func TestFullConfig(t *testing.T) {
|
|||
ServiceID: "CmUUcRna",
|
||||
Token: "a3nQzHuy",
|
||||
Status: "irj26nf3",
|
||||
Script: "FJsI1oXt",
|
||||
ScriptArgs: []string{"9s526ogY", "gSlOHj1w"},
|
||||
HTTP: "yzhgsQ7Y",
|
||||
Header: map[string][]string{
|
||||
|
@ -3334,7 +3314,6 @@ func TestFullConfig(t *testing.T) {
|
|||
ServiceID: "L8G0QNmR",
|
||||
Token: "oo4BCTgJ",
|
||||
Status: "qLykAl5u",
|
||||
Script: "dhGfIF8n",
|
||||
ScriptArgs: []string{"f3BemRjy", "e5zgpef7"},
|
||||
HTTP: "29B93haH",
|
||||
Header: map[string][]string{
|
||||
|
@ -3454,7 +3433,6 @@ func TestFullConfig(t *testing.T) {
|
|||
Name: "atDGP7n5",
|
||||
Status: "pDQKEhWL",
|
||||
Notes: "Yt8EDLev",
|
||||
Script: "MDu7wjlD",
|
||||
ScriptArgs: []string{"81EDZLPa", "bPY5X8xd"},
|
||||
HTTP: "qzHYvmJO",
|
||||
Header: map[string][]string{
|
||||
|
@ -3487,7 +3465,6 @@ func TestFullConfig(t *testing.T) {
|
|||
Name: "9OOS93ne",
|
||||
Notes: "CQy86DH0",
|
||||
Status: "P0SWDvrk",
|
||||
Script: "6BhLJ7R9",
|
||||
ScriptArgs: []string{"EXvkYIuG", "BATOyt6h"},
|
||||
HTTP: "u97ByEiW",
|
||||
Header: map[string][]string{
|
||||
|
@ -3509,7 +3486,6 @@ func TestFullConfig(t *testing.T) {
|
|||
Name: "PQSaPWlT",
|
||||
Notes: "jKChDOdl",
|
||||
Status: "5qFz6OZn",
|
||||
Script: "PbdxFZ3K",
|
||||
ScriptArgs: []string{"NMtYWlT9", "vj74JXsm"},
|
||||
HTTP: "1LBDJhw4",
|
||||
Header: map[string][]string{
|
||||
|
@ -3543,7 +3519,6 @@ func TestFullConfig(t *testing.T) {
|
|||
Name: "sgV4F7Pk",
|
||||
Notes: "yP5nKbW0",
|
||||
Status: "7oLMEyfu",
|
||||
Script: "NlUQ3nTE",
|
||||
ScriptArgs: []string{"5wEZtZpv", "0Ihyk8cS"},
|
||||
HTTP: "KyDjGY9H",
|
||||
Header: map[string][]string{
|
||||
|
@ -3565,7 +3540,6 @@ func TestFullConfig(t *testing.T) {
|
|||
Name: "IEqrzrsd",
|
||||
Notes: "SVqApqeM",
|
||||
Status: "XXkVoZXt",
|
||||
Script: "IXLZTM6E",
|
||||
ScriptArgs: []string{"wD05Bvao", "rLYB7kQC"},
|
||||
HTTP: "kyICZsn8",
|
||||
Header: map[string][]string{
|
||||
|
@ -3587,7 +3561,6 @@ func TestFullConfig(t *testing.T) {
|
|||
Name: "iehanzuq",
|
||||
Status: "rCvn53TH",
|
||||
Notes: "fti5lfF3",
|
||||
Script: "rtj34nfd",
|
||||
ScriptArgs: []string{"16WRUmwS", "QWk7j7ae"},
|
||||
HTTP: "dl3Fgme3",
|
||||
Header: map[string][]string{
|
||||
|
@ -4007,7 +3980,6 @@ func TestSanitize(t *testing.T) {
|
|||
"Method": "",
|
||||
"Name": "zoo",
|
||||
"Notes": "",
|
||||
"Script": "",
|
||||
"ScriptArgs": [],
|
||||
"ServiceID": "",
|
||||
"Shell": "",
|
||||
|
@ -4139,7 +4111,6 @@ func TestSanitize(t *testing.T) {
|
|||
"Method": "",
|
||||
"Name": "blurb",
|
||||
"Notes": "",
|
||||
"Script": "",
|
||||
"ScriptArgs": [],
|
||||
"Shell": "",
|
||||
"Status": "",
|
||||
|
|
|
@ -21,7 +21,6 @@ type CheckDefinition struct {
|
|||
//
|
||||
// ID (CheckID), Name, Status, Notes
|
||||
//
|
||||
Script string
|
||||
ScriptArgs []string
|
||||
HTTP string
|
||||
Header map[string][]string
|
||||
|
@ -63,7 +62,6 @@ func (c *CheckDefinition) CheckType() *CheckType {
|
|||
Status: c.Status,
|
||||
Notes: c.Notes,
|
||||
|
||||
Script: c.Script,
|
||||
ScriptArgs: c.ScriptArgs,
|
||||
HTTP: c.HTTP,
|
||||
GRPC: c.GRPC,
|
||||
|
|
|
@ -83,7 +83,7 @@ func TestCheckDefinitionToCheckType(t *testing.T) {
|
|||
|
||||
ServiceID: "svcid",
|
||||
Token: "tok",
|
||||
Script: "/bin/foo",
|
||||
ScriptArgs: []string{"/bin/foo"},
|
||||
HTTP: "someurl",
|
||||
TCP: "host:port",
|
||||
Interval: 1 * time.Second,
|
||||
|
@ -100,7 +100,7 @@ func TestCheckDefinitionToCheckType(t *testing.T) {
|
|||
Status: "green",
|
||||
Notes: "notes",
|
||||
|
||||
Script: "/bin/foo",
|
||||
ScriptArgs: []string{"/bin/foo"},
|
||||
HTTP: "someurl",
|
||||
TCP: "host:port",
|
||||
Interval: 1 * time.Second,
|
||||
|
|
|
@ -25,7 +25,6 @@ type CheckType struct {
|
|||
// fields copied to CheckDefinition
|
||||
// Update CheckDefinition when adding fields here
|
||||
|
||||
Script string
|
||||
ScriptArgs []string
|
||||
HTTP string
|
||||
Header map[string][]string
|
||||
|
@ -70,7 +69,7 @@ func (c *CheckType) Empty() bool {
|
|||
|
||||
// IsScript checks if this is a check that execs some kind of script.
|
||||
func (c *CheckType) IsScript() bool {
|
||||
return c.Script != "" || len(c.ScriptArgs) > 0
|
||||
return len(c.ScriptArgs) > 0
|
||||
}
|
||||
|
||||
// IsTTL checks if this is a TTL type
|
||||
|
|
|
@ -14,8 +14,8 @@ func TestAgentStructs_CheckTypes(t *testing.T) {
|
|||
|
||||
// Singular Check field works
|
||||
svc.Check = CheckType{
|
||||
Script: "/foo/bar",
|
||||
Interval: 10 * time.Second,
|
||||
ScriptArgs: []string{"/foo/bar"},
|
||||
Interval: 10 * time.Second,
|
||||
}
|
||||
|
||||
// Returns HTTP checks
|
||||
|
@ -26,8 +26,8 @@ func TestAgentStructs_CheckTypes(t *testing.T) {
|
|||
|
||||
// Returns Script checks
|
||||
svc.Checks = append(svc.Checks, &CheckType{
|
||||
Script: "/foo/bar",
|
||||
Interval: 10 * time.Second,
|
||||
ScriptArgs: []string{"/foo/bar"},
|
||||
Interval: 10 * time.Second,
|
||||
})
|
||||
|
||||
// Returns TTL checks
|
||||
|
|
|
@ -86,7 +86,6 @@ type AgentServiceCheck struct {
|
|||
CheckID string `json:",omitempty"`
|
||||
Name string `json:",omitempty"`
|
||||
Args []string `json:"ScriptArgs,omitempty"`
|
||||
Script string `json:",omitempty"` // Deprecated, use Args.
|
||||
DockerContainerID string `json:",omitempty"`
|
||||
Shell string `json:",omitempty"` // Only supported for Docker.
|
||||
Interval string `json:",omitempty"`
|
||||
|
|
|
@ -694,7 +694,7 @@ func TestAPI_AgentChecks_Docker(t *testing.T) {
|
|||
ServiceID: "redis",
|
||||
AgentServiceCheck: AgentServiceCheck{
|
||||
DockerContainerID: "f972c95ebf0e",
|
||||
Script: "/bin/true",
|
||||
Args: []string{"/bin/true"},
|
||||
Shell: "/bin/bash",
|
||||
Interval: "10s",
|
||||
},
|
||||
|
|
|
@ -247,11 +247,6 @@ In Consul 0.9.0 and later, the agent must be configured with
|
|||
[`enable_script_checks`](/docs/agent/options.html#_enable_script_checks) set to `true`
|
||||
in order to enable script checks.
|
||||
|
||||
Prior to Consul 1.0, checks used a single `script` field to define the command to run, and
|
||||
would always run in a shell. In Consul 1.0, the `args` array was added so that checks can be
|
||||
run without a shell. The `script` field is deprecated, and you should include the shell in
|
||||
the `args` to run under a shell, eg. `"args": ["sh", "-c", "..."]`.
|
||||
|
||||
## Initial Health Check Status
|
||||
|
||||
By default, when checks are registered against a Consul agent, the state is set
|
||||
|
|
|
@ -32,7 +32,7 @@ A service definition is a script that looks like:
|
|||
"enable_tag_override": false,
|
||||
"checks": [
|
||||
{
|
||||
"script": "/usr/local/bin/check_redis.py",
|
||||
"args": ["/usr/local/bin/check_redis.py"],
|
||||
"interval": "10s"
|
||||
}
|
||||
]
|
||||
|
@ -80,7 +80,7 @@ node has any failing system-level check, the DNS interface will omit that
|
|||
node from any service query.
|
||||
|
||||
The check must be of the script, HTTP, TCP or TTL type. If it is a script type,
|
||||
`script` and `interval` must be provided. If it is a HTTP type, `http` and
|
||||
`args` and `interval` must be provided. If it is a HTTP type, `http` and
|
||||
`interval` must be provided. If it is a TCP type, `tcp` and `interval` must be
|
||||
provided. If it is a TTL type, then only `ttl` must be provided. The check name
|
||||
is automatically generated as `service:<service-id>`. If there are multiple
|
||||
|
@ -142,7 +142,7 @@ Multiple services definitions can be provided at once using the plural
|
|||
"port": 6000,
|
||||
"checks": [
|
||||
{
|
||||
"script": "/bin/check_redis -p 6000",
|
||||
"args": ["/bin/check_redis", "-p", "6000"],
|
||||
"interval": "5s",
|
||||
"ttl": "20s"
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ Multiple services definitions can be provided at once using the plural
|
|||
"port": 7000,
|
||||
"checks": [
|
||||
{
|
||||
"script": "/bin/check_redis -p 7000",
|
||||
"args": ["/bin/check_redis", "-p", "7000"],
|
||||
"interval": "30s",
|
||||
"ttl": "60s"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue