Skip to content

Commit

Permalink
Use concurrent.futures instead of multiprocessing
Browse files Browse the repository at this point in the history
On the environment with enabled SSL the SSLv3_ALERT_BAD_RECORD_MAC error
occurs in fio_setup/fio_cleanup modules, in the section where processes
of creating/deleting VMs are paralleled.
This is due the paralleled processes have to communicate with each other
about the state of the shared SSL connection.
Changing to multithreading resolves the issues.

Related-PROD: #PROD-37187
Change-Id: I4f15ef900c79811db0d807ae2c91779595f497d2
  • Loading branch information
Dmitriy Kruglov committed Jun 9, 2024
1 parent 8143233 commit 5e3ee1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions fio/fio_cleanup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import multiprocessing as mp
import concurrent.futures as cex

import connection as conn
from openstack.exceptions import ResourceFailure
Expand Down Expand Up @@ -51,10 +51,10 @@ def delete_fio_client(vm_id: str) -> None:
vms = list(compute.servers(name=CLIENT_NAME_MASK, details=False))

# Delete fio VMs in parallel in batches of CONCURRENCY size
with mp.Pool(processes=CONCURRENCY) as pool:
results = [pool.apply_async(delete_fio_client, (vm.id,)) for vm in vms]
with cex.ThreadPoolExecutor(max_workers=CONCURRENCY) as executor:
futures = [executor.submit(delete_fio_client, vm.id) for vm in vms]
# Waits for batch of fio VMs to be deleted
_ = [r.get() for r in results]
_ = [future.result() for future in futures]

# Remove ports from fio router (including external GW)
router = network.find_router(ROUTER_NAME)
Expand Down
10 changes: 4 additions & 6 deletions fio/fio_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import base64
import multiprocessing as mp
import concurrent.futures as cex
import os
import random
import sys
Expand Down Expand Up @@ -224,9 +224,7 @@ def create_fio_client(
user_data=udata)

# Create fio client VMs in parallel in batches of CONCURRENCY size
with mp.Pool(processes=CONCURRENCY) as pool:
results = [
pool.apply_async(create_fio_client, kwds=vm_kwargs)
for _ in range(CLIENTS_COUNT)]
with cex.ThreadPoolExecutor(max_workers=CONCURRENCY) as executor:
futures = [executor.submit(create_fio_client, **vm_kwargs) for _ in range(CLIENTS_COUNT)]
# Wait for batch of fio client VMs to be created
_ = [r.get() for r in results]
_ = [future.result() for future in futures]

0 comments on commit 5e3ee1d

Please sign in to comment.