Skip to content

Add invalid job case & improve error handling in check-for-build #1590

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

Merged
merged 2 commits into from
Feb 3, 2022

Conversation

ohltyler
Copy link
Member

@ohltyler ohltyler commented Feb 3, 2022

Signed-off-by: Tyler Ohlsen [email protected]

Description

Adds a check for handling invalid jobs passed. Properly fails the job if there is any failure seen in the build or uploading steps. Follow-up to #1585

Sanity test with job name distribution-build-invalid (Jenkins job Playground/ohltyler-check-for-build-2 #3):

ERROR: Job invalid-job is invalid

Issues Resolved

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@ohltyler ohltyler requested a review from a team as a code owner February 3, 2022 17:28
@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2022

Codecov Report

Merging #1590 (1a7ecab) into main (6c54533) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #1590   +/-   ##
=========================================
  Coverage     94.63%   94.63%           
  Complexity       13       13           
=========================================
  Files           153      153           
  Lines          3281     3281           
  Branches         21       21           
=========================================
  Hits           3105     3105           
  Misses          173      173           
  Partials          3        3           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 484f6bc...1a7ecab. Read the comment docs.

@@ -81,6 +82,8 @@ pipeline {
build job: "${TARGET_JOB_NAME}", parameters: [
string(name: 'INPUT_MANIFEST', value: "${INPUT_MANIFEST}")
], wait: true
} else {
throw new Exception("Job ${TARGET_JOB_NAME} is not a valid option")
Copy link
Member

Choose a reason for hiding this comment

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

Use error doc to make sure the build is marked a failure. I am not a fan of exceptions as standard flow of control mechanism.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in latest commit by checking the job name matches the 2 currently-supported jobs (distribution-build-opensearch, distribution-build-opensearch-dashboards

@@ -89,6 +92,7 @@ pipeline {
)
} catch (err) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove this catch block, its just swallowing errors that should be failing the build

Copy link
Member

Choose a reason for hiding this comment

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

+1 here. I think the exceptions threw above will be caught here and won't fail the job.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch - I was adding on to existing code but see this would silently fail. Removed in latest commit.

Comment on lines 74 to 75
// TEST_MANIFEST param isn't applicable for distribution-build-opensearch-dashboards job yet,
// so we don't pass it to that job to prevent confusion from Jenkins UI
Copy link
Member

Choose a reason for hiding this comment

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

Could we just add the param (and not use it) to that job and avoid the error entirely?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed if/else logic, and passing the same params regardless of job.

@ohltyler ohltyler changed the title Add invalid job case in check-for-build Add invalid job case & improve error handling in check-for-build Feb 3, 2022
@peternied peternied merged commit 84c160e into opensearch-project:main Feb 3, 2022
peterzhuamazon pushed a commit to peterzhuamazon/opensearch-build that referenced this pull request Feb 16, 2022
…nsearch-project#1590)

* Add invalid job case in check-for-build
* Remove catch block; pass TEST_MANIFEST for all jobs

Signed-off-by: Tyler Ohlsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants