Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

fix: kube-dns and coredns addons UT, back-compat #2433

Merged
merged 2 commits into from
Dec 11, 2019

Conversation

jackfrancis
Copy link
Member

Reason for Change:

Follow up from #2393 and #2416. UT was not fully engaged, and thus the back-compat was not implemented exactly right. This PR fixes UT, and implements back-compat according to the following recipe:

  • If you are in an upgrade context and your cluster version is >= 1.12 (when coredns support first landed in aks-engine):
    • Ensure that coredns addon is set to enabled if there is no coredns addon entry in the addons array
      • The absence of coredns in the addons array indicates a "legacy" cluster config, i.e., a cluster config built using aks-engine prior to coredns being added as a user-configurable addon
    • Ensure that kube-dns addon is set to disabled
      • This is statically done, essentially to mimic the legacy implementation, which statically disables kube-dns and statically enables coredns based on an upgrade from <= 1.12 to >= 1.12

This back-compat implementation includes some permissiveness for intrepid users who manually edit the addons array in their pre-existing api model prior to running aks-engine upgrade. Specifically, we only do the above default enforcement if the coredns addon is not present in the api model (which is the api model signature a legacy cluster will exhibit). What this means in practice is that users who want to continue to use kube-dns on a >= 1.12 cluster may manually modify the api model accordingly. UT have been added to prove this out.

Also, ensure we account for scenarios where coredns and kube-dns could be (incorrectly) enabled together.

Issue Fixed:

Requirements:

Notes:

@acs-bot acs-bot added the size/M label Dec 11, 2019
@@ -3255,6 +3255,10 @@ func TestSetAddonsConfig(t *testing.T) {
Name: common.CloudNodeManagerAddonName,
Enabled: to.BoolPtr(false),
},
{
Name: common.KubeDNSAddonName,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an error that wasn't caught because kube-dns wasn't actually being validated in this UT.

@@ -4252,7 +4256,7 @@ func TestSetAddonsConfig(t *testing.T) {
Containers: []KubernetesContainerSpec{
{
Name: common.CoreDNSAddonName,
Image: specConfig.KubernetesImageBase + K8sComponentsByVersionMap["1.15.4"][common.CoreDNSAddonName],
Image: specConfig.KubernetesImageBase + K8sComponentsByVersionMap["1.16.0"][common.CoreDNSAddonName],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fixes are actually functionally no-ops, as we ship the same coredns for many versions, but it's still something we want to address.

NetworkPlugin: NetworkPluginAzure,
Addons: []KubernetesAddon{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proper back-compat/upgrade flow would not have the kube-dns or coredns addons present

@@ -7249,25 +7246,7 @@ func TestSetAddonsConfig(t *testing.T) {
expectedAddons: []KubernetesAddon{
{
Name: common.HeapsterAddonName,
Enabled: to.BoolPtr(true),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is due to increasing the version to 1.13 (which makes sense because we no longer support 1.12)

},
},
},
},
},
{
name: "kube-dns enabled",
name: "upgrade w/ manual kube-dns enabled",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the "user manually modifies his/her api model to explicitly continue using kube-dns, which is now an option since making kube-dns a user-configurable addon"

@@ -7608,15 +7589,600 @@ func TestSetAddonsConfig(t *testing.T) {
},
Containers: []KubernetesContainerSpec{
{
Name: common.KubeDNSAddonName,
Name: "kubedns",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, more errors slipping through because we weren't actually validating kube-dns in this UT.

@@ -7649,6 +8215,8 @@ func TestSetAddonsConfig(t *testing.T) {
common.AzureFileCSIDriverAddonName,
common.AzureDiskCSIDriverAddonName,
common.CloudNodeManagerAddonName,
common.CoreDNSAddonName,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is us actually testing kube-dns and coredns addons

@codecov
Copy link

codecov bot commented Dec 11, 2019

Codecov Report

Merging #2433 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2433      +/-   ##
==========================================
+ Coverage   72.29%   72.29%   +<.01%     
==========================================
  Files         130      130              
  Lines       23603    23606       +3     
==========================================
+ Hits        17063    17066       +3     
  Misses       5516     5516              
  Partials     1024     1024

Copy link
Member

@mboersma mboersma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@acs-bot
Copy link

acs-bot commented Dec 11, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jackfrancis, mboersma

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [jackfrancis,mboersma]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jackfrancis jackfrancis merged commit 59adb42 into Azure:master Dec 11, 2019
@jackfrancis jackfrancis added this to the v0.45.0 milestone Dec 16, 2019
@jackfrancis
Copy link
Member Author

Related to #2251

@jackfrancis jackfrancis deleted the addons-kube-dns-coredns-ut branch December 18, 2019 23:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants