-
-
Notifications
You must be signed in to change notification settings - Fork 524
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
Remove the dormant container during intercept with --replace. #3761
Conversation
When the traffic-manager shuts down, it must uninstall agents unconditionally, without concerns about the "inject" annotation. Signed-off-by: Thomas Hallgren <thomas@tada.se>
Signed-off-by: Thomas Hallgren <thomas@tada.se>
There's no need to have a dormant container because the traffic-agent can serve as the replacement itself. That way, there's no need to redirect ports either, which means that there's no need to rename ports or use an init-container. An annotation is added to the pod to cater for when multiple injections happen due to replace-policy, so that injections that follow the one when an app-container is removed can reproduce the traffic-agent container, taking its ports, mounts, and environment into account. Closes #3758 Signed-off-by: Thomas Hallgren <thomas@tada.se>
The `tunnel.ConnID` still used the `net.IP`. This commit changes the constructor to use `netip.AddrPort` for host and destination instead of separate combos of `net.IP` and `uint16`. Signed-off-by: Thomas Hallgren <thomas@tada.se>
Signed-off-by: Thomas Hallgren <thomas@tada.se>
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.
Just one typo.
I like the swap of net.IP
with netip.AddrPort
// skips contain defaults assigned by Kubernetes that are not zero values | ||
if dlog.MaxLogLevel(ctx) >= dlog.LogLevelDebug { | ||
diff := cmp.Diff(a, b, | ||
cmp.Comparer(compareProbes), |
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.
a minor one too, but we already have options below, so could dedupe it a bit
func containerEqual(ctx context.Context, a, b *core.Container) bool {
// skips contain defaults assigned by Kubernetes that are not zero values
options := cmp.Options{
cmp.Comparer(compareProbes),
cmp.Comparer(compareVolumeMounts),
cmpopts.IgnoreFields(core.Container{}, "ImagePullPolicy", "Resources", "TerminationMessagePath", "TerminationMessagePolicy"),
}
if dlog.MaxLogLevel(ctx) >= dlog.LogLevelDebug {
diff := cmp.Diff(a, b, options...)
if diff != "" {
dlog.Debug(ctx, diff)
}
return diff == ""
}
return cmp.Equal(a, b, options...)
}
pkg/agentconfig/container.go
Outdated
|
||
func eachConfiguredContainer(configureContainers []*core.Container, config *Sidecar, f func(*core.Container, *Container)) { | ||
for i, cn := range configureContainers { | ||
f(cn, config.Containers[i]) |
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.
is it possible that a container will be nil at runtime?
Technically from the perspective of ConfiguredContainers
function that might be the case if we're unable to find the configured container.
If so, we may want to filter out nil values here as the callbacks we pass to eachConfiguredContainer
will panic due to them expecting a non-nil value.
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.
Good point, A nil entry in the configContainers
should never be possible, but looking at the ConfiguredContainers
function, I realize that if the pod.Spec.Containers
for some reason is out of sync with the config.Containers
, and no longer contain all the containers that were present at the time when the config.Containers
was generated, then that could actually happen.
Co-authored-by: Jakub Rożek <jrozek@datawire.io> Signed-off-by: Thomas Hallgren <thomas@tada.se>
- Dedup compare options. - Add nil-check in `eachConfiguredContainer` Signed-off-by: Thomas Hallgren <thomas@tada.se>
There's no need to have a dormant container because the traffic-agent
can serve as the replacement itself. That way, there's no need to
redirect ports either, which means that there's no need to rename ports
or use an init-container.
An annotation is added to the pod to cater for when multiple injections
happen due to replace-policy, so that injections that follow the one
when an app-container is removed can reproduce the traffic-agent
container, taking its ports, mounts, and environment into account.