Description
Bug description
Incremental Prebuilds (Beta) fails for Projects which have repo that contains private submodules.
This happens when the submodules are update in the repo. The subsequent prebuild fails while trying to update the submodules.
Error
Error looks similar to these
Example 1
When you start a workspace, it triggers a prebuild which results in the following error:
Oh, no! Something went wrong!
cannot initialize workspace: cannot initialize
workspace: prebuild initializer: git fetch -p -P .
tags -f failed (exit status 1): From
https://github.com/x/x-mean +
5096db13…b6a9d685 tests/y
-
origin/tests/y (forced update) Fetching
submodule a/b No user exists for uid
133332 fatal: Could not read from remote
repository. Please make sure you have the correct
access rights and the repository exists. No user
exists for id 133332 fatal: Could not read from
remote repository. Please make sure you have the
correct access rights and the repository exists.
Errors during submodule fetch: a/b
a/b
Example 2
No user exists for uid 133332
fatal: Could not read from remote repository.
Please make sure you have the correct access right and the repository exists.
Example 3
On the prebuild page of the project.
Prebuild failed for system reasons. Please contact support. cannot initialize workspace: cannot initialize workspace: prebuild initializer: git fetch -p -P --tags -f failed (exit status 1): From https://github.com/princerachit/pub 9383449..529e501 main -> origin/main * [new branch] newbranch1 - ...
Workaround
Since this problem is specific to Incremental Prebuilds as workaround we suggest users to do the following until we fix this issue.
- Disable Incremental Prebuilds permanently
- Trigger a new Prebuild on on your branch
Above seems to work for most cases but recently we encountered a customer who disabled prebuild but could still see the issue: internal slack thread
Please let us know if this workaround does not help.
Steps to reproduce
- Create a repo (
pub
) which has a private repo git submodule (hidden
) - Create an ssh key from an account which has access to
hidden
- Encode the ssh key and set into your project environment variable. e.g.
cat id_rsa | base64
- Update your
.gitpod.yml
so that it uses that key to initializepub
's submodules in prebuild- ref - Create a project from this
pub
repo and enable incremental prebuilds - Add new commits to the submodule repo
- Now create a branch
b1
frompub
repo and push it to GH. Let the prebuild run and finish. - Update a few files locally (other than .gitpod.yml) and then also update the submodule to the HEAD in branch
b1
e.g.cd hidden && GIT_SSH_COMMAND="ssh -i ../idkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git pull origin main
- Commit the change
git add -u && git commit -m "changes"
- Push the change
git push
- Navigate to the prebuild running on
b1
branch. Prebuild should be failing.
e.g. Refer to the prebuild url here and logs (This is not accessible to public)
Workspace affected
Several prebuilds have been affected resulting in workspace failure.
To find the current number of failed prebuilds by their repo run the following command:
SELECT
cloneURL,COUNT(*)
FROM
d_b_prebuilt_workspace
WHERE
error LIKE '%prebuild initializer: git fetch -p -P%'
and creationTime > '2022-02-13 08:56:44.752194'
GROUP BY cloneURL;
Expected behavior
Prebuilds should work without any issue.
Example repository
https://github.com/princerachit/pub
Anything else?
No response
Root cause
During incremental prebuild snapshost is downloaded and then the local repo is updated.
The snapshot contains the hidden submodule which was initialized during last successful prebuild.
When the git fetch -p -P --tags
command is run git finds that there was an update in the hidden submodule's sha reference. It then tries to update the submodule. Since we preserve the userid/gid (133332 which is missing in the init container) mapping when untarring the snapshot, the git command complains about the user not exisiting.
Even after creating this user manually the prebuild fails as the ssh-key required to fetch this submodule does not exists in the content-init container.
Plan to Resolve
- Try Reproducing the Error
- Triage the code responsible for the issue
- Figure out possible fixes - This issue will be fixed with the migration to PVC based storage where the git command will be run in the workspace container context. The work for PVC is under progress and being tracked in previous link. See internal thread.
- Test fixes