From 8afd31c625f7278237ed4622b4e3f8d449a55894 Mon Sep 17 00:00:00 2001 From: Alexandru Scvortov Date: Fri, 30 Jul 2021 16:16:23 +0100 Subject: [PATCH] kubernetes: fix flaky test and run tests as group --- .../cluster/kubernetes/addon-manager.nix | 3 +++ .../services/cluster/kubernetes/apiserver.nix | 4 ++++ .../cluster/kubernetes/controller-manager.nix | 3 +++ .../services/cluster/kubernetes/kubelet.nix | 3 +++ .../services/cluster/kubernetes/proxy.nix | 3 +++ .../services/cluster/kubernetes/scheduler.nix | 3 +++ nixos/tests/all-tests.nix | 5 +---- nixos/tests/kubernetes/default.nix | 18 +++++++++++++----- .../networking/cluster/kubernetes/default.nix | 7 +------ 9 files changed, 34 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/cluster/kubernetes/addon-manager.nix b/nixos/modules/services/cluster/kubernetes/addon-manager.nix index 1378b5ccfb7a..821f1aa54604 100644 --- a/nixos/modules/services/cluster/kubernetes/addon-manager.nix +++ b/nixos/modules/services/cluster/kubernetes/addon-manager.nix @@ -84,6 +84,9 @@ in Restart = "on-failure"; RestartSec = 10; }; + unitConfig = { + StartLimitIntervalSec = 0; + }; }; services.kubernetes.addonManager.bootstrapAddons = mkIf isRBACEnabled diff --git a/nixos/modules/services/cluster/kubernetes/apiserver.nix b/nixos/modules/services/cluster/kubernetes/apiserver.nix index f842f784b349..2c89310beb5a 100644 --- a/nixos/modules/services/cluster/kubernetes/apiserver.nix +++ b/nixos/modules/services/cluster/kubernetes/apiserver.nix @@ -398,6 +398,10 @@ in Restart = "on-failure"; RestartSec = 5; }; + + unitConfig = { + StartLimitIntervalSec = 0; + }; }; services.etcd = { diff --git a/nixos/modules/services/cluster/kubernetes/controller-manager.nix b/nixos/modules/services/cluster/kubernetes/controller-manager.nix index 0c81fa9ae492..7128b5f70b1a 100644 --- a/nixos/modules/services/cluster/kubernetes/controller-manager.nix +++ b/nixos/modules/services/cluster/kubernetes/controller-manager.nix @@ -146,6 +146,9 @@ in User = "kubernetes"; Group = "kubernetes"; }; + unitConfig = { + StartLimitIntervalSec = 0; + }; path = top.path; }; diff --git a/nixos/modules/services/cluster/kubernetes/kubelet.nix b/nixos/modules/services/cluster/kubernetes/kubelet.nix index fcfcc8435477..08f5cdfdf334 100644 --- a/nixos/modules/services/cluster/kubernetes/kubelet.nix +++ b/nixos/modules/services/cluster/kubernetes/kubelet.nix @@ -337,6 +337,9 @@ in ''; WorkingDirectory = top.dataDir; }; + unitConfig = { + StartLimitIntervalSec = 0; + }; }; # Allways include cni plugins diff --git a/nixos/modules/services/cluster/kubernetes/proxy.nix b/nixos/modules/services/cluster/kubernetes/proxy.nix index 42729f54643b..a92043d52597 100644 --- a/nixos/modules/services/cluster/kubernetes/proxy.nix +++ b/nixos/modules/services/cluster/kubernetes/proxy.nix @@ -77,6 +77,9 @@ in Restart = "on-failure"; RestartSec = 5; }; + unitConfig = { + StartLimitIntervalSec = 0; + }; }; services.kubernetes.proxy.hostname = with config.networking; mkDefault hostName; diff --git a/nixos/modules/services/cluster/kubernetes/scheduler.nix b/nixos/modules/services/cluster/kubernetes/scheduler.nix index 454c689759df..1b0c22a11426 100644 --- a/nixos/modules/services/cluster/kubernetes/scheduler.nix +++ b/nixos/modules/services/cluster/kubernetes/scheduler.nix @@ -79,6 +79,9 @@ in Restart = "on-failure"; RestartSec = 5; }; + unitConfig = { + StartLimitIntervalSec = 0; + }; }; services.kubernetes.pki.certs = { diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index b1c3ccf782d1..40e87bdd6ce3 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -220,10 +220,7 @@ in knot = handleTest ./knot.nix {}; krb5 = discoverTests (import ./krb5 {}); ksm = handleTest ./ksm.nix {}; - kubernetes.dns = handleTestOn ["x86_64-linux"] ./kubernetes/dns.nix {}; - # kubernetes.e2e should eventually replace kubernetes.rbac when it works - #kubernetes.e2e = handleTestOn ["x86_64-linux"] ./kubernetes/e2e.nix {}; - kubernetes.rbac = handleTestOn ["x86_64-linux"] ./kubernetes/rbac.nix {}; + kubernetes = handleTestOn ["x86_64-linux"] ./kubernetes {}; latestKernel.hardened = handleTest ./hardened.nix { latestKernel = true; }; latestKernel.login = handleTest ./login.nix { latestKernel = true; }; leaps = handleTest ./leaps.nix {}; diff --git a/nixos/tests/kubernetes/default.nix b/nixos/tests/kubernetes/default.nix index a801759bf582..90b73c68a76d 100644 --- a/nixos/tests/kubernetes/default.nix +++ b/nixos/tests/kubernetes/default.nix @@ -1,7 +1,15 @@ -{ system ? builtins.currentSystem }: +{ system ? builtins.currentSystem +, pkgs ? import { inherit system; } +}: +let + dns = import ./dns.nix { inherit system pkgs; }; + rbac = import ./rbac.nix { inherit system pkgs; }; + # TODO kubernetes.e2e should eventually replace kubernetes.rbac when it works + # e2e = import ./e2e.nix { inherit system pkgs; }; +in { - dns = import ./dns.nix { inherit system; }; - # e2e = import ./e2e.nix { inherit system; }; # TODO: make it pass - # the following test(s) can be removed when e2e is working: - rbac = import ./rbac.nix { inherit system; }; + dns-single-node = dns.singlenode.test; + dns-multi-node = dns.multinode.test; + rbac-single-node = rbac.singlenode.test; + rbac-multi-node = rbac.multinode.test; } diff --git a/pkgs/applications/networking/cluster/kubernetes/default.nix b/pkgs/applications/networking/cluster/kubernetes/default.nix index b59a5549b72d..7c1d366a4b62 100644 --- a/pkgs/applications/networking/cluster/kubernetes/default.nix +++ b/pkgs/applications/networking/cluster/kubernetes/default.nix @@ -97,10 +97,5 @@ stdenv.mkDerivation rec { platforms = platforms.unix; }; - passthru.tests = with nixosTests.kubernetes; { - dns-single-node = dns.singlenode; - dns-multi-node = dns.multinode; - rbac-single-node = rbac.singlenode; - rbac-multi-node = rbac.multinode; - }; + passthru.tests = nixosTests.kubernetes; }