Skip to content

Commit

Permalink
temporary work-around to #129 (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueskyjunkie authored Feb 23, 2022
1 parent a298aa1 commit b2a7961
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
11 changes: 10 additions & 1 deletion foodx_devops_tools/deploy_me/_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

import click

from foodx_devops_tools.azure.cloud.auth import AzureAuthenticationError
from foodx_devops_tools.azure.cloud.auth import (
AzureAuthenticationError,
login_service_principal,
)
from foodx_devops_tools.pipeline_config import (
ApplicationDefinition,
ApplicationDeploymentSteps,
Expand Down Expand Up @@ -358,6 +361,12 @@ async def do_deploy(
timeout_seconds=pipeline_parameters.wait_timeout_seconds,
)
try:
# this is a temporary work-around to the login concurrency problem -
# it works provided there is no more than a single subscription per
# deployment at a time.
# https://github.com/Food-X-Technologies/foodx_devops_tools/issues/129
await login_service_principal(deployment_data.data.azure_credentials)

wait_task = asyncio.create_task(
frame_deployment_status.wait_for_all_completed()
)
Expand Down
2 changes: 0 additions & 2 deletions foodx_devops_tools/deploy_me/application_steps/_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import click

from foodx_devops_tools.azure.cloud.auth import login_service_principal
from foodx_devops_tools.azure.cloud.resource_group import (
AzureSubscriptionConfiguration,
)
Expand Down Expand Up @@ -118,7 +117,6 @@ async def _do_step_deployment(
this_step.resource_group,
)

await login_service_principal(deployment_data.data.azure_credentials)
if enable_validation:
log.info(f"validation deployment enabled, {step_context}")
resource_group = _mangle_validation_resource_group(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
async def test_clean(
mock_apply_template,
mock_deploystep_context,
mock_login,
mock_rg_deploy,
mock_run_puff,
mock_verify_puff_target,
Expand All @@ -33,7 +32,6 @@ async def test_default_override_parameters(
default_override_parameters,
mock_apply_template,
mock_deploystep_context,
mock_login,
mock_rg_deploy,
mock_run_puff,
mock_verify_puff_target,
Expand Down Expand Up @@ -65,7 +63,6 @@ async def test_secrets_enabled(
default_override_parameters,
mock_apply_template,
mock_deploystep_context,
mock_login,
mock_rg_deploy,
mock_run_puff,
mock_verify_puff_target,
Expand Down Expand Up @@ -114,9 +111,7 @@ async def test_secrets_enabled(


@pytest.mark.asyncio
async def test_step_skip(
caplog, mock_deploystep_context, mock_login, mock_rg_deploy
):
async def test_step_skip(caplog, mock_deploystep_context, mock_rg_deploy):
with caplog.at_level(logging.DEBUG):
mock_deploystep_context["deployment_data"].data.to = StructuredTo(
frame="f1", application="a1", step="other_step"
Expand Down
3 changes: 1 addition & 2 deletions tests/ci/unit_tests/deploy_me/deployment/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
@pytest.fixture()
def mock_login(mock_async_method):
mock_async_method(
"foodx_devops_tools.deploy_me.application_steps"
"._deploy.login_service_principal"
"foodx_devops_tools.deploy_me._deployment.login_service_principal"
)


Expand Down
7 changes: 6 additions & 1 deletion tests/ci/unit_tests/deploy_me/deployment/test_do_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def prep_data(mock_async_method, mock_flattened_deployment, mock_run_puff):
class TestDoDeploy:
@pytest.mark.asyncio
async def test_validation_clean(
self, mocker, prep_data, mock_completion_event, pipeline_parameters
self,
mocker,
prep_data,
mock_completion_event,
mock_login,
pipeline_parameters,
):
cli_options = pipeline_parameters()
mock_frame, deployment_data, pipeline_config = prep_data
Expand Down

0 comments on commit b2a7961

Please sign in to comment.