fix: missing UDP field in checkType (#14885)
* fix: missing UDP field in checkType * Add changelog * Update doc
This commit is contained in:
parent
fbee1272e7
commit
53ff317b01
|
@ -0,0 +1,4 @@
|
|||
```release-note:bug
|
||||
checks: Fixed a bug that prevented registration of UDP health checks from agent configuration files, such as service definition files with embedded health check definitions.
|
||||
```
|
||||
|
|
@ -1562,6 +1562,7 @@ func (b *builder) checkVal(v *CheckDefinition) *structs.CheckDefinition {
|
|||
Body: stringVal(v.Body),
|
||||
DisableRedirects: boolVal(v.DisableRedirects),
|
||||
TCP: stringVal(v.TCP),
|
||||
UDP: stringVal(v.UDP),
|
||||
Interval: b.durationVal(fmt.Sprintf("check[%s].interval", id), v.Interval),
|
||||
DockerContainerID: stringVal(v.DockerContainerID),
|
||||
Shell: stringVal(v.Shell),
|
||||
|
|
|
@ -326,6 +326,24 @@ func TestBuilder_ServiceVal_MultiError(t *testing.T) {
|
|||
require.Contains(t, b.err.Error(), "cannot have both socket path")
|
||||
}
|
||||
|
||||
func TestBuilder_ServiceVal_with_Check(t *testing.T) {
|
||||
b := builder{}
|
||||
svc := b.serviceVal(&ServiceDefinition{
|
||||
Name: strPtr("unbound"),
|
||||
ID: strPtr("unbound"),
|
||||
Port: intPtr(12345),
|
||||
Checks: []CheckDefinition{
|
||||
{
|
||||
Interval: strPtr("5s"),
|
||||
UDP: strPtr("localhost:53"),
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, b.err)
|
||||
require.Equal(t, 1, len(svc.Checks))
|
||||
require.Equal(t, "localhost:53", svc.Checks[0].UDP)
|
||||
}
|
||||
|
||||
func intPtr(v int) *int {
|
||||
return &v
|
||||
}
|
||||
|
|
|
@ -24,10 +24,11 @@ be reviewed and tested.
|
|||
on `config.Config` in [agent/config/config.go].
|
||||
5. Config [Service.Checks](https://www.consul.io/docs/discovery/services) - the
|
||||
`Checks` and `Check` fields on `ServiceDefinition` in [agent/config/config.go].
|
||||
6. CLI [consul services register](https://www.consul.io/commands/services/register) - the
|
||||
6. The returned fields of `ServiceDefinition` in [agent/config/builder.go].
|
||||
7. CLI [consul services register](https://www.consul.io/commands/services/register) - the
|
||||
`Checks` and `Check` fields on `api.AgentServiceRegistration`. The entrypoint is
|
||||
`ServicesFromFiles` in [command/services/config.go].
|
||||
7. API [/v1/txn](https://www.consul.io/api-docs/txn) - the `Transaction` API allows for registering a check.
|
||||
8. API [/v1/txn](https://www.consul.io/api-docs/txn) - the `Transaction` API allows for registering a check.
|
||||
|
||||
|
||||
[agent/catalog_endpoint.go]: https://github.com/hashicorp/consul/blob/main/agent/catalog_endpoint.go
|
||||
|
|
Loading…
Reference in New Issue