API Accepts Invalid Type for "ConnectTimeout" in service-resolver Configuration
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
#### Overview of the Issue
When applying a service resolver configuration, if ConnectTimeout is provided as an `int` instead of a `string` with a time suffix, the api will accept and apply the configuration, however this results in a failure to then speak to that service as the resolver config is invalid, and you are met with connection resets attempting to speak to it via connect.
#### Reproduction Steps
Steps to reproduce this issue, eg:
1. Create or have a cluster ready
1. Register a service
1. Create a service-resolver configuration for that service, using an `int` for the time value in `ConnectTimeout`
2. attempt to communicate with that service via connect.
### Consul info for both Client and Server
Client info
```
agent:
check_monitors = 0
check_ttls = 0
checks = 3
services = 2
build:
prerelease =
revision = bd257019
version = 1.14.3
version_metadata =
consul:
acl = enabled
known_servers = 3
server = false
runtime:
arch = amd64
cpu_count = 2
goroutines = 93
max_procs = 2
os = linux
version = go1.19.4
serf_lan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 111
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 1158115
members = 121
query_queue = 0
query_time = 3323
```
Server info
```
agent:
check_monitors = 0
check_ttls = 0
checks = 0
services = 0
build:
prerelease =
revision = 12dd8aa9
version = 1.12.8
version_metadata =
consul:
acl = enabled
bootstrap = false
known_datacenters = 3
leader = true
leader_addr = REDACTED:8300
server = true
raft:
applied_index = 54345301
commit_index = 54345301
fsm_pending = 0
last_contact = 0
last_log_index = 54345301
last_log_term = 641
last_snapshot_index = 54330691
last_snapshot_term = 641
latest_configuration = [{REDACTED}]
latest_configuration_index = 0
num_peers = 2
protocol_version = 3
protocol_version_max = 3
protocol_version_min = 0
snapshot_version_max = 1
snapshot_version_min = 0
state = Leader
term = 641
runtime:
arch = amd64
cpu_count = 2
goroutines = 3917
max_procs = 2
os = linux
version = go1.18.9
serf_lan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 111
failed = 0
health_score = 0
intent_queue = 0
left = 8
member_time = 1158109
members = 129
query_queue = 0
query_time = 3323
serf_wan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 1
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 7299
members = 9
query_queue = 0
query_time = 2
```
Bad Config Example
```json
{
"Kind":"service-resolver",
"Name":"REDACTED",
"ConnectTimeout":10, <-----This should throw an error on config write
"Failover":{
"*":{
"Datacenters":["us-east-1","us-west-2"]
}
}
}
```
### Operating system and Environment details
Consul Container for the client, server is running amazon linux
Contributor guide
Assessment
This issue has not been assessed yet.