-
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
Custom Connect Sidecar Checks #10524
Changes from 4 commits
2a4adab
5d5e7ae
d195c34
0ed745b
5fdb909
1d1ebf0
96248da
dcd2533
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.AgentServiceCheck | ||
if len(css.Checks) == 0 { | ||
checks = api.AgentServiceChecks{ | ||
{ | ||
Name: "Connect Sidecar Listening", | ||
TCP: net.JoinHostPort(cMapping.HostIP, strconv.Itoa(cMapping.Value)), | ||
|
@@ -120,7 +117,25 @@ func connectSidecarRegistration(serviceId string, css *structs.ConsulSidecarServ | |
Name: "Connect Sidecar Aliasing " + serviceId, | ||
AliasService: serviceId, | ||
}, | ||
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. Unclear what the value of this Aliasing service id - do we need to insert it even when checks are overriden? 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. The alias basically means "if you request health for service X, send the request to me instead" - which is useful for connect, where requests must go through the sidecar proxy. I think yes, this should always be there |
||
}, | ||
} | ||
} else { | ||
checks = make([]*api.AgentServiceCheck, len(css.Checks)) | ||
for i, c := range css.Checks { | ||
check, err := createCheckReg(serviceId, "", c, cMapping.HostIP, cMapping.Value, "") | ||
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. Not sure if I'm doing this correctly, and what host/port should be used. When I tried, I can successfully set a custom 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. I sort of imagined being able to create checks that somehow made use of The only way that will work is if the Consul agent is able to make a connection to that ip:port, which is going to be |
||
if err != nil { | ||
return nil, fmt.Errorf("failed to register check %v: %w", c.Name, err) | ||
} | ||
|
||
checks[i] = &check.AgentServiceCheck | ||
} | ||
} | ||
|
||
return &api.AgentServiceRegistration{ | ||
Tags: helper.CopySliceString(css.Tags), | ||
Port: cMapping.Value, | ||
Address: cMapping.HostIP, | ||
Proxy: proxy, | ||
Checks: checks, | ||
}, nil | ||
} | ||
|
||
|
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.
With this change, there is no way to actually disable sidecar checks. The job author must specify a
check
or we insert the default TCP ones. This seems a bit reasonable.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.
This is also the only option if registering with Consul directly; this approach is just following suite