Skip to content

Batch commands no longer throw error upon precondition failures.#5702

Merged
williexu merged 3 commits intoAzure:devfrom
williexu:storageprecondition
Mar 8, 2018
Merged

Batch commands no longer throw error upon precondition failures.#5702
williexu merged 3 commits intoAzure:devfrom
williexu:storageprecondition

Conversation

@williexu
Copy link
Copy Markdown
Contributor


Closes: #5286
-batch commands should not fail upon preconditions set by user

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

General Guidelines

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

@williexu williexu requested a review from troydai February 28, 2018 22:05
@promptws
Copy link
Copy Markdown

View a preview at https://prompt.ws/r/Azure/azure-cli/5702
This is an experimental preview for @microsoft users.

@williexu williexu added the Storage az storage label Feb 28, 2018
@williexu williexu changed the title Storageprecondition Batch commands no longer throw error upon precondition failures. Feb 28, 2018


def check_precondition_success(func):
def new_func(*args, **kwargs):
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.

wrapper

def new_func(*args, **kwargs):
from azure.common import AzureHttpError
try:
return (True, func(*args, **kwargs))
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.

You don't need the ()

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.

return 1, 2  # => (1,2)
return 1 => 1

except AzureHttpError as ex:
# Precondition failed error
if ex.status_code != 412:
raise ex
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.

raise

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.

Also, can we log a warning here?

# Precondition failed error
if ex.status_code != 412:
raise ex
return (False, None)
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.

no need ()

except AzureHttpError as ex:
# Precondition failed error
if ex.status_code != 412:
raise ex
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.

Also, can we log a warning here?

@troydai
Copy link
Copy Markdown
Contributor

troydai commented Mar 7, 2018

Looks good besides the comments.

@williexu
Copy link
Copy Markdown
Contributor Author

williexu commented Mar 8, 2018

@troydai could you review my feedback changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storage az storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Storage] --if-unmodified-since The condition specified using HTTP conditional header(s) is not met

4 participants