-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[pvc] fix prebuilds when using pvc #12746
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
Conversation
/werft build 👎 unknown command: build |
/werft run 👍 started the job as gitpod-build-pavel-12464.3 |
// version of this function for persistent volume claim feature | ||
// we cannot use /workspace folder as when mounting /workspace folder through PVC | ||
// it will mask anything that was in container layer, hence we are using /.workspace instead here | ||
func contentDescriptorToLayerPVC(cdesc []byte) (*Layer, error) { | ||
layers := []fileInLayer{ | ||
{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil}, | ||
{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace/.gitpod", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil}, | ||
{&tar.Header{Typeflag: tar.TypeReg, Name: "/.workspace/.gitpod/pvc", Uid: 0, Gid: 0, Mode: 0775, Size: int64(len(pvcEnabledFile))}, []byte(pvcEnabledFile)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows us to reliably check in supervisor if workspace is using pvc or not, instead of relying on content.json being present, which is not the case everytime (restoring from prebuild will not generate any content.json for example).
return layerFromContent( | ||
fileInLayer{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil}, | ||
fileInLayer{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace/.gitpod", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil}, | ||
fileInLayer{&tar.Header{Typeflag: tar.TypeReg, Name: "/.workspace/.gitpod/ready", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755, Size: int64(len(ctnt))}, []byte(ctnt)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows us to place ready file.
why we cannot use /workspace
folder? because when using pvc that folder is masked by pvc.
also, on top of that, when restoring from prebuild for example, prebuild volume snapshot will contain ready file in there from the time when prebuild was generated.
so this allows us to completely separate pvc and non pvc approach.
fn = "/.workspace/.gitpod/content.json" | ||
log.Info("Detected content.json in /.workspace folder, assuming PVC feature enabled") | ||
fnReady = "/.workspace/.gitpod/ready" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to wait for ready file that comes from PVC layer, we should not use ready file that comes from /workspace
since that file will be backed up into volume snapshot when it is created from pvc.
so this makes a clear separation between pvc and non-pvc code path.
c2eb066
to
4a9ed32
Compare
@kylos101 |
started the job as gitpod-build-pavel-12464.14 because the annotations in the pull request description changed |
4a9ed32
to
c0ea488
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have verified it, it works like a charm.
@@ -287,8 +295,12 @@ func (s *Provider) GetContentLayerPVC(ctx context.Context, owner, workspaceID st | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
layerReady, err := workspaceReadyLayerPVC(csapi.WorkspaceInitFromOther) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't know what is the correct WorkspaceInitSource
for the snapshot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I test the snapshot without the PVC feature flag. The content within read
file is {"source":"from-backup"}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it matters that much if it is from backup or from other, but for consistency, updated to match. ❤️
c0ea488
to
54fecf9
Compare
/werft run with-preview 👍 started the job as gitpod-build-pavel-12464.17 |
/werft run with-preview with-clean-slate-deployment 👍 started the job as gitpod-build-pavel-12464.18 |
/werft run with-clean-slate-deployment 👍 started the job as gitpod-build-pavel-12464.19 |
/werft run 👍 started the job as gitpod-build-pavel-12464.20 |
started the job as gitpod-build-pavel-12464.21 because the annotations in the pull request description changed |
/werft run 👍 started the job as gitpod-build-pavel-12464.22 |
The werft finally happy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, i have not tried, rely on @pavel review
it seems that changes to supervisor are backward compatible
/hold
unhold when you comfortable to merge
/unhold |
Description
First, kudos to @jenting for catching this issue. ❤️
What was happening is actually when using pvc and prebuilds, it would not know that workspace was open from prebuild, rendering prebuild useless (as it would do all the work that prebuild already done).
This PR fixes this.
Related Issue(s)
Fixes #12464
How to test
Open regular workspace
Open PVC regular workspace
Open regular prebuild
Open PVC prebuild
Release Notes
Documentation
Werft options: