-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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] retry if environmental issues #22662
Changes from 4 commits
098eb35
3a119ce
6c98a74
f0f885b
ebb6644
aa3a25e
4a4a15d
b11e00a
29404d9
e977e49
a7c74eb
446f840
3ea53ee
965d5e9
d018c7d
466d10d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,12 +260,28 @@ def k8sTest(Map args = [:]) { | |
} | ||
} | ||
|
||
/** | ||
* This method is a wrapper to run the runCommand method and retry if there are | ||
* environmental issues. Therefore it passes the arguments to the runCommand. | ||
* For further details regarding the arguments please refers to the runCommand method. | ||
*/ | ||
def target(Map args = [:]) { | ||
try { | ||
runCommand(args) | ||
} catch (err) { | ||
if(fileExists('environmental-issue')) { | ||
sleep 10 | ||
runCommand(args) | ||
} | ||
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. The file is not deleted explicitly, it is true that runCommand deletes the folder but it is weird/hiden. Also, there is no stop condition, what happens if a tool is no longer available for installation? I think that will enter on an infinite loop 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.
|
||
} | ||
} | ||
|
||
/** | ||
* This method runs the given command supporting two kind of scenarios: | ||
* - make -C <folder> then the dir(location) is not required, aka by disaling isMage: false | ||
* - mage then the dir(location) is required, aka by enabling isMage: true. | ||
*/ | ||
def target(Map args = [:]) { | ||
def runCommand(Map args = [:]) { | ||
def context = args.context | ||
def command = args.command | ||
def directory = args.get('directory', '') | ||
|
@@ -345,6 +361,7 @@ def withBeatsEnv(Map args = [:], Closure body) { | |
dockerLogin(secret: "${DOCKERELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") | ||
} | ||
dir("${env.BASE_DIR}") { | ||
def environmentalIssue = true | ||
installTools() | ||
if(isUnix()) { | ||
// TODO (2020-04-07): This is a work-around to fix the Beat generator tests. | ||
|
@@ -355,6 +372,8 @@ def withBeatsEnv(Map args = [:], Closure body) { | |
git config --global user.name "beatsmachine" | ||
fi''') | ||
} | ||
// Pre-requisites to configure the environment were ok. | ||
environmentalIssue = false | ||
// Skip to upload the generated files by default. | ||
def upload = false | ||
try { | ||
|
@@ -371,14 +390,17 @@ def withBeatsEnv(Map args = [:], Closure body) { | |
upload = true | ||
error("Error '${err.toString()}'") | ||
} finally { | ||
if (archive) { | ||
if (archive && !environmentalIssue) { | ||
archiveTestOutput(testResults: testResults, artifacts: artifacts, id: args.id, upload: upload) | ||
} | ||
// Tear down the setup for the permamnent workers. | ||
// Tear down the setup for the permanent workers. | ||
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { | ||
fixPermissions("${WORKSPACE}") | ||
deleteDir() | ||
} | ||
if (environmentalIssue) { | ||
writeFile file: 'environmental-issue', text: 'environmental-issue' | ||
} | ||
} | ||
} | ||
} | ||
|
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 do think about a more descriptive name? I acknowledge references should be updated.
Alternatives?
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.
I was not intended to change the name at first, though it might be worth to add more clarity.
What do you think
runCommandWithRetry
?