Skip to content

Commit 7b4f818

Browse files
authored
Update uperf process (#840)
* uperf: wait for vms update * Update base image * Update pod starting clients check
1 parent deb7c8b commit 7b4f818

File tree

6 files changed

+82
-28
lines changed

6 files changed

+82
-28
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quay.io/operator-framework/ansible-operator:v1.32.0
1+
FROM quay.io/operator-framework/ansible-operator:v1.37.0
22
USER root
33

44
COPY requirements.yml ${HOME}/requirements.yml
@@ -8,8 +8,8 @@ RUN ansible-galaxy collection list
88
RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \
99
&& chmod -R ug+rwx ${HOME}/.ansible
1010

11-
COPY image_resources/centos8-appstream.repo /etc/yum.repos.d/centos8-appstream.repo
12-
RUN dnf install -y --nodocs redis openssl --enablerepo=centos8-appstream-* && dnf clean all
11+
COPY image_resources/centos9-appstream.repo /etc/yum.repos.d/centos9-appstream.repo
12+
RUN dnf install -y --nodocs redis openssl --enablerepo=centos9-appstream-* --refresh && dnf clean all
1313

1414
COPY resources/kernel-cache-drop-daemonset.yaml /opt/kernel_cache_dropper/
1515
COPY watches.yaml ${HOME}/watches.yaml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[centos9-appstream-x86_64]
2+
name=CentOS-9-Appstream-x86_64
3+
baseurl=http://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/
4+
enabled=0
5+
gpgcheck=0
6+
7+
[centos9-appstream-aarch64]
8+
name=CentOS-9-Appstream-aarch64
9+
baseurl=http://mirror.stream.centos.org/9-stream/AppStream/aarch64/os/
10+
enabled=0
11+
gpgcheck=0
12+
13+
[centos9-appstream-ppc64le]
14+
name=CentOS-9-Appstream-ppc64le
15+
baseurl=http://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/
16+
enabled=0
17+
gpgcheck=0

roles/uperf/tasks/main.yml

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
register: serviceip
1111
when: workload_args.serviceip is defined and workload_args.serviceip
1212

13+
- name: Get Workload Pairs
14+
set_fact:
15+
workload_pairs: "{{ workload_args.pair|default('1')|int }}"
16+
1317
- block:
1418

1519
- name: Create service for server pods
1620
k8s:
1721
definition: "{{ lookup('template', 'service.yml.j2') | from_yaml }}"
18-
with_sequence: start=0 count={{ workload_args.pair | default('1')|int }}
22+
with_sequence: start=0 count={{ workload_pairs }}
1923
when:
2024
- workload_args.serviceip is defined and workload_args.serviceip
2125
- ( workload_args.servicetype | default("clusterip") == "clusterip" ) or
@@ -24,7 +28,7 @@
2428
- name: Create metal LB service for server pods
2529
k8s:
2630
definition: "{{ lookup('template', 'service_metallb.yml.j2') | from_yaml }}"
27-
with_sequence: start=0 count={{ workload_args.pair | default('1')|int }}
31+
with_sequence: start=0 count={{ workload_pairs }}
2832
when:
2933
- workload_args.serviceip is defined and workload_args.serviceip
3034
- workload_args.servicetype | default("clusterip") == "metallb"
@@ -33,7 +37,7 @@
3337
k8s:
3438
definition: "{{ lookup('template', 'server.yml.j2') | from_yaml }}"
3539
register: servers
36-
with_sequence: start=0 count={{ workload_args.pair | default('1')|int }}
40+
with_sequence: start=0 count={{ workload_pairs }}
3741

3842
- include_role:
3943
name: benchmark_state
@@ -49,7 +53,7 @@
4953
k8s:
5054
definition: "{{ lookup('template', 'server_vm.yml.j2') | from_yaml }}"
5155
register: servers
52-
with_sequence: start=0 count={{ workload_args.pair | default('1')|int }}
56+
with_sequence: start=0 count={{ workload_pairs }}
5357

5458
- include_role:
5559
name: benchmark_state
@@ -70,19 +74,21 @@
7074
- type = {{ ansible_operator_meta.name }}-bench-server-{{ trunc_uuid }}
7175
register: server_pods
7276

77+
- name: Get number of running server pods
78+
set_fact:
79+
running_pod_count: "{{ server_pods | json_query('resources[].status[]')|selectattr('phase','match','Running')|list|length|int }}"
80+
7381
- include_role:
7482
name: benchmark_state
7583
tasks_from: set_state
7684
vars:
7785
state: "Starting Clients"
78-
when: "workload_args.pair|default('1')|int == server_pods | json_query('resources[].status[]')|selectattr('phase','match','Running')|list|length"
79-
86+
when: workload_pairs == running_pod_count
8087

8188
when: benchmark_state.resources[0].status.state == "Starting Servers" and resource_kind == "pod"
8289

8390
- block:
84-
85-
- name: Wait for vms to be running....
91+
- name: Get Server VMs
8692
k8s_info:
8793
kind: VirtualMachineInstance
8894
api_version: kubevirt.io/v1alpha3
@@ -91,19 +97,31 @@
9197
- type = {{ ansible_operator_meta.name }}-bench-server-{{ trunc_uuid }}
9298
register: server_vms
9399

100+
- name: Get Running VMs
101+
set_fact:
102+
running_vm_count: "{{ server_vms | json_query('resources[].status[]') | selectattr('phase','match','Running') | list | length | int }}"
103+
104+
- name: Get VMs with ip addresses
105+
set_fact:
106+
server_vms_with_ips: "{{ server_vms | json_query('resources[].status.interfaces[0]') | selectattr('ipAddress', 'defined') | map(attribute='ipAddress') | list | length | int }}"
107+
108+
- name: Determine if can start clients
109+
set_fact:
110+
start_clients: "{{ (workload_pairs == running_vm_count) and (workload_pairs == server_vms_with_ips) }}"
111+
94112
- include_role:
95113
name: benchmark_state
96114
tasks_from: set_state
97115
vars:
98116
state: "Starting Clients"
99-
when: "workload_args.pair|default('1')|int == server_vms | json_query('resources[].status[]')|selectattr('phase','match','Running')|list|length and workload_args.pair|default('1')|int == (server_vms | json_query('resources[].status.interfaces[0].ipAddress')|length)"
117+
when: start_clients
100118

101119
- name: blocking client from running uperf
102120
command: "redis-cli set start-{{ trunc_uuid }} false"
103121
with_items: "{{ server_vms.resources }}"
104-
when: "workload_args.pair|default('1')|int == server_vms | json_query('resources[].status[]')|selectattr('phase','match','Running')|list|length and workload_args.pair|default('1')|int == (server_vms | json_query('resources[].status.interfaces[0].ipAddress')|length)"
122+
when: start_clients
105123

106-
when: benchmark_state.resources[0].status.state == "Starting Servers" and resource_kind == "vm" and workload_args.pair|default('1')|int|int == 1
124+
when: benchmark_state.resources[0].status.state == "Starting Servers" and resource_kind == "vm"
107125

108126
- block:
109127

@@ -148,11 +166,16 @@
148166
- workload_args.serviceip|default(False) == True and serviceip.resources|length > 0
149167
- workload_args.servicetype | default("clusterip") != "nodeport"
150168

169+
- include_role:
170+
name: benchmark_state
171+
tasks_from: set_state
172+
vars:
173+
state: "Waiting for Clients"
174+
151175
when: resource_kind == "pod"
152176

153177
- block:
154-
155-
- name: Wait for vms to be running....
178+
- name: Get Server VMs
156179
k8s_info:
157180
kind: VirtualMachineInstance
158181
api_version: kubevirt.io/v1alpha3
@@ -161,25 +184,39 @@
161184
- type = {{ ansible_operator_meta.name }}-bench-server-{{ trunc_uuid }}
162185
register: server_vms
163186

187+
- name: Get Running VMs
188+
set_fact:
189+
running_vm_count: "{{ server_vms | json_query('resources[].status[]') | selectattr('phase','match','Running') | list | length | int }}"
190+
191+
- name: Get VMs with ip addresses
192+
set_fact:
193+
server_vms_with_ips: "{{ server_vms | json_query('resources[].status.interfaces[0]') | selectattr('ipAddress', 'defined') | map(attribute='ipAddress') | list | length | int }}"
194+
195+
- name: Determine if can start clients
196+
set_fact:
197+
start_clients: "{{ (workload_pairs == running_vm_count) and (workload_pairs == server_vms_with_ips) }}"
164198

165199
- name: Generate uperf test files
166200
k8s:
167201
definition: "{{ lookup('template', 'configmap_script.yml.j2') | from_yaml }}"
168202
with_items: "{{ server_vms.resources }}"
203+
when: start_clients
169204

170205
- name: Start Client(s)
171206
k8s:
172207
definition: "{{ lookup('template', 'workload_vm.yml.j2') | from_yaml }}"
173208
with_indexed_items: "{{ server_vms.resources }}"
174-
when: server_vms.resources|length > 0
209+
when: start_clients
210+
211+
- include_role:
212+
name: benchmark_state
213+
tasks_from: set_state
214+
vars:
215+
state: "Waiting for Clients"
216+
when: start_clients
175217

176218
when: resource_kind == "vm"
177219

178-
- include_role:
179-
name: benchmark_state
180-
tasks_from: set_state
181-
vars:
182-
state: "Waiting for Clients"
183220

184221
when: benchmark_state.resources[0].status.state == "Starting Clients"
185222

roles/uperf/templates/configmap_script.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:
5-
name: uperf-run-script-{{item.status.interfaces[0].ipAddress}}-{{ trunc_uuid }}
5+
name: uperf-run-script-{{item.status.interfaces[0].ipAddress | replace(".", "-") }}-{{ trunc_uuid }}
66
namespace: '{{ operator_namespace }}'
77
data:
88
run_script.sh : |

roles/uperf/templates/workload.yml.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ metadata:
77
{% if workload_args.servicetype | default("clusterip") == "nodeport" %}
88
name: 'uperf-client-{{item.status.hostIP}}-{{ item.metadata.labels.index|int }}-{{ trunc_uuid }}'
99
{% elif workload_args.servicetype | default("clusterip") == "metallb" or workload_args.servicetype | default("clusterip") == "loadbalancer" %}
10-
name: 'uperf-client-{{item.status.loadBalancer.ingress[0].ip}}-{{ trunc_uuid }}'
10+
name: 'uperf-client-{{item.status.loadBalancer.ingress[0].ip | replace(".", "-") }}-{{ trunc_uuid }}'
1111
{% else %}
12-
name: 'uperf-client-{{item.spec.clusterIP}}-{{ trunc_uuid }}'
12+
name: 'uperf-client-{{item.spec.clusterIP | replace(".", "-")}}-{{ trunc_uuid }}'
1313
{% endif %}
1414
{% else %}
15-
name: 'uperf-client-{{item.status.podIP}}-{{ trunc_uuid }}'
15+
name: 'uperf-client-{{item.status.podIP | replace(".", "-")}}-{{ trunc_uuid }}'
1616
{% endif %}
1717
namespace: '{{ operator_namespace }}'
1818
{% if workload_args.annotations is defined or workload_args.server_annotations is defined %}

roles/uperf/templates/workload_vm.yml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: kubevirt.io/v1alpha3
33
kind: VirtualMachineInstance
44
metadata:
5-
name: 'uperf-client-{{item.1.status.interfaces[0].ipAddress}}-{{ trunc_uuid }}'
5+
name: 'uperf-client-{{item.1.status.interfaces[0].ipAddress | replace(".", "-") }}-{{ trunc_uuid }}'
66
namespace: '{{ operator_namespace }}'
77
labels:
88
benchmark-uuid: {{ uuid }}
@@ -93,6 +93,6 @@ spec:
9393
name: uperf-test-{{ item.0 }}-{{ trunc_uuid }}
9494
name: app-config-disk
9595
- configMap:
96-
name: uperf-run-script-{{item.1.status.interfaces[0].ipAddress}}-{{ trunc_uuid }}
96+
name: uperf-run-script-{{item.1.status.interfaces[0].ipAddress | replace(".", "-") }}-{{ trunc_uuid }}
9797
name: run-config-disk
9898
status: {}

0 commit comments

Comments
 (0)