Skip to content

Fix azure SDK namespace shadowing in CRUD pipeline steps (run via -m crud.main) - #1319

Merged
Xu Xue (xuexu6666) merged 1 commit into
mainfrom
xuxue/crud-azure-namespace-shadowing
Sep 10, 2026
Merged

Xu Xue (xuexu6666) merged 1 commit into
mainfrom
xuxue/crud-azure-namespace-shadowing

Conversation

@xuexu6666

@xuexu6666 Xu Xue (xuexu6666) commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Regression introduced by #1231 ("Register crud module in pyproject.toml"), which added modules/python/crud/azure/__init__.py. This PR fixes the fallout.

Problem

Every pipeline that executes the crud module has failed on every run since #1231 merged. The CRUD tasks fail immediately:

File ".../modules/python/crud/main.py", line 19
  from crud.azure.node_pool_crud import NodePoolCRUD
File ".../modules/python/clients/aks_client.py", line 20
  from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
ModuleNotFoundError: No module named 'azure.core'

azure-core is installed correctly by "Install Dependencies" — this is namespace shadowing, not a missing dependency.

Impacted pipelines (both crud engines)

Topology Engine steps Pipeline Last green → now
k8s-crud-gpu engine/crud/k8s/{execute,collect}.yml GPU Cluster CRUD green on 65836724, red on every c66241e4 run
k8s-cluster-crud-machine engine/machine/k8s/{execute,collect}.yml Autoscale / Machine-API CRUD green on 65836724, red on every c66241e4 run

A full-repo grep for crud/main.py finds only these four step files, so this PR covers 100% of the impacted call sites.

Root cause

The steps run the script as a file:

workingDirectory: modules/python
env:
  PYTHON_SCRIPT_FILE: $(Pipeline.Workspace)/s/modules/python/crud/main.py
script: python3 "$PYTHON_SCRIPT_FILE" create ...

Running python3 .../crud/main.py puts the script's own directory — modules/python/crud/ — at sys.path[0]. #1231 added modules/python/crud/azure/__init__.py, turning crud/azure/ into a regular package. Found first on sys.path, it shadows the installed azure SDK namespace package, so azure.core can no longer be resolved.

Unit tests didn't catch this because pytest runs with a different sys.path that never places crud/ at sys.path[0].

Fix

Invoke the module with -m instead of running the file. python3 -m crud.main puts modules/python (the working directory) on sys.path[0] instead of crud/, so the azure SDK resolves from site-packages while crud.azure still imports. This is also what the telescope-crud entry point registered in #1231 was intended for. The now-unused PYTHON_SCRIPT_FILE env var is removed.

Applied to all affected engine steps:

  • steps/engine/crud/k8s/execute.yml
  • steps/engine/crud/k8s/collect.yml
  • steps/engine/machine/k8s/execute.yml
  • steps/engine/machine/k8s/collect.yml

Verification

Pipeline runs on this branch (xuxue/crud-azure-namespace-shadowing):

Both run the actual CRUD create/scale/delete operations — sailing past the ModuleNotFoundError that killed every prior run.

Also reproduced the shadowing and confirmed the fix locally:

# crud/ on sys.path[0] (file invocation)
import azure.core.exceptions  -> ModuleNotFoundError: No module named 'azure.core'

# modules/python on sys.path[0] (-m crud.main)
import azure.core.exceptions; import crud.azure  -> both import OK

The crud engine/machine steps ran main.py as a file
(python3 $PYTHON_SCRIPT_FILE), which puts modules/python/crud/ on
sys.path[0]. After #1231 added crud/azure/__init__.py, that regular
package shadows the installed 'azure' SDK namespace, so
'from azure.core.exceptions import ...' fails with
ModuleNotFoundError: No module named 'azure.core'.

Invoke as a module instead (python3 -m crud.main) so sys.path[0] is
modules/python: the azure SDK resolves from site-packages and
crud.azure still imports. Drop the now-unused PYTHON_SCRIPT_FILE env var.
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

For reviewers only: reply /run-tf-integration to trigger the terraform integration pipeline before approving the PR.

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.

🟢 Approval recommended

The changes are narrowly scoped YAML updates that consistently apply the intended -m crud.main invocation and remove the now-unused environment variable without introducing new logic paths.

Pull request overview

Updates Telescope’s engine pipeline steps to invoke the Python CRUD entrypoint as a module (python3 -m crud.main) rather than executing crud/main.py as a file, preventing the crud/azure package from shadowing the installed Azure SDK azure.* namespace during pipeline execution.

Changes:

  • Switch CRUD and Machine-API pipeline steps to python3 -m crud.main ... for all CRUD invocations.
  • Remove the unused PYTHON_SCRIPT_FILE environment variable from affected steps.
File summaries
File Description
steps/engine/machine/k8s/execute.yml Runs create-machine / scale-machine via python3 -m crud.main and removes PYTHON_SCRIPT_FILE.
steps/engine/machine/k8s/collect.yml Runs collect via python3 -m crud.main and removes PYTHON_SCRIPT_FILE.
steps/engine/crud/k8s/execute.yml Runs CRUD create/scale/workload/delete operations via python3 -m crud.main and removes PYTHON_SCRIPT_FILE.
steps/engine/crud/k8s/collect.yml Runs collect via python3 -m crud.main and removes PYTHON_SCRIPT_FILE.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@xuexu6666
Xu Xue (xuexu6666) merged commit 94d0bd4 into main Sep 10, 2026
8 checks passed
@xuexu6666
Xu Xue (xuexu6666) deleted the xuxue/crud-azure-namespace-shadowing branch September 10, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants