-
Notifications
You must be signed in to change notification settings - Fork 326
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
Only write service-defaults if protocol set #169
Conversation
// the protocol was empty. This is the same as setting it to tcp. This | ||
// would then override any global proxy-defaults config. Now, we only | ||
// write the config if a protocol is explicitly set. | ||
writeServiceDefaults := h.WriteServiceDefaults && protocol != "" |
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.
Here's the only real change. Previously this was just the value of h.WriteServiceDefaults
// Default protocol is specified by a flag if not explicitly annotated | ||
if _, ok := pod.ObjectMeta.Annotations[annotationProtocol]; !ok { | ||
if _, ok := pod.ObjectMeta.Annotations[annotationProtocol]; !ok && h.DefaultProtocol != "" { |
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.
Previously we would write an annotation even if the protocol was empty (i.e. we'd set it to the empty string).
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.
I have this impression that there was a reason we needed to define a protocol on everything, but can't remember the details. If Consul is fine in these situations, then this looks great.
connect-inject/container_init.go
Outdated
{{- if .CentralConfig }} | ||
# Create the central config's service registration | ||
{{- if .WriteServiceDefaults }} | ||
# Create the service-defaults config for the service | ||
cat <<EOF >/consul/connect-inject/central-config.hcl |
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.
Since everything is being renamed to "service-defaults", does it make sense to rename the file be written as well? (This would need to be changed several places, as well as in the tests.)
cat <<EOF >/consul/connect-inject/central-config.hcl | |
cat <<EOF >/consul/connect-inject/service-defaults.hcl |
Previously, we would write a service-defaults config regardless of the value of the -default-protocol flag or the Pod's protocol annotation. If neither of these were set, we would write a config with protocol set to the empty string. This is the same as setting it to tcp. So for every service, we were by default setting its protocol to tcp. If a user explicitly created a global proxy-defaults config and set the protocol to, say, http. Then our service-defaults config would override that protocol. This behaviour was unexpected because users had never explicitly told us to write a service-defaults config and it wasn't helping them. This change will cause us to only write a service-defaults config if the protocol is explicitly set–either via the -default-protocol flag or via the Pod annotation. I've also renamed the CentralConfig field to WriteServiceDefaults because there are many types of central config now so it's best to be explicit. Fixes #168
9f22760
to
afb5808
Compare
Previously, we would write a service-defaults config regardless of the
value of the -default-protocol flag or the Pod's protocol annotation. If
neither of these were set, we would write a config with protocol set to
the empty string. This is the same as setting it to tcp. So for every
service, we were by default setting its protocol to tcp.
If a user explicitly created a global proxy-defaults config and set the
protocol to, say, http. Then our service-defaults config would override
that protocol. This behaviour was unexpected because users had never
explicitly told us to write a service-defaults config and it wasn't
helping them.
This change will cause us to only write a service-defaults config if the
protocol is explicitly set–either via the -default-protocol flag or via
the Pod annotation.
I've also renamed the CentralConfig field to WriteServiceDefaults
because there are many types of central config now so it's best to be
explicit.
Fixes #168