From ee23b947aa54510cca153eb8425926b5a4a2048f Mon Sep 17 00:00:00 2001 From: Hans Feldt <2808287+hafe@users.noreply.github.com> Date: Mon, 23 Nov 2020 08:47:35 +0100 Subject: [PATCH] fix flake8 errors in Kubespray CI - tox-inventory-builder (#6910) * fix flake8 errors in Kubespray CI - tox-inventory-builder * Invalidate CRI-O kubic repo's cache Signed-off-by: Victor Morales * add support to configure pkg install retries and use in CI job tf-ovh_ubuntu18-calico (due to it failing often) * Switch Calico, Cilium and MetalLB image repos to Quay.io Co-authored-by: Victor Morales Co-authored-by: Barry Melbourne <9964974+bmelbourne@users.noreply.github.com> --- .../inventory_builder/tests/test_inventory.py | 22 +++++++++---------- .../cri-o/tasks/crio_repo.yml | 1 + roles/download/defaults/main.yml | 18 +++++++-------- roles/kubernetes/preinstall/defaults/main.yml | 3 +++ .../preinstall/tasks/0070-system-packages.yml | 2 +- tests/files/tf-ovh_ubuntu18-calico.yml | 2 ++ 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/contrib/inventory_builder/tests/test_inventory.py b/contrib/inventory_builder/tests/test_inventory.py index aa03e7c64..d76bb5474 100644 --- a/contrib/inventory_builder/tests/test_inventory.py +++ b/contrib/inventory_builder/tests/test_inventory.py @@ -51,7 +51,7 @@ class TestInventory(unittest.TestCase): groups = ['group1', 'group2'] self.inv.ensure_required_groups(groups) for group in groups: - self.assertTrue(group in self.inv.yaml_config['all']['children']) + self.assertIn(group, self.inv.yaml_config['all']['children']) def test_get_host_id(self): hostnames = ['node99', 'no99de01', '01node01', 'node1.domain', @@ -209,8 +209,8 @@ class TestInventory(unittest.TestCase): ('doesnotbelong2', {'whateveropts=ilike'})]) self.inv.yaml_config['all']['hosts'] = existing_hosts self.inv.purge_invalid_hosts(proper_hostnames) - self.assertTrue( - bad_host not in self.inv.yaml_config['all']['hosts'].keys()) + self.assertNotIn( + bad_host, self.inv.yaml_config['all']['hosts'].keys()) def test_add_host_to_group(self): group = 'etcd' @@ -227,8 +227,8 @@ class TestInventory(unittest.TestCase): host = 'node1' self.inv.set_kube_master([host]) - self.assertTrue( - host in self.inv.yaml_config['all']['children'][group]['hosts']) + self.assertIn( + host, self.inv.yaml_config['all']['children'][group]['hosts']) def test_set_all(self): hosts = OrderedDict([ @@ -246,8 +246,8 @@ class TestInventory(unittest.TestCase): self.inv.set_k8s_cluster() for host in expected_hosts: - self.assertTrue( - host in + self.assertIn( + host, self.inv.yaml_config['all']['children'][group]['children']) def test_set_kube_node(self): @@ -255,16 +255,16 @@ class TestInventory(unittest.TestCase): host = 'node1' self.inv.set_kube_node([host]) - self.assertTrue( - host in self.inv.yaml_config['all']['children'][group]['hosts']) + self.assertIn( + host, self.inv.yaml_config['all']['children'][group]['hosts']) def test_set_etcd(self): group = 'etcd' host = 'node1' self.inv.set_etcd([host]) - self.assertTrue( - host in self.inv.yaml_config['all']['children'][group]['hosts']) + self.assertIn( + host, self.inv.yaml_config['all']['children'][group]['hosts']) def test_scale_scenario_one(self): num_nodes = 50 diff --git a/roles/container-engine/cri-o/tasks/crio_repo.yml b/roles/container-engine/cri-o/tasks/crio_repo.yml index 76d60f3d0..4993bedaa 100644 --- a/roles/container-engine/cri-o/tasks/crio_repo.yml +++ b/roles/container-engine/cri-o/tasks/crio_repo.yml @@ -36,6 +36,7 @@ baseurl: http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_$releasever/ gpgcheck: yes gpgkey: http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_$releasever/repodata/repomd.xml.key + keepcache: false when: ansible_distribution in ["CentOS"] - name: Add CRI-O kubic yum repo diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml index 50fad23c2..5c570b95a 100644 --- a/roles/download/defaults/main.yml +++ b/roles/download/defaults/main.yml @@ -420,13 +420,13 @@ etcd_image_repo: "{{ quay_image_repo }}/coreos/etcd" etcd_image_tag: "{{ etcd_version }}{%- if image_arch != 'amd64' -%}-{{ image_arch }}{%- endif -%}" flannel_image_repo: "{{ quay_image_repo }}/coreos/flannel" flannel_image_tag: "{{ flannel_version }}" -calico_node_image_repo: "{{ docker_image_repo }}/calico/node" +calico_node_image_repo: "{{ quay_image_repo }}/calico/node" calico_node_image_tag: "{{ calico_version }}" -calico_cni_image_repo: "{{ docker_image_repo }}/calico/cni" +calico_cni_image_repo: "{{ quay_image_repo }}/calico/cni" calico_cni_image_tag: "{{ calico_cni_version }}" -calico_policy_image_repo: "{{ docker_image_repo }}/calico/kube-controllers" +calico_policy_image_repo: "{{ quay_image_repo }}/calico/kube-controllers" calico_policy_image_tag: "{{ calico_policy_version }}" -calico_typha_image_repo: "{{ docker_image_repo }}/calico/typha" +calico_typha_image_repo: "{{ quay_image_repo }}/calico/typha" calico_typha_image_tag: "{{ calico_typha_version }}" pod_infra_image_repo: "{{ kube_image_repo }}/pause" pod_infra_image_tag: "{{ pod_infra_version }}" @@ -451,11 +451,11 @@ contiv_etcd_init_image_repo: "{{ docker_image_repo }}/ferest/etcd-initer" contiv_etcd_init_image_tag: latest contiv_ovs_image_repo: "{{ docker_image_repo }}/contiv/ovs" contiv_ovs_image_tag: "latest" -cilium_image_repo: "{{ docker_image_repo }}/cilium/cilium" +cilium_image_repo: "{{ quay_image_repo }}/cilium/cilium" cilium_image_tag: "{{ cilium_version }}" -cilium_init_image_repo: "{{ docker_image_repo }}/cilium/cilium-init" +cilium_init_image_repo: "{{ quay_image_repo }}/cilium/cilium-init" cilium_init_image_tag: "2019-04-05" -cilium_operator_image_repo: "{{ docker_image_repo }}/cilium/operator" +cilium_operator_image_repo: "{{ quay_image_repo }}/cilium/operator" cilium_operator_image_tag: "{{ cilium_version }}" kube_ovn_container_image_repo: "{{ docker_image_repo }}/kubeovn/kube-ovn" kube_ovn_container_image_tag: "{{ kube_ovn_version }}" @@ -581,8 +581,8 @@ image_pull_command_on_localhost: "{{ docker_bin_dir }}/docker pull" image_save_command_on_localhost: "{{ docker_bin_dir }}/docker save {{ image_reponame }} | gzip -{{ download_compress }} > {{ image_path_cached }}" image_info_command_on_localhost: "{{ docker_bin_dir }}/docker images" -metallb_speaker_image_repo: "{{ docker_image_repo }}/metallb/speaker" -metallb_controller_image_repo: "{{ docker_image_repo }}/metallb/controller" +metallb_speaker_image_repo: "{{ quay_image_repo }}/metallb/speaker" +metallb_controller_image_repo: "{{ quay_image_repo }}/metallb/controller" downloads: netcheck_server: diff --git a/roles/kubernetes/preinstall/defaults/main.yml b/roles/kubernetes/preinstall/defaults/main.yml index f0b54c444..5bf702dba 100644 --- a/roles/kubernetes/preinstall/defaults/main.yml +++ b/roles/kubernetes/preinstall/defaults/main.yml @@ -53,3 +53,6 @@ minimal_node_memory_mb: 1024 minimal_master_memory_mb: 1500 yum_repo_dir: /etc/yum.repos.d + +# number of times package install task should be retried +pkg_install_retries: 4 diff --git a/roles/kubernetes/preinstall/tasks/0070-system-packages.yml b/roles/kubernetes/preinstall/tasks/0070-system-packages.yml index fa5f5f0f3..0b78603c3 100644 --- a/roles/kubernetes/preinstall/tasks/0070-system-packages.yml +++ b/roles/kubernetes/preinstall/tasks/0070-system-packages.yml @@ -77,7 +77,7 @@ state: latest register: pkgs_task_result until: pkgs_task_result is succeeded - retries: 4 + retries: "{{ pkg_install_retries }}" delay: "{{ retry_stagger | random + 3 }}" when: not (ansible_os_family in ["Flatcar Container Linux by Kinvolk", "ClearLinux"] or is_fedora_coreos) tags: diff --git a/tests/files/tf-ovh_ubuntu18-calico.yml b/tests/files/tf-ovh_ubuntu18-calico.yml index 43ef55aa3..704e21735 100644 --- a/tests/files/tf-ovh_ubuntu18-calico.yml +++ b/tests/files/tf-ovh_ubuntu18-calico.yml @@ -2,6 +2,8 @@ dns_min_replicas: 1 deploy_netchecker: true sonobuoy_enabled: true +pkg_install_retries: 10 +retry_stagger: 10 # Ignore ping errors ignore_assert_errors: true