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

Fix prebuild lookup for prebuilds run in reverse-chronological order #20360

Merged
merged 10 commits into from
Nov 15, 2024

Conversation

filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Nov 12, 2024

Description

The following situation breaks Gitpod as it is today:

  1. A user commits two commits: A and B to main
  2. A user opens a workspace for B (the current head of main) and that triggers a prebuild
  3. A user opens a workspace for A (either by it being the head of another branch, or it being a directly opened commit). This in turn triggers a prebuild for A.
  4. A user tries to open main (commit B) again as a new workspace, but now the prebuild for A would get used, because it was created later than the one for B and therefore returned first from the DB.

How to test

See updates to DB tests.

/hold

@filiptronicek
Copy link
Member Author

Before merging, I will investigate if our assumption of "commits are ordered in descending chronological order" holds. This will entail going through API docs of our SCM providers

@geropl
Copy link
Member

geropl commented Nov 13, 2024

I had a closer look, and sadly something seems to be off about the test: If I undo the changes, it still works 😢

Update: I re-tested, and everything worked as expected. Not sure what went wrong yesterday; might have forgotten the yarn watch and testing outdated code 🤷

@filiptronicek
Copy link
Member Author

filiptronicek commented Nov 14, 2024

@geropl I've pushed f4eac6d (#20360), which does a bunch of things to simplify and more thoroughly explain the matching process. I would love to hear what you had in mind with the restructure, since after giving it some thought, I think this pattern of having a method returning a match is not too bad.

@geropl
Copy link
Member

geropl commented Nov 15, 2024

@filiptronicek Sorry for the confusion: I did not mean to argue against having a filter function, that certainly makes sense.

Also, I realized when looking at your solution, that my idea from yesterday did not make sense. 🙄

Synthesizing our approaches, I took the liberty to push 29e6aa6. Happy to sync on this! 👋

@filiptronicek
Copy link
Member Author

@geropl that filter function was a bit redundant anyway, since we check for commit overlap in isMatchForIncrementalBuild already.

I think these two should be identical, is there anything in particular that made you add the warning? Either way, we should definitely unify which one we use in the code.

// TODO(gpl) Isn't "candidateCtx.revision" identical to "candidatePrebuild.commit"? If yes, we could do .indexOf once...
if (candidateCtx.revision !== candidatePrebuild.commit) {
log.warn("Prebuild matching: commits mismatch!", { candidateCtx, candidatePrebuild });
}

@geropl
Copy link
Member

geropl commented Nov 15, 2024

I think these two should be identical

I think so, too, but am not 💯 sure I'm not missing sth. So going with the log, and a follow-up to remove it if it does not show up the next week. 👍

@geropl geropl force-pushed the ft/fix-mixed-up-prebuild-runs branch from 29e6aa6 to caa1f74 Compare November 15, 2024 09:11
@roboquat roboquat added size/XL and removed size/L labels Nov 15, 2024
Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Code LGTM, tests are green (+ looking great!): ✔️

@roboquat roboquat merged commit 2cd0670 into main Nov 15, 2024
17 checks passed
@roboquat roboquat deleted the ft/fix-mixed-up-prebuild-runs branch November 15, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants