-
Notifications
You must be signed in to change notification settings - Fork 324
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
Disable DNS redirection when tproxy is disabled #2176
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
control-plane: fix issue with multiport pods crashlooping due to dataplane port conflicts by ensuring dns redirection is disabled for non-tproxy pods | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,7 +267,17 @@ func (w *MeshWebhook) containerInit(namespace corev1.Namespace, pod corev1.Pod, | |
// consulDNSEnabled returns true if Consul DNS should be enabled for this pod. | ||
// It returns an error when the annotation value cannot be parsed by strconv.ParseBool or if we are unable | ||
// to read the pod's namespace label when it exists. | ||
func consulDNSEnabled(namespace corev1.Namespace, pod corev1.Pod, globalEnabled bool) (bool, error) { | ||
func consulDNSEnabled(namespace corev1.Namespace, pod corev1.Pod, globalDNSEnabled bool, globalTProxyEnabled bool) (bool, error) { | ||
// DNS is only possible when tproxy is also enabled because it relies | ||
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. Change to also check tproxy. |
||
// on traffic being redirected. | ||
tproxy, err := common.TransparentProxyEnabled(namespace, pod, globalTProxyEnabled) | ||
if err != nil { | ||
return false, err | ||
} | ||
if !tproxy { | ||
return false, nil | ||
} | ||
|
||
// First check to see if the pod annotation exists to override the namespace or global settings. | ||
if raw, ok := pod.Annotations[constants.KeyConsulDNS]; ok { | ||
return strconv.ParseBool(raw) | ||
|
@@ -277,7 +287,7 @@ func consulDNSEnabled(namespace corev1.Namespace, pod corev1.Pod, globalEnabled | |
return strconv.ParseBool(raw) | ||
} | ||
// Else fall back to the global default. | ||
return globalEnabled, nil | ||
return globalDNSEnabled, nil | ||
} | ||
|
||
// splitCommaSeparatedItemsFromAnnotation takes an annotation and a pod | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,13 +396,17 @@ func (w *MeshWebhook) Handle(ctx context.Context, req admission.Request) admissi | |
pod.Annotations[constants.KeyTransparentProxyStatus] = constants.Enabled | ||
} | ||
|
||
// If tproxy with DNS redirection is enabled, we want to configure dns on the pod. | ||
if tproxyEnabled && w.EnableConsulDNS { | ||
// If DNS redirection is enabled, we want to configure dns on the pod. | ||
dnsEnabled, err := consulDNSEnabled(*ns, pod, w.EnableConsulDNS, w.EnableTransparentProxy) | ||
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. @ishustava also made the same change here to check ns/pod. |
||
if err != nil { | ||
w.Log.Error(err, "error determining if dns redirection is enabled", "request name", req.Name) | ||
return admission.Errored(http.StatusInternalServerError, fmt.Errorf("error determining if dns redirection is enabled: %s", err)) | ||
} | ||
if dnsEnabled { | ||
if err = w.configureDNS(&pod, req.Namespace); err != nil { | ||
w.Log.Error(err, "error configuring DNS on the pod", "request name", req.Name) | ||
return admission.Errored(http.StatusInternalServerError, fmt.Errorf("error configuring DNS on the pod: %s", err)) | ||
} | ||
|
||
} | ||
|
||
// Add annotations for metrics. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Bugfix is here. Use
consulDNSEnabled
instead of just checking global DNS setting. @ishustava can you confirm this change is okay. Previously we only looked at the global setting but I see there is also pod and namespace settings so I made the change to look at those too (in addition to checking if tproxy is enabled)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.
Perfect, this is exactly what I was hoping we'd do.