From 7783c9b1ee46ea7cc2ab0a9d481f1154d7f506a1 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 9 Dec 2022 11:47:58 -0800 Subject: [PATCH] [stable-2.13] ansible-test - Fix target PyPI proxy config.. (cherry picked from commit dcc08eec35fde72845d121859abf1ffef1e9030f) Co-authored-by: Matt Clay --- .../fragments/ansible-test-pypi-proxy-fix.yml | 4 ++++ .../_internal/commands/integration/__init__.py | 18 ++++++++---------- .../lib/ansible_test/_internal/provisioning.py | 7 +++++-- 3 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 changelogs/fragments/ansible-test-pypi-proxy-fix.yml diff --git a/changelogs/fragments/ansible-test-pypi-proxy-fix.yml b/changelogs/fragments/ansible-test-pypi-proxy-fix.yml new file mode 100644 index 00000000000..5e5e52b1504 --- /dev/null +++ b/changelogs/fragments/ansible-test-pypi-proxy-fix.yml @@ -0,0 +1,4 @@ +bugfixes: + - ansible-test - Perform PyPI proxy configuration after instances are ready and bootstrapping has been completed. + Only target instances are affected, as controller instances were already handled this way. + This avoids proxy configuration errors when target instances are not yet ready for use. diff --git a/test/lib/ansible_test/_internal/commands/integration/__init__.py b/test/lib/ansible_test/_internal/commands/integration/__init__.py index a20c3ab0f83..2ae1e39c9db 100644 --- a/test/lib/ansible_test/_internal/commands/integration/__init__.py +++ b/test/lib/ansible_test/_internal/commands/integration/__init__.py @@ -98,6 +98,7 @@ from ...host_configs import ( from ...host_profiles import ( ControllerProfile, + ControllerHostProfile, HostProfile, PosixProfile, SshTargetHostProfile, @@ -960,13 +961,10 @@ def command_integration_filter(args, # type: TIntegrationConfig return host_state, internal_targets -def requirements(args, host_state): # type: (IntegrationConfig, HostState) -> None - """Install requirements.""" - target_profile = host_state.target_profiles[0] - - configure_pypi_proxy(args, host_state.controller_profile) # integration, windows-integration, network-integration - - if isinstance(target_profile, PosixProfile) and not isinstance(target_profile, ControllerProfile): - configure_pypi_proxy(args, target_profile) # integration - - install_requirements(args, host_state.controller_profile.python, ansible=True, command=True) # integration, windows-integration, network-integration +def requirements(host_profile: HostProfile) -> None: + """Install requirements after bootstrapping and delegation.""" + if isinstance(host_profile, ControllerHostProfile) and host_profile.controller: + configure_pypi_proxy(host_profile.args, host_profile) # integration, windows-integration, network-integration + install_requirements(host_profile.args, host_profile.python, ansible=True, command=True) # integration, windows-integration, network-integration + elif isinstance(host_profile, PosixProfile) and not isinstance(host_profile, ControllerProfile): + configure_pypi_proxy(host_profile.args, host_profile) # integration diff --git a/test/lib/ansible_test/_internal/provisioning.py b/test/lib/ansible_test/_internal/provisioning.py index e61a0230948..5a5361ed60e 100644 --- a/test/lib/ansible_test/_internal/provisioning.py +++ b/test/lib/ansible_test/_internal/provisioning.py @@ -99,7 +99,7 @@ def prepare_profiles( args, # type: TEnvironmentConfig targets_use_pypi=False, # type: bool skip_setup=False, # type: bool - requirements=None, # type: t.Optional[t.Callable[[TEnvironmentConfig, HostState], None]] + requirements=None, # type: t.Optional[t.Callable[[HostProfile], None]] ): # type: (...) -> HostState """ Create new profiles, or load existing ones, and return them. @@ -139,7 +139,7 @@ def prepare_profiles( check_controller_python(args, host_state) if requirements: - requirements(args, host_state) + requirements(host_state.controller_profile) def configure(profile): # type: (HostProfile) -> None """Configure the given profile.""" @@ -148,6 +148,9 @@ def prepare_profiles( if not skip_setup: profile.configure() + if requirements: + requirements(profile) + dispatch_jobs([(profile, WrappedThread(functools.partial(configure, profile))) for profile in host_state.target_profiles]) return host_state