Skip to content
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

Validate that Connect Native services define a port #24329

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

oulman
Copy link
Contributor

@oulman oulman commented Oct 29, 2024

This PR adds a validation check for PortLabels on Connect Native enabled services. This is a requirement in Consul and if missing from the job spec will continually error.

"service": "nomad",
"message": "failed to update services in Consul",
"attributes": {
    "hostname": "<snip>",
    "@level": "warn",
    "@timestamp": "2024-10-29T15:16:34.148322Z",
    "service": "nomad",
    "@module": "consul.sync",
    "error": "Unexpected response code: 400 (Validation failed: 1 error occurred:\n\t* Port or SocketPath must be set for a Connect native service.)",
    "status": "info",
}

I can't get all of the tests to pass locally but TestService_Validate looked good.

=== RUN   TestService_Validate
=== PAUSE TestService_Validate
=== CONT  TestService_Validate
=== RUN   TestService_Validate/base_service
=== RUN   TestService_Validate/Native_Connect_without_task_name
=== RUN   TestService_Validate/Native_Connect_with_task_name
=== RUN   TestService_Validate/Native_Connect_without_port
=== RUN   TestService_Validate/Native_Connect_with_port
=== RUN   TestService_Validate/Native_Connect_with_Sidecar
=== RUN   TestService_Validate/provider_nomad_with_checks
=== RUN   TestService_Validate/provider_nomad_with_invalid_check_type
=== RUN   TestService_Validate/provider_nomad_with_tls_skip_verify
=== RUN   TestService_Validate/provider_nomad_with_connect
=== RUN   TestService_Validate/provider_nomad_valid
=== RUN   TestService_Validate/provider_consul_with_notes_too_long
--- PASS: TestService_Validate (0.00s)
    --- PASS: TestService_Validate/base_service (0.00s)
    --- PASS: TestService_Validate/Native_Connect_without_task_name (0.00s)
    --- PASS: TestService_Validate/Native_Connect_with_task_name (0.00s)
    --- PASS: TestService_Validate/Native_Connect_without_port (0.00s)
    --- PASS: TestService_Validate/Native_Connect_with_port (0.00s)
    --- PASS: TestService_Validate/Native_Connect_with_Sidecar (0.00s)
    --- PASS: TestService_Validate/provider_nomad_with_checks (0.00s)
    --- PASS: TestService_Validate/provider_nomad_with_invalid_check_type (0.00s)
    --- PASS: TestService_Validate/provider_nomad_with_tls_skip_verify (0.00s)
    --- PASS: TestService_Validate/provider_nomad_with_connect (0.00s)
    --- PASS: TestService_Validate/provider_nomad_valid (0.00s)
    --- PASS: TestService_Validate/provider_consul_with_notes_too_long (0.00s)
PASS

@schmichael schmichael added the backport/ent/1.9.x+ent Changes are backported to 1.9.x+ent label Oct 29, 2024
Copy link
Member

@gulducat gulducat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

For posterity, since the error said "Port or SocketPath must be set", I double-checked SocketPath. It doesn't look like there's any such option in Nomad for that in this context, so it's Port or bust, and this very nicely busts much earlier, at job submit time. 👍

@schmichael schmichael merged commit 202baa1 into hashicorp:main Oct 29, 2024
23 of 24 checks passed
@gulducat gulducat added backport/1.9.x backport to 1.9.x release line and removed backport/ent/1.9.x+ent Changes are backported to 1.9.x+ent labels Oct 29, 2024
@gulducat gulducat added backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent type/bug labels Oct 29, 2024
@oulman oulman deleted the validate-connect-native-port branch October 29, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/1.9.x backport to 1.9.x release line theme/consul/connect Consul Connect integration type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants