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

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

Merged
merged 3 commits into from
Mar 8, 2018

Conversation

williexu
Copy link
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).

@promptws
Copy link

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
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
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
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
Contributor

Choose a reason for hiding this comment

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

raise

Copy link
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
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
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
Contributor

troydai commented Mar 7, 2018

Looks good besides the comments.

@williexu
Copy link
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