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

feat: persistent user home documentation #2822

Merged
merged 10 commits into from
Dec 3, 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions modules/administration-guide/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
*** xref:configuring-storage-classes.adoc[]
*** xref:configuring-the-storage-strategy.adoc[]
*** xref:configuring-storage-sizes.adoc[]
*** xref:about-persistent-user-home.adoc[]
** xref:configuring-dashboard.adoc[]
*** xref:configuring-getting-started-samples.adoc[]
*** xref:configuring-editors-definitions.adoc[]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
:_content-type: CONCEPT
:description: About persistent user home
:keywords: administration guide, about, {prod-id-short}, persistent, user, home
:navtitle: About persistent user home
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved
:page-aliases:

[id="about-persistent-user-home"]
= About persistent user home
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved


{prod} provides a persistent home directory feature that allows each non-ephemeral workspace to have their `/home/user` directory be persisted across workspace restarts.
This feature can be enabled in the CheCluster by setting `spec.devEnvironments.persistUserHome.enabled` to `true`.
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

For newly started workspaces, this feature creates a PVC mounted to the `/home/user` path of the tools container.
In this documentation, a "tools container" will be used to refer to the first container in the devfile.
This container is the container that includes the project source code by default.

When the PVC is mounted for the first time, the persistent volume contents are empty and therefore must be populated with the `/home/user` folder content.
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

By default, the `persistUserHome` feature creates an init container for each new workspace pod named `init-persistent-home`.
This init container is created with the tools container image and is responsible for running a `stow` command to create symbolic links
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved
in the persistent volume to populate the `/home/user` folder.
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

The primary function of the `stow` command is to run:
[subs="+quotes,attributes"]
----
stow -t /home/user/ -d /home/tooling/ --no-folding
----

The command above creates symbolic links in `/home/user` for files and folders located in /home/tooling. This populates the persistent volume with symbolic links to the content in /home/tooling. As a result, it the `persistentUserHome` feature expects the tooling image to have it's `/home/user/` content within `/home/tooling`.
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

For example, if the tools container image contains files in the `home/tooling` folder such as `.config` and `.config-folder/another-file`, stow will create symbolic links in the persistent volume in the following manner:

.Tools container with `persistUserHome` enabled
image::persistent-user-home/tools-container-example.png[Persistent user home example scenario]

The init container writes the output of the `stow` command to `/home/user/.stow.log` and will only run `stow` the first time the PVC is mounted to the workspace.
Copy link
Contributor

Choose a reason for hiding this comment

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

Technical nitpick: Isin't the stow command run only the first time when the workspace is started up? When aa workspace pod gets terminated (if the workspace shuts down) won't it unmount to the PVC and then get mounted again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, what I mean is it runs the first time it's mounted, in the second/third/fourth workspace starts, it's the second/third/fourth time it's mounted, so it doesn't run.

Is the wording is a bit unclear?

In my latest commit, I've updated it to:

The init container writes the output of the `stow` command to `/home/user/.stow.log`
and will only run `stow` the first time the persistent volume is mounted to the workspace. 


Using the `stow` command to populate `/home/user` content in the persistent volume provides two main advantages.
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

1. Creating symbolic links is faster than creating copies of the `/home/user` folder content in the persistent volume. To put it differently, the persistent volume in this case contains symbolic links and not the actual files themselves.
2. If the tools image is updated with newer versions of existing binaries, configs, and files, the init container does not need to `stow` the new versions, as the existing symbolic links will link to the newer versions in `/home/tooling` already.
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

== Requirements for the tools image
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

The `persistUserHome` depends on the tools image used for the workspace. By default {prod-short} uses the Universal Developer Image (UDI) for sample workspaces, which supports `persistUserHome` out of the box.

If you are using a custom image, there are three requirements that should be met to support the `persistUserHome` feature.

1. The tools image should contain `stow` version 2.4.0.
2. The home directory should be `/home/user`.
3. In the tools image, the directory that contains the `/home/user` content is `/home/tooling`.
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

Due to requirement three, the default UDI image for example adds the `/home/user` content to `/home/tooling` instead, and runs:

[subs="+quotes,attributes"]
----
RUN stow -t /home/user/ -d /home/tooling/ --no-folding
----

in the Dockerfile so that `/home/tooling` is accessible from `/home/user` even when not using the `persistUserHome` feature.
dkwon17 marked this conversation as resolved.
Show resolved Hide resolved

Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

* xref:configuring-storage-classes.adoc[]
* xref:configuring-the-storage-strategy.adoc[]
* xref:configuring-storage-sizes.adoc[]
* xref:configuring-storage-sizes.adoc[]
* xref:about-persistent-user-home.adoc[]
Loading