Skip to content

[PostgreSQL] az postgres flexible-server deploy: Resolve deployment tool paths consistently - #34308

Merged
Naga Nandyala (naga-nandyala) merged 3 commits into
Azure:devfrom
thegabrielobo:fix/postgres-deploy-executable-paths
Nov 9, 2026
Merged

Naga Nandyala (naga-nandyala) merged 3 commits into
Azure:devfrom
thegabrielobo:fix/postgres-deploy-executable-paths

Conversation

@thegabrielobo

@thegabrielobo Gabriel Lobo (thegabrielobo) commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests Suppressions
️✔️ None ️✔️ 130/130 ⚠️ 5 added

This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.

5 added suppressions
File Line Kind Code
src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_deploy_commands.py 179 skipped test @unittest.skipUnless(is_windows(), 'Windows executable lookup')
src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_deploy_commands.py 189 skipped test @unittest.skipUnless(is_windows(), 'Windows executable lookup')
src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_deploy_commands.py 197 skipped test @unittest.skipUnless(is_windows(), 'Windows executable lookup')
src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_deploy_commands.py 205 skipped test @unittest.skipUnless(is_windows(), 'Windows executable lookup')
src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_deploy_commands.py 211 skipped test @unittest.skipUnless(is_windows(), 'Windows executable lookup')

Related command

az postgres flexible-server deploy setup
az postgres flexible-server deploy run

Description

Resolve Git and GitHub CLI paths before use and retain the resolved paths throughout PostgreSQL deployment setup and workflow execution.

  • Reuse the existing core executable lookup helper on Windows, with native executable and absolute-path checks for deployment tools.
  • Pass subprocess arguments as lists so executable paths, workflow paths, and arguments containing spaces remain intact.
  • Cover dependency lookup, authentication, repository operations, secret operations, and workflow invocation with focused unit tests.

This change is limited to PostgreSQL deployment commands. It does not change MySQL commands or the core subprocess helper.

Testing Guide

Validated on Windows with Python 3.14, using repository sources and an isolated dependency environment.

Set source imports from the repository root before running the commands:

$env:PYTHONPATH = "$PWD\src\azure-cli-core;$PWD\src\azure-cli;$PWD\src\azure-cli-telemetry;$PWD\src\azure-cli-testsdk"
python -m pytest -q -p no:cacheprovider src\azure-cli\azure\cli\command_modules\postgresql\tests\unit\test_deploy_commands.py src\azure-cli-core\azure\cli\core\tests\test_util.py -k 'PostgresqlDeployTest or TestSafeExecutablePath or test_run_cmd_arg_error'

Passed: 21 tests and 18 subtests; 30 unrelated tests deselected.

python -m flake8 src\azure-cli\azure\cli\command_modules\postgresql\commands\deploy_commands.py src\azure-cli\azure\cli\command_modules\postgresql\utils\_flexible_server_util.py src\azure-cli\azure\cli\command_modules\postgresql\tests\unit\test_deploy_commands.py
git diff --check
git diff --cached --check

All three checks passed. Deployment subprocesses and Azure calls are mocked; no live deployment was performed. The full suite, Linux execution, and azdev style/linter checks were not run locally.

History Notes

[PostgreSQL] az postgres flexible-server deploy: Resolve deployment tool paths consistently


This checklist is used to make sure that common guidelines for a pull request are followed.

Reuse executable lookup and retain resolved Git and GitHub CLI paths throughout deployment operations. Preserve arguments containing spaces and cover the deployment flows with unit tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 04:25
@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Oct 30, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution Gabriel Lobo (@thegabrielobo)! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test fixture accepts nonexistent tools and breaks missing-tool tests on Linux, while PATHEXT-dependent lookup can reject valid Git/GitHub CLI executables.

2 open issues
What changed in this PR

This PR makes PostgreSQL deployment commands resolve and reuse Git and GitHub CLI executable paths, while preserving paths and arguments containing spaces. MySQL commands and the core subprocess helper remain unchanged.

Changes:

  • Add deployment-tool resolution with Windows native-executable and absolute-path checks.
  • Pass resolved paths and argument lists through authentication, secret management, repository operations, and workflow execution.
  • Add focused tests for executable lookup and subprocess invocation.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​postgresql/​utils/​_flexible_server_util.py Adds executable resolution and updates deployment helpers to use resolved paths and argument lists.
src/​azure-cli/​azure/​cli/​command_modules/​postgresql/​tests/​unit/​test_deploy_commands.py Adds mocked coverage for lookup, path reuse, and deployment subprocess calls.
src/​azure-cli/​azure/​cli/​command_modules/​postgresql/​commands/​deploy_commands.py Retains resolved tool paths throughout deployment setup and workflow execution.

Review effort: Balanced

patch('subprocess.run', self.run),
patch('subprocess.Popen', self.popen),
patch('builtins.open', mock_open()),
patch.object(_util.os.path, 'exists', return_value=True),
Comment on lines +266 to +267
name = executable if os.path.splitext(executable)[1] else executable + '.exe'
resolved = executable if explicit else get_safe_executable_path(name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gabriel Lobo (@thegabrielobo) could you look into the suggestion

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Gabriel Lobo and others added 2 commits November 9, 2026 13:35
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants