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

rp changes for porter show #2542

Merged
merged 3 commits into from
Sep 5, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ BUG FIXES:

* API health check is also returned by accessing the root path at / ([#2469](https://github.com/microsoft/AzureTRE/pull/2469))
* Temporary disable AppInsight's private endpoint in base workspace ([#2543](https://github.com/microsoft/AzureTRE/pull/2543))
* Resource Processor execution optimization (`porter show`) for long-standing services ([#2542](https://github.com/microsoft/AzureTRE/pull/2542))

## 0.4.2 (August 23, 2022)

Expand Down
2 changes: 1 addition & 1 deletion resource_processor/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.5"
__version__ = "0.4.6"
6 changes: 3 additions & 3 deletions resource_processor/resources/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ async def build_porter_command(config, logger, msg_body, custom_action=False):
f" {porter_parameters} --allow-docker-host-access --force"
f" --cred ./vmss_porter/arm_auth_local_debugging.json"
f" --cred ./vmss_porter/aad_auth.json"
f" && porter show {installation_id}"]
]
return command_line


async def build_porter_command_for_outputs(msg_body):
installation_id = get_installation_id(msg_body)
# we only need "real" outputs and use jq to remove the logs which are big
command_line = [f"porter show {installation_id} --output json | jq -c '. | select(.Outputs!=null) | .Outputs | del (.[] | select(.Name==\"io.cnab.outputs.invocationImageLogs\"))'"]
command_line = [f"porter installations output list --installation {installation_id} --output json | jq -c 'del (.[] | select(.Name==\"io.cnab.outputs.invocationImageLogs\"))'"]
return command_line


async def get_porter_parameter_keys(config, logger, msg_body):
command = [f"{azure_login_command(config)} >/dev/null && \
{azure_acr_login_command(config)} >/dev/null && \
porter explain --reference {config['registry_server']}/{msg_body['name']}:v{msg_body['version']} -ojson"]
porter explain --reference {config['registry_server']}/{msg_body['name']}:v{msg_body['version']} --output json"]

proc = await asyncio.create_subprocess_shell(
''.join(command),
Expand Down
2 changes: 1 addition & 1 deletion resource_processor/vmss_porter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM python:3.8-slim-buster
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install Azure CLI
ARG AZURE_CLI_VERSION=2.37.0-1~buster
ARG AZURE_CLI_VERSION=2.39.0-1~buster
COPY scripts/azure-cli.sh /tmp/
RUN export AZURE_CLI_VERSION=${AZURE_CLI_VERSION} \
&& /tmp/azure-cli.sh
Expand Down
4 changes: 4 additions & 0 deletions resource_processor/vmss_porter/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ async def invoke_porter_action(msg_body: dict, sb_client: ServiceBusClient, mess
# Build and run porter command (flagging if its a built-in action or custom so we can adapt porter command appropriately)
is_custom_action = action not in ["install", "upgrade", "uninstall"]
porter_command = await build_porter_command(config, message_logger_adapter, msg_body, is_custom_action)
message_logger_adapter.debug("Starting to run porter execution command...")
returncode, _, err = await run_porter(porter_command, message_logger_adapter, config)
message_logger_adapter.debug("Finished running porter execution command.")

# Handle command output
if returncode != 0:
Expand Down Expand Up @@ -191,7 +193,9 @@ async def get_porter_outputs(msg_body: dict, message_logger_adapter: logging.Log
Get outputs JSON from a Porter command
"""
porter_command = await build_porter_command_for_outputs(msg_body)
message_logger_adapter.debug("Starting to run porter output command...")
returncode, stdout, err = await run_porter(porter_command, message_logger_adapter, config)
message_logger_adapter.debug("Finished running porter output command.")

if returncode != 0:
error_message = "Error context message = " + " ".join(err.split('\n'))
Expand Down