-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support disabling TCP checks for connect sidecar services #10531
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,12 +105,9 @@ func connectSidecarRegistration(serviceId string, css *structs.ConsulSidecarServ | |
return nil, err | ||
} | ||
|
||
return &api.AgentServiceRegistration{ | ||
Tags: helper.CopySliceString(css.Tags), | ||
Port: cMapping.Value, | ||
Address: cMapping.HostIP, | ||
Proxy: proxy, | ||
Checks: api.AgentServiceChecks{ | ||
var checks api.AgentServiceChecks | ||
if !css.DisableDefaultTCPCheck { | ||
checks = api.AgentServiceChecks{ | ||
{ | ||
Name: "Connect Sidecar Listening", | ||
TCP: net.JoinHostPort(cMapping.HostIP, strconv.Itoa(cMapping.Value)), | ||
|
@@ -120,7 +117,23 @@ func connectSidecarRegistration(serviceId string, css *structs.ConsulSidecarServ | |
Name: "Connect Sidecar Aliasing " + serviceId, | ||
AliasService: serviceId, | ||
}, | ||
}, | ||
} | ||
} else { | ||
// insert a NOOP check to avoid Consul inserting the default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is a bit misleading - the aliasing here is functional to consul service discovery - e.g. if the tcp check exists and is failing, queries for the aliased service will not return results including this sidecar (i.e. when using connect upstreams). |
||
checks = api.AgentServiceChecks{ | ||
{ | ||
Name: "Connect Sidecar Aliasing " + serviceId, | ||
AliasService: serviceId, | ||
}, | ||
} | ||
} | ||
|
||
return &api.AgentServiceRegistration{ | ||
Tags: helper.CopySliceString(css.Tags), | ||
Port: cMapping.Value, | ||
Address: cMapping.HostIP, | ||
Proxy: proxy, | ||
Checks: checks, | ||
}, nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -550,6 +550,7 @@ func parseSidecarService(o *ast.ObjectItem) (*api.ConsulSidecarService, error) { | |
"port", | ||
"proxy", | ||
"tags", | ||
"disable_default_tcp_check", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. backporting to HCL1 isn't required, but also doesn't hurt anything |
||
} | ||
|
||
if err := checkHCLKeys(o.Val, valid); err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
job "sidecar_disablecheck" { | ||
type = "service" | ||
|
||
group "group" { | ||
service { | ||
name = "example" | ||
|
||
connect { | ||
sidecar_service { | ||
disable_default_tcp_check = true | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: since we're building a slice that will always include the alias, i'd golf this down to