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

[CI] Upgrade version of Python SDK used in distributed mutext script #1826

Merged
merged 1 commit into from
Jun 9, 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
8 changes: 2 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ jobs:
inputs:
secureFile: 'ci-gcs-dev.json'
- script: |
pip install azure-storage-blob==12.0.0b3
# the recent release 1.0.0b4 has a breaking change
pip install azure-core==1.0.0b3
pip install azure-storage-blob==12.12.0
# acquire the mutex before running live tests to avoid conflicts
python ./tool_distributed_mutex.py lock "$(MUTEX_URL)"
# set the variable to indicate that the mutex was actually acquired
Expand Down Expand Up @@ -241,9 +239,7 @@ jobs:
S2S_SRC_GCP_SERVICE_URL: $(S2S_SRC_GCP_SERVICE_URL)
SHARE_SAS_URL: $(SHARE_SAS_URL)
- script: |
pip install azure-storage-blob==12.0.0b3
# the recent release 1.0.0b4 has a breaking change
pip install azure-core==1.0.0b3
pip install azure-storage-blob==12.12.0
python ./tool_distributed_mutex.py unlock "$(MUTEX_URL)"
name: 'Release_the_distributed_mutex'
# this runs even if the job was canceled (only if the mutex was acquired by this job)
Expand Down
8 changes: 4 additions & 4 deletions tool_distributed_mutex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# note that the track 2 python SDK is being used here
from azure.storage.blob import (
BlobClient,
LeaseClient,
BlobLeaseClient,
)

from azure.core import (
from azure.core.exceptions import (
HttpResponseError,
)

Expand All @@ -31,15 +31,15 @@ def process():
action, mutex_url = get_raw_input()

# check whether the blob exists, if not quit right away to avoid wasting time
blob_client = BlobClient(mutex_url)
blob_client = BlobClient.from_blob_url(mutex_url)
try:
blob_client.get_blob_properties()
print("INFO: validated mutex url")
except HttpResponseError as e:
raise ValueError('please provide an existing and valid blob URL, failed to get properties with error: ' + e)

# get a handle on the lease
lease_client = LeaseClient(blob_client)
lease_client = BlobLeaseClient(blob_client)
if action == UNLOCK:
# make the lease free as soon as possible
lease_client.break_lease(lease_break_period=1)
Expand Down