Enable graceful upgrade of Nexus repo configurations without VM recreation#4983
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the Nexus shared service upgrade experience by re-applying repository configuration to an existing VM during upgrades (instead of requiring VM destruction/recreation), and updates the Nexus runtime image and bundle version accordingly.
Changes:
- Add an
azurerm_virtual_machine_run_commandto copy repo/realm configs to the VM and re-run the Nexus configuration script when config inputs change. - Update
configure_nexus_repos.shto create-or-update repositories (POST then PUT fallback) so changes apply to existing instances. - Bump Nexus image tag and bundle version, and document the upgrade behavior + add a CHANGELOG entry.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/shared_services/sonatype-nexus-vm/terraform/vm.tf | Ignore custom_data recreation triggers and add a VM run command to re-apply Nexus repo configuration on upgrade. |
| templates/shared_services/sonatype-nexus-vm/terraform/configure_nexus_repos_wrapper.sh | New wrapper script to deliver configs/scripts to the VM via run command and invoke configuration. |
| templates/shared_services/sonatype-nexus-vm/terraform/cloud-config.yaml | Remove repo configuration invocation from cloud-init flow. |
| templates/shared_services/sonatype-nexus-vm/scripts/configure_nexus_repos.sh | Make repository configuration idempotent by falling back to PUT when POST doesn’t create. |
| templates/shared_services/sonatype-nexus-vm/porter.yaml | Bump bundle version and Nexus runtime image tag. |
| docs/tre-admins/setup-instructions/configuring-shared-services.md | Document the new upgrade-based repo configuration flow and its limitations. |
| CHANGELOG.md | Add enhancement entry for Nexus repo upgrade behavior and image bump. |
|
@copilot address the pr comments:
|
Addressed in
|
…on 3.8.1; remove non-functional snapcraft proxy configuration.
Unit Test Results0 tests 0 ✅ 0s ⏱️ Results for commit e035496. ♻️ This comment has been updated with latest results. |
…kdown line length
|
@copilot Fix the code for all comments in this review thread. When a review comment includes a suggested change, apply the suggestion exactly. Do not make changes beyond what is described in the linked review thread. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
templates/shared_services/sonatype-nexus-vm/scripts/configure_nexus_repos.sh:189
- The script captures the HTTP status from the realms configuration request but never validates it, so a failed realms update will be silently ignored and the upgrade will appear successful even though Nexus is left misconfigured.
echo 'Configuring realms...'
status_code=$(curl -iu admin:"$NEXUS_ADMIN_PASSWORD" -XPUT \
'http://localhost/service/rest/v1/security/realms/active' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
templates/shared_services/sonatype-nexus-vm/porter.yaml:4
- PR description says the bundle version was bumped to 3.8.0, but porter.yaml sets it to 3.8.2 (and the CHANGELOG entry also mentions 3.8.2). Please reconcile the PR description vs the actual version you intend to release.
version: 3.8.2
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
templates/shared_services/sonatype-nexus-vm/porter.yaml:4
- PR description says the bundle version is bumped from 3.7.9 → 3.8.0, but the code sets it to 3.8.2 (and CHANGELOG also references 3.8.2). Please reconcile this either by updating the PR description or by adjusting this version so the PR metadata matches what will be released.
name: tre-shared-service-sonatype-nexus
version: 3.8.2
|
/test 0ca0a96 |
|
🤖 pr-bot 🤖 🏃 Running tests: https://github.com/microsoft/AzureTRE/actions/runs/30096654645 (with refid (in response to this comment from @marrobi) |
|
@copilot resolve the merge conflicts in this pull request |
Resolved the merge conflicts. The only conflict was in |
|
/test-force-approve e035496 |
|
🤖 pr-bot 🤖 ✅ Marking tests as complete (for commit e035496) (in response to this comment from @marrobi) |
Resolves #2721
What is being addressed
Nexus repository configurations were only applied on VM create, via cloud-init. Adding, modifying, or removing a proxy repo in the bundle's
nexus_repos_configJSON required destroying and recreating the Nexus VM to take effect — otherwise changes made in the Nexus UI were lost on any redeploy. Shared services also lacked a functioning upgrade path for this.How is this addressed
azurerm_virtual_machine_run_command(configure_nexus_repos) whose script base64-embeds the repo config JSONs, realms config, and configure script, writes them onto the VM, and runs the configure script. The run command re-executes whenever itssource.scriptchanges, so editing any config file re-applies it to the existing VM. A run command is used rather than a secondCustomScriptextension because only one CustomScript extension is allowed per VM (cloud_init_waitalready uses it); it runs aftercloud_init_wait.configure_nexus_repos.shnow creates each repo (POST, expects201) and falls back to updating it (PUTto the repo URL, expects204) when it already exists, so modified repos are applied to a running instance.custom_data/cloud-config.yamlruncmd) and addedignore_changes = [custom_data]to the VM so config changes no longer force a rebuild.3.94.0; bundle version3.7.9→3.8.0.CHANGELOG.md.Known limitations / pending work
ignore_changes = [custom_data]).