-
Notifications
You must be signed in to change notification settings - Fork 15.1k
2.3 release.py sftp retries #7450
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,10 +96,12 @@ def print_output(output): | |
| for line in output.split('\n'): | ||
| print(">", line) | ||
|
|
||
| def cmd(action, cmd, *args, **kwargs): | ||
| if isinstance(cmd, basestring) and not kwargs.get("shell", False): | ||
| cmd = cmd.split() | ||
| def cmd(action, cmd_arg, *args, **kwargs): | ||
| if isinstance(cmd_arg, basestring) and not kwargs.get("shell", False): | ||
| cmd_arg = cmd_arg.split() | ||
|
|
||
| allow_failure = kwargs.pop("allow_failure", False) | ||
| num_retries = kwargs.pop("num_retries", 0) | ||
|
|
||
| stdin_log = "" | ||
| if "stdin" in kwargs and isinstance(kwargs["stdin"], basestring): | ||
|
|
@@ -109,16 +111,23 @@ def cmd(action, cmd, *args, **kwargs): | |
| stdin.seek(0) | ||
| kwargs["stdin"] = stdin | ||
|
|
||
| print(action, cmd, stdin_log) | ||
| print(action, cmd_arg, stdin_log) | ||
| try: | ||
| output = subprocess.check_output(cmd, *args, stderr=subprocess.STDOUT, **kwargs) | ||
| output = subprocess.check_output(cmd_arg, *args, stderr=subprocess.STDOUT, **kwargs) | ||
| print_output(output) | ||
| except subprocess.CalledProcessError as e: | ||
| print_output(e.output) | ||
|
|
||
| if num_retries > 0: | ||
| kwargs['num_retries'] = num_retries - 1 | ||
| kwargs['allow_failure'] = allow_failure | ||
| print("Retrying... %d remaining retries" % (num_retries - 1)) | ||
| return cmd(action, cmd_arg, *args, **kwargs) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably fine currently given max number of retries we specify, but would really be preferable to do this iteratively (which also doesn't require copying/mgmt of kwargs like this). |
||
|
|
||
| if allow_failure: | ||
| return | ||
|
|
||
|
|
||
| print("*************************************************") | ||
| print("*** First command failure occurred here. ***") | ||
| print("*** Will now try to clean up working state. ***") | ||
|
|
@@ -153,7 +162,7 @@ def regexReplace(path, pattern, replacement): | |
|
|
||
| def user_ok(msg): | ||
| ok = raw_input(msg) | ||
| return ok.lower() == 'y' | ||
| return ok.strip().lower() == 'y' | ||
|
|
||
| def sftp_mkdir(dir): | ||
| basedir, dirname = os.path.split(dir) | ||
|
|
@@ -628,7 +637,7 @@ def select_gpg_key(): | |
| sftp_cmds = """ | ||
| put %s %s | ||
| """ % (local_path, remote_path) | ||
| cmd("Uploading artifacts in %s to your Apache home directory" % root, "sftp -b - %s@home.apache.org" % apache_id, stdin=sftp_cmds) | ||
| cmd("Uploading artifacts in %s to your Apache home directory" % root, "sftp -b - %s@home.apache.org" % apache_id, stdin=sftp_cmds, num_retries=3) | ||
|
|
||
| with open(os.path.expanduser("~/.gradle/gradle.properties")) as f: | ||
| contents = f.read() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kinds of failures are we trying to mask here? Frequently retries also require delays between retries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a sleep in the new PR