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

fix flake8 errors in Kubespray CI - tox-inventory-builder #6910

Merged
merged 4 commits into from
Nov 23, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions contrib/inventory_builder/tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_ensure_required_groups(self):
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'])
Comment on lines 53 to +54
Copy link
Contributor

Choose a reason for hiding this comment

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

What about something that doesn't iterate over the groups like:

self.assertTrue(set(groups).issuperset(set(self.inv.yaml_config['all']['children'])))


def test_get_host_id(self):
hostnames = ['node99', 'no99de01', '01node01', 'node1.domain',
Expand Down Expand Up @@ -209,8 +209,8 @@ def test_purge_invalid_hosts(self):
('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())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this works without having to specify the keys() method

Suggested change
bad_host, self.inv.yaml_config['all']['hosts'].keys())
bad_host, self.inv.yaml_config['all']['hosts'])


def test_add_host_to_group(self):
group = 'etcd'
Expand All @@ -227,8 +227,8 @@ def test_set_kube_master(self):
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([
Expand All @@ -246,25 +246,25 @@ def test_set_k8s_cluster(self):

self.inv.set_k8s_cluster()
for host in expected_hosts:
self.assertTrue(
host in
self.assertIn(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same suggestion as the first comment

self.assertTrue(set(expected_hosts).issuperset(self.inv.yaml_config['all']['children'][group]['children']))

host,
self.inv.yaml_config['all']['children'][group]['children'])

def test_set_kube_node(self):
group = 'kube-node'
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
Expand Down
1 change: 1 addition & 0 deletions roles/container-engine/cri-o/tasks/crio_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions roles/download/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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 }}"
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions roles/kubernetes/preinstall/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion roles/kubernetes/preinstall/tasks/0070-system-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/files/tf-ovh_ubuntu18-calico.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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