From d5f1625a7199363b1d646d1a42ecf1f6dd73bc0d Mon Sep 17 00:00:00 2001 From: Anat Balzam Date: Tue, 23 Aug 2022 12:55:25 +0300 Subject: [PATCH 1/2] Notifications sent to airlock manager instead of ws owner (#2493) * Initial airlock manager role * Modify and generalize emails * change the logic app Co-authored-by: Anat Balzam --- api_app/_version.py | 2 +- .../api/routes/airlock_resource_helpers.py | 12 +++--- api_app/event_grid/event_sender.py | 7 ++- api_app/models/domain/events.py | 5 +-- api_app/resources/strings.py | 2 +- api_app/services/aad_authentication.py | 19 +++++--- .../test_api/test_routes/test_airlock.py | 2 +- .../test_airlock_resource_helpers.py | 22 +++++----- .../app/AirlockNotifier/workflow.json | 43 +++++++++++-------- 9 files changed, 64 insertions(+), 50 deletions(-) diff --git a/api_app/_version.py b/api_app/_version.py index ac1552129d..2dd5536049 100644 --- a/api_app/_version.py +++ b/api_app/_version.py @@ -1 +1 @@ -__version__ = "0.4.17" +__version__ = "0.4.18" diff --git a/api_app/api/routes/airlock_resource_helpers.py b/api_app/api/routes/airlock_resource_helpers.py index e311a53345..f3ae0a8387 100644 --- a/api_app/api/routes/airlock_resource_helpers.py +++ b/api_app/api/routes/airlock_resource_helpers.py @@ -35,7 +35,7 @@ async def save_and_publish_event_airlock_request(airlock_request: AirlockRequest try: logging.debug(f"Sending status changed event for airlock request item: {airlock_request.id}") await send_status_changed_event(airlock_request) - await send_airlock_notification_event(airlock_request, role_assignment_details["researcher_emails"], role_assignment_details["owner_emails"]) + await send_airlock_notification_event(airlock_request, role_assignment_details) except Exception as e: airlock_request_repo.delete_item(airlock_request.id) logging.error(f"Failed sending status_changed message: {e}") @@ -58,7 +58,7 @@ async def update_and_publish_event_airlock_request(airlock_request: AirlockReque await send_status_changed_event(updated_airlock_request) access_service = get_access_service() role_assignment_details = access_service.get_workspace_role_assignment_details(workspace) - await send_airlock_notification_event(updated_airlock_request, role_assignment_details["researcher_emails"], role_assignment_details["owner_emails"]) + await send_airlock_notification_event(updated_airlock_request, role_assignment_details) return updated_airlock_request except Exception as e: logging.error(f"Failed sending status_changed message: {e}") @@ -70,12 +70,12 @@ def get_timestamp() -> float: def check_email_exists(role_assignment_details: defaultdict(list)): - if "researcher_emails" not in role_assignment_details or not role_assignment_details["researcher_emails"]: + if "WorkspaceResearcher" not in role_assignment_details or not role_assignment_details["WorkspaceResearcher"]: logging.error('Creating an airlock request but the researcher does not have an email address.') raise HTTPException(status_code=status.HTTP_417_EXPECTATION_FAILED, detail=strings.AIRLOCK_NO_RESEARCHER_EMAIL) - if "owner_emails" not in role_assignment_details or not role_assignment_details["owner_emails"]: - logging.error('Creating an airlock request but the workspace owner does not have an email address.') - raise HTTPException(status_code=status.HTTP_417_EXPECTATION_FAILED, detail=strings.AIRLOCK_NO_OWNER_EMAIL) + if "AirlockManager" not in role_assignment_details or not role_assignment_details["AirlockManager"]: + logging.error('Creating an airlock request but the airlock manager does not have an email address.') + raise HTTPException(status_code=status.HTTP_417_EXPECTATION_FAILED, detail=strings.AIRLOCK_NO_AIRLOCK_MANAGER_EMAIL) def get_airlock_requests_by_user_and_workspace(user: User, workspace: Workspace, airlock_request_repo: AirlockRequestRepository, diff --git a/api_app/event_grid/event_sender.py b/api_app/event_grid/event_sender.py index 6b3ed6b5ec..7fba8bcd0c 100644 --- a/api_app/event_grid/event_sender.py +++ b/api_app/event_grid/event_sender.py @@ -1,4 +1,6 @@ import logging +import re +from typing import Dict from azure.eventgrid import EventGridEvent from models.domain.events import StatusChangedData, AirlockNotificationData from event_grid.helpers import publish_event @@ -22,14 +24,15 @@ async def send_status_changed_event(airlock_request: AirlockRequest): await publish_event(status_changed_event, config.EVENT_GRID_STATUS_CHANGED_TOPIC_ENDPOINT) -async def send_airlock_notification_event(airlock_request: AirlockRequest, researchers_emails, owners_emails): +async def send_airlock_notification_event(airlock_request: AirlockRequest, emails: Dict): request_id = airlock_request.id status = airlock_request.status.value short_workspace_id = airlock_request.workspaceId[-4:] + snake_case_emails = {re.sub(r'(? Date: Tue, 23 Aug 2022 13:18:51 +0300 Subject: [PATCH 2/2] Github release doc (#2495) --- devops/scripts/list_versions.sh | 34 +++++++++++++++++++++++++++++++++ docs/tre-developers/release.md | 20 +++++++++++++++++++ mkdocs.yml | 2 ++ 3 files changed, 56 insertions(+) create mode 100755 devops/scripts/list_versions.sh create mode 100644 docs/tre-developers/release.md diff --git a/devops/scripts/list_versions.sh b/devops/scripts/list_versions.sh new file mode 100755 index 0000000000..49a6e2bc9a --- /dev/null +++ b/devops/scripts/list_versions.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o nounset +# set -o xtrace + +function template_version () { + version=$(yq eval ".version" "$1") + name=$(yq eval ".name" "$1") + echo -e "| $name | $version |" +} + +function component_version () { + version_line=$(cat "$2") + + # doesn't work with quotes + # shellcheck disable=SC2206 + version_array=( ${version_line//=/ } ) # split by = + version="${version_array[1]//\"}" # second element is what we want, remove " chars + echo -e "| $1 | $version |" +} + +echo -e "| name | version |\n| ----- | ----- |" + +component_version "devops" "devops/version.txt" +component_version "core" "templates/core/version.txt" + +find . -type f -name "porter.yaml" -not -path "*/.cnab/*" -print0 | sort | while read -r -d $'\0' file +do + template_version "$file" +done + + + diff --git a/docs/tre-developers/release.md b/docs/tre-developers/release.md new file mode 100644 index 0000000000..53f5cb3042 --- /dev/null +++ b/docs/tre-developers/release.md @@ -0,0 +1,20 @@ +# How to release an AzureTRE version + +A release is created when enough changes have been made and the main branch is stable enough. + +The process follows these steps: + +1. Update `CHANGELOG.md` in a PR with the following: + 1. Rename the top-most verion noted as unreleaed with the version number that makes sense. Note that you don't have to keep the one that is currently in the file as the version number chosen should reflect the changes made (major, minor, etc.) + 1. Create a new section for the next-unreleaed version so that future changes will be placed there. + 1. Run `devops/scripts/list_versions.sh` and include the output in the change log for the version you're about the release +1. Merge the PR +1. Create a GitHub Release + + 1. Go to https://github.com/microsoft/AzureTRE/releases/new + 1. Click on `Choose a tag` and type a new one for you version. It should be in the form of `v0.9.2` - note the "v" in the begining. + 1. The release title should be just the version number "0.9.2" in the example above. + 1. Copy the text from the CHANGELOG.md file and paste in the release description. + 1. Include a final line with a link to the full changelog similar to this: + + **Full Changelog**: https://github.com/microsoft/AzureTRE/compare/v0.9.1...v0.9.2 diff --git a/mkdocs.yml b/mkdocs.yml index 0a0de4fa03..f564b5d67d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -128,6 +128,8 @@ nav: - GitHub Actions: tre-admins/setup-instructions/workflows.md - Azure DevOps: coming-soon.md + - Releases: tre-developers/release.md + - Troubleshooting FAQ: # General Troubleshooting Section for Development - troubleshooting-faq/index.md - Enabling Debugging for the API: troubleshooting-faq/debug-api.md