Skip to content

Commit

Permalink
Re-add missing changes from #556 back after they got lost in #651 (#868)
Browse files Browse the repository at this point in the history
The generic handling of the overlay handling unintentionally removed the
source NAT to upstream DNS server setting. This change introduces it
again.
  • Loading branch information
ScheererJ authored Oct 17, 2024
1 parent b0e6d14 commit 78070e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions pkg/admission/mutator/shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ type shoot struct {
}

const (
overlayKey = "overlay"
enabledKey = "enabled"
overlayKey = "overlay"
snatToUpstreamDNSKey = "snatToUpstreamDNS"
enabledKey = "enabled"
)

// Mutate mutates the given shoot object.
Expand Down Expand Up @@ -95,6 +96,10 @@ func (s *shoot) Mutate(_ context.Context, new, old client.Object) error {
}
}

if networkConfig[overlayKey] != nil && !networkConfig[overlayKey].(map[string]interface{})[enabledKey].(bool) {
networkConfig[snatToUpstreamDNSKey] = map[string]interface{}{enabledKey: false}
}

modifiedJSON, err := json.Marshal(networkConfig)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/admission/mutator/shoot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ var _ = Describe("Shoot mutator", func() {
err := shootMutator.Mutate(ctx, shoot, nil)
Expect(err).NotTo(HaveOccurred())
Expect(shoot.Spec.Networking.ProviderConfig).To(Equal(&runtime.RawExtension{
Raw: []byte(`{"overlay":{"enabled":false}}`),
Raw: []byte(`{"overlay":{"enabled":false},"snatToUpstreamDNS":{"enabled":false}}`),
}))
})

Expand All @@ -172,7 +172,7 @@ var _ = Describe("Shoot mutator", func() {
err := shootMutator.Mutate(ctx, shoot, nil)
Expect(err).NotTo(HaveOccurred())
Expect(shoot.Spec.Networking.ProviderConfig).To(Equal(&runtime.RawExtension{
Raw: []byte(`{"foo":{"enabled":true},"overlay":{"enabled":false}}`),
Raw: []byte(`{"foo":{"enabled":true},"overlay":{"enabled":false},"snatToUpstreamDNS":{"enabled":false}}`),
}))
})

Expand Down

0 comments on commit 78070e7

Please sign in to comment.