Skip to content

deployed-labeler: improve error handling, add GET endpoint #86

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 6 commits into from
Dec 7, 2022

Conversation

adrienthebo
Copy link
Contributor

Description

deployed-labeler: bump commit limit to 5 pages, 100 results


deployed-labeler: emit error messages from /deployed endpoint

This commit generates user readable error messages when the /deployed endpoint is called without required parameters.


deployed-labeler: expose log level CLI option, adjust log levels


deployed-labeler: add GET handler for deployed to indicate label status


deployed-labeler: serialise errors as strings

per golang/go#5161 serializing an error object to json emits an empty object; this caused deployed-labeler to emit an empty object when erroring. This commit converts all errors to strings before returning to the user to provide more context.

Related Issue(s)

How to test

Test error handling

  1. Create a malformed GitHub key
  2. Run curl "http://localhost:8080/deployed?commit=470062367333b5d9992188dbc9ff89465c0ab1e3&team=workspace"
  3. verify that an error is emitted and returned to the user.

Test status endpoint

  1. Remove the deployed labels from Log JSON as strings not an array of bytes gitpod#14215
  2. run curl "http://localhost:8080/deployed?commit=470062367333b5d9992188dbc9ff89465c0ab1e3&team=workspace"
  3. confirm that the correct PR is listed as unlabeled

Release Notes

Documentation

This commit generates user readable error messages when the /deployed endpoint is called without required parameters.
@roboquat
Copy link

roboquat commented Nov 3, 2022

@adrienthebo: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@werft-gitpod-dev-com
Copy link

cannot start job - please talk to whoever's in charge of your Werft installation

Copy link
Contributor

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Really nice addition of the GET endpoint! I can see that helping us a lot when debugging failures 🙂

I've made just a few suggestions about go

Comment on lines 107 to 112
var preconditionFailed struct {
Errors []string
}

preconditionFailed.Errors = make([]string, 0, 1)
preconditionFailed.Errors = append(preconditionFailed.Errors, fmt.Sprintf("team and commit are required parameters. Team: '%v', commit: '%v'", team, commitSHA))
Copy link
Contributor

Choose a reason for hiding this comment

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

What was your goal in creating a new type to store the error?

Could we use standard error libs? Maybe errors would make more sense here

Copy link
Contributor

Choose a reason for hiding this comment

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

What was your goal in creating a new type to store the error?

The PR mention's per golang/go#5161 serializing an error object to json emits an empty object; this caused deployed-labeler to emit an empty object when erroring. This commit converts all errors to strings before returning to the user to provide more context.

Seems to be serialisation and making sure the errors are returned in the HTTP response. 🤔

Copy link
Contributor

@Pothulapati Pothulapati Dec 5, 2022

Choose a reason for hiding this comment

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

Update! New err type is not required. Rolled it back to error

This won't render internal gh errors i.e when a malformed token is used. We get an empty errors field which @adrienthebo was trying to fix.

Example

{
  "deployedPRs": {
    "team": null,
    "all": null
  },
  "errors": [
    "non-200 OK status code: 401 Unauthorized body: \"{\\\"message\\\":\\\"Bad credentials\\\",\\\"documentation_url\\\":\\\"https://docs.github.com/graphql\\\"}\""
  ]
}

@adrienthebo
Copy link
Contributor Author

adrienthebo commented Nov 4, 2022

@ArthurSens thanks for the detailed review! This PR was the result of a bunch of fairly blind hacking and stumbling around Go's error handling; a lot of decisions were based on "well, it compiles, so good enough!" I'll run through and address your comments and do another round of general cleanup and will follow up with you on another review - likely on Monday since it's Friday night your time, but perhaps tonight if you're burning the weekend oil. 😊 No rush!

@kylos101 kylos101 requested a review from a team November 30, 2022 18:08
@kylos101
Copy link
Contributor

Hi @gitpod-io/engineering-delivery-operations-experience it looks like this is caught in limbo, so I added you all back as a reviewer.

@liam-j-bennett
Copy link

@kylos101 @adrienthebo This work also might have gotten caught up in the changes in the team structure (i.e. Scout Team). Could this work be handed off?

@kylos101
Copy link
Contributor

kylos101 commented Dec 2, 2022

@kylos101 @adrienthebo This work also might have gotten caught up in the changes in the team structure (i.e. Scout Team). Could this work be handed off?

Hey @liam-j-bennett 👋 we discussed with @meysholdt and @corneliusludmann during the platform/self-hosted to devx/delivery transformation, and my understanding is that Delivery Team owns the labeling component.

Is it in the list of Delivery owned components? Perhaps something changed since then? cc: @corneliusludmann

@corneliusludmann
Copy link

corneliusludmann commented Dec 2, 2022

Is it in the list of Delivery owned components? Perhaps something changed since then?

No, nothing has changed. I think @liam-j-bennett's comment was about Adrien being busy with scout team work and not in the position to continue this and should be handed over to someone else from the delivery team.

I removed Adrien from the corresponding issue https://github.com/gitpod-io/ops/issues/6409 and put it back to “Scheduled” so that someone else can pick this up soon.

@Pothulapati
Copy link
Contributor

Pothulapati commented Dec 5, 2022

Now that the PR compiles, Testing this PR now. 👀

@Pothulapati Pothulapati force-pushed the alt/deployed-labeler/error-handling branch 2 times, most recently from 2192857 to 41521d1 Compare December 5, 2022 11:20
@Pothulapati Pothulapati self-assigned this Dec 5, 2022
@Pothulapati Pothulapati force-pushed the alt/deployed-labeler/error-handling branch from 41521d1 to be466da Compare December 5, 2022 11:35
@Pothulapati
Copy link
Contributor

Update, Now that the changes work:

The move from Error to String for returning errors seem to be necessary to handle Internal API errors that Github Client returns. This is useful when there is a malfunctioning token that is passed, etc.

{
  "deployedPRs": {
    "team": null,
    "all": null
  },
  "errors": [
    "non-200 OK status code: 401 Unauthorized body: \"{\\\"message\\\":\\\"Bad credentials\\\",\\\"documentation_url\\\":\\\"https://docs.github.com/graphql\\\"}\""
  ]
}

@Pothulapati Pothulapati force-pushed the alt/deployed-labeler/error-handling branch from be466da to 5a51b9a Compare December 5, 2022 11:50
per golang/go#5161 serializing an `error` object to json emits an empty object; this caused deployed-labeler to emit an empty object when erroring. This commit converts all errors to strings before returning to the user to provide more context.

Signed-off-by: Tarun Pothulapati <[email protected]>
@Pothulapati Pothulapati force-pushed the alt/deployed-labeler/error-handling branch from 5a51b9a to 11b2df5 Compare December 5, 2022 11:55
@Pothulapati
Copy link
Contributor

Pothulapati commented Dec 5, 2022

PR is now ready to review! Cleaned up commit messages by rebasing things. 👍🏼

@Pothulapati
Copy link
Contributor

@ArthurSens Just to confirm before proceeding, The deployment process is manual as per thereadme doc right? :)

@ArthurSens
Copy link
Contributor

ArthurSens commented Dec 6, 2022

@ArthurSens Just to confirm before proceeding, The deployment process is manual as per thereadme doc right? :)

It has been a long time since I did anything here, but I believe it still the same process 😅

@roboquat roboquat merged commit 3bb1445 into main Dec 7, 2022
@roboquat roboquat deleted the alt/deployed-labeler/error-handling branch December 7, 2022 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants