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

Change injector overriding logic to be more generic #12405

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion controller/api/destination/watcher/workload_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,9 @@ func GetAnnotatedOpaquePorts(pod *corev1.Pod, defaultPorts map[uint32]struct{})
return defaultPorts
}
opaquePorts := make(map[uint32]struct{})
namedPorts := util.GetNamedPorts(pod.Spec.Containers)
if annotation != "" {
for _, pr := range util.ParseContainerOpaquePorts(annotation, pod.Spec.Containers) {
for _, pr := range util.ParseContainerOpaquePorts(annotation, namedPorts) {
for _, port := range pr.Ports() {
opaquePorts[uint32(port)] = struct{}{}
}
Expand Down
2 changes: 1 addition & 1 deletion controller/proxy-injector/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func Inject(linkerdNamespace string) webhook.Handler {

// If namespace has annotations that do not exist on pod then copy them
// over to pod's template.
resourceConfig.AppendNamespaceAnnotations()
inject.AppendNamespaceAnnotations(resourceConfig.GetOverrideAnnotations(), resourceConfig.GetNsAnnotations(), resourceConfig.GetWorkloadAnnotations())

// If the pod did not inherit the opaque ports annotation from the
// namespace, then add the default value from the config values. This
Expand Down
2 changes: 1 addition & 1 deletion controller/proxy-injector/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestGetPodPatch(t *testing.T) {

// The namespace has two config annotations: one valid and one invalid
// the pod patch should only contain the valid annotation.
conf.AppendNamespaceAnnotations()
inject.AppendNamespaceAnnotations(conf.GetOverrideAnnotations(), conf.GetNsAnnotations(), conf.GetWorkloadAnnotations())
patchJSON, err := conf.GetPodPatch(true)
if err != nil {
t.Fatalf("Unexpected PatchForAdmissionRequest error: %s", err)
Expand Down