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

[Hold for Payment on July 22] OSBotify falsely marks pull requests as cherry-picks instead of standard deploys #3383

Closed
roryabraham opened this issue Jun 4, 2021 · 32 comments · Fixed by #3771
Assignees
Labels
Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@roryabraham
Copy link
Contributor

roryabraham commented Jun 4, 2021

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Ensure that the open StagingDeployCash checklist issue does not have the 🔐 LockCashDeploys 🔐 label.
  2. Merge a pull request.
  3. Once the staging deploy for that pull request has begun, add the 🔐 LockCashDeploys 🔐 label to the open StagingDeployCash

Expected Result:

Once the staging deploy for the pull request has completed, OSBotify should comment on the pull request saying that it was "Deployed to staging", with the normal table and such, like this:

image

Actual Result:

Once the staging deploy for the pull request has completed, OSBotify comments on the pull request saying that it was Cherry Picked to staging, like this:

image

Workaround:

Not applicable - it's just a misleading comment and doesn't affect app usability.

Platform:

Github only

Version Number: 1.0.63-0
Logs: https://github.com/Expensify/Expensify.cash/actions/runs/906930849

View all open jobs on Upwork

@roryabraham roryabraham added the External Added to denote the issue can be worked on by a contributor label Jun 4, 2021
@roryabraham roryabraham self-assigned this Jun 4, 2021
@MelvinBot
Copy link

Triggered auto assignment to @JmillsExpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@roryabraham
Copy link
Contributor Author

This can be worked on by an external contributor, but they'll need help from an Expensifier to test their PR.

@roryabraham
Copy link
Contributor Author

Ultimately this race condition is occurring because right here we are making the incorrect assumption that, when a staging deploy completes, if the StagingDeployCash is locked, then the PR that was deployed must have been cherry-picked.

There are a number of potential ways one could determine if the deploy was the result of a normal staging deploy vs a cherry-pick, and I'm not sure which is best. One idea would be to check if the StagingDeployCash was locked at the time the pull request was merged.

@roryabraham roryabraham changed the title OSBotify falsely marks pull requests as cherry-picks instead of standard deploys. OSBotify falsely marks pull requests as cherry-picks instead of standard deploys Jun 4, 2021
@JmillsExpensify
Copy link

Sorry @roryabraham I've been super busy with an internal project. Picking this one up tomorrow.

@roryabraham
Copy link
Contributor Author

No worries, this one is not that urgent.

@JmillsExpensify
Copy link

JmillsExpensify commented Jun 10, 2021

Done! Upwork job is here: https://www.upwork.com/jobs/~017e5b710bf91a779e

A note for contributors:

If you are interested in working on this issue, please post directly in this issue with a proposal with the technical explanation of the changes you will make. Somebody from Expensify will review your proposal, and if your proposal is accepted, you will be hired in Upwork for the job.

@JmillsExpensify
Copy link

Increased the payout on Upwork. Hopefully we'll get some proposals here soon!

@attaradev
Copy link
Contributor

@JmillsExpensify and @roryabraham I can investigate this.

@attaradev
Copy link
Contributor

My proposal

  • Create a separate job for checking the presence of the lock which will run first, and set that as the output value for the job
  • Pass the output value as the IS_CHERRY_PICK for the comment job

@roryabraham what do you think?

@roryabraham
Copy link
Contributor Author

@mikeattara When would this job execute?

@attaradev
Copy link
Contributor

attaradev commented Jun 25, 2021

I can start working on it immediately, @roryabraham

@roryabraham
Copy link
Contributor Author

Sorry @mikeattara, I don't think your proposed solution will work. Placing a separate job at the start of the platformDeploy.yml workflow won't resolve the race condition:

  1. Merge a PR, and preDeploy will begin.
  2. Then add the lock label
  3. By the time your separate job begins after the ~10-30 second startup time, the label will be present.

@parasharrajat
Copy link
Member

parasharrajat commented Jun 25, 2021

I am not sure about the cherry-picking concept here. What I understand so far is that in the following conditions a PR is CP.

  1. If CP staging label is present before PR is merged.
  2. As per the current issue, If we don't have the LockCashDeploys label on the StagingDeployCash issue.

So I can't think of any solution other than what you have posted above. So If we follow your solution then this would be achieved as below

  1. We get the StaginDeployCash using GithubUtils.getStagingDeployCash().
  2. Get a set of [added, removed] pairs for the LockCashDeploys label for StaginDeployCash using paginated https://octokit.github.io/rest.js/v18#issues-list-events.
  3. 1-2 will run as a single step where outPut will be the timeline set.
  4. Now inside the markPullRequestsAsDeployed we have to get each PR one by one to get their merged_at time using https://octokit.github.io/rest.js/v18#pulls-get.
  5. Now merged_at time comes between any of the [added, removed] pairs then we mark as CP, otherwise normal staging deploy.

For Pairs => [added, removed(if not present then take as now)]. We will be needing pagination https://octokit.github.io/rest.js/v18#pagination as well.

if you can post other possible solutions then I can find the optimal one out of those.

@roryabraham
Copy link
Contributor Author

@parasharrajat I think your solution would work well, with one modification:

  1. If the merged_at time comes between any of the [added, removed] pairs and the PR has the CP Staging label, then it was a CP. Otherwise it's a normal staging deploy.

@roryabraham
Copy link
Contributor Author

@parasharrajat Want to take on this issue and #3662 at the same time? 🙃 Since we need pagination for this, we might as well build a more general-purpose paginator for the GitHub API

@parasharrajat
Copy link
Member

1. If the `merged_at` time comes between any of the `[added, removed]` pairs **and the PR has the `CP Staging` label**, then it was a CP. Otherwise, it's a normal staging deploy.

Oh yeah. So I think I need to add one more step that is PR has a CP staging label before Pr was merged then Its CP.

@parasharrajat
Copy link
Member

But it seems that https://octokit.github.io/rest.js/v18#pagination this gives all the results autmatically. Let me read that issue and see what is required there.

@roryabraham
Copy link
Contributor Author

I need to add one more step that is PR has a CP staging label before Pr was merged then Its CP

Well, if a PR is merged with the CP Staging label when the StagingDeployCash is unlocked, then it goes through a regular staging deploy (just like any other E.cash PR that's merged when the StagingDeployCash is unlocked).

@parasharrajat
Copy link
Member

OK, then your point makes sense. I told you I am not yet fully familiar with CP flow. 😉

@roryabraham
Copy link
Contributor Author

@JmillsExpensify Let's get @parasharrajat hired for this on Upwork.

@JmillsExpensify
Copy link

Hired! Looks like we are testing the PR on the latest QA issue, so I'll make sure to pay you out as soon as that goes through as well! Or let me know if I've misunderstood the status!

@roryabraham
Copy link
Contributor Author

roryabraham commented Jul 8, 2021

As stated in the PR, this did cause a regression that will need to be fixed.

@roryabraham roryabraham reopened this Jul 8, 2021
@parasharrajat
Copy link
Member

@roryabraham Please update here if regression is fixed. Thanks.

@roryabraham
Copy link
Contributor Author

Hey @parasharrajat! The regression seems to have been fixed, but in order to really test if this issue is complete, we'll need to:

  1. Ensure that the open StagingDeployCash checklist issue does not have the 🔐 LockCashDeploys 🔐 label.
  2. Merge a pull request.
  3. Once the staging deploy for that pull request has begun, add the 🔐 LockCashDeploys 🔐 label to the open StagingDeployCash
  4. Wait for the staging deploy to finish, and verify that it gets a "deployed to staging" comment and not a "cherry-picked to staging" comment.

@roryabraham
Copy link
Contributor Author

@parasharrajat We can sync 1:1 and test that on the next open checklist?

@parasharrajat
Copy link
Member

Sure. Thanks

@roryabraham
Copy link
Contributor Author

Testing with #4096

@botify botify closed this as completed Jul 15, 2021
@roryabraham roryabraham reopened this Jul 15, 2021
@roryabraham
Copy link
Contributor Author

Reopening because there were some very weird and unrelated failures in the standard deploy from the dummy PR.

@roryabraham
Copy link
Contributor Author

The dominos are lined up. We just need to wait for this deploy to finish and then verify that this PR gets the "Deployed to staging" comment instead of "Cherry-picked to staging"

@roryabraham
Copy link
Contributor Author

QA passed, closing this out!

@JmillsExpensify JmillsExpensify changed the title OSBotify falsely marks pull requests as cherry-picks instead of standard deploys [Hold for Payment on July 22] OSBotify falsely marks pull requests as cherry-picks instead of standard deploys Jul 20, 2021
@parasharrajat
Copy link
Member

@JmillsExpensify Any update on Upwork? Thanks

@JmillsExpensify
Copy link

Yep! Closed out. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants