Adding support of the ephemeral workspaces (using emptyDir volume instead of PVC) via 'persistVolumes' attribute#11343
Conversation
…tead of PVC) via 'mountSources' attribute Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
|
@garagatyi @sleshchenko PR is still WIP and missing tests / docs, but I just want to make sure that you are ok with the overall approach. |
…PVCCleaner Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
| String machineName = Names.machineName(pod, container); | ||
| InternalMachineConfig machineConfig = k8sEnv.getMachines().get(machineName); | ||
| addMachineVolumes(workspaceId, subPaths, pod, container, machineConfig.getVolumes()); | ||
| if (ephemeralWorkspaceAdapter.isEphemeral(workspaceId)) { |
There was a problem hiding this comment.
Changing code like that shows a big diff I would say. Can you just:
if (ephemeralWorkspaceAdapter.isEphemeral(workspaceId)) {
ephemeralWorkspaceAdapter.provision(k8sEnv, identity);
return;
}?
| } | ||
| if (preCreateDirs && subpaths != null) { | ||
| pvcSubPathHelper.createDirs(workspaceId, subpaths); | ||
| if (!ephemeralWorkspaceAdapter.isEphemeral(workspaceId)) { |
| final String workspaceId = event.getWorkspace().getId(); | ||
| try { | ||
| strategy.cleanup(workspaceId); | ||
| if (!isEphemeral(event.getWorkspace())) { |
There was a problem hiding this comment.
Would be better to move this logic to the strategy to avoid splitting it between components.
There was a problem hiding this comment.
@garagatyi do you think it would be acceptable to change strategy interface e.g. void cleanup(Workspace workspace) throws InfrastructureException; in order to get the whole workspace config directly in strategies ?
| } | ||
|
|
||
| private String getSubPath(String workspaceId, String volumeName, String machineName) { | ||
| // logs must be located inside the folder related to the machine because few machines can |
There was a problem hiding this comment.
It seems that a lot of code is inspired by strategies code. Would be nice to reuse the code if possible.
There was a problem hiding this comment.
you are right, but reusing strategies code might be not really straight-forward
There was a problem hiding this comment.
Then let's go with a simpler approach. Time will show whether we would need to refactor that later
…ntSources' attribute Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
emptyDir volume instead of PVC) via 'mountSources' attributeemptyDir volume instead of PVC) via 'mountSources' attribute
|
ci-test |
|
Results of automated E2E tests of Eclipse Che Multiuser on OCP: |
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
|
ci-test |
|
Results of automated E2E tests of Eclipse Che Multiuser on OCP: |
| */ | ||
| public boolean isEphemeral(String workspaceId) throws InternalInfrastructureException { | ||
| try { | ||
| WorkspaceImpl workspace = workspaceManager.getWorkspace(workspaceId); |
There was a problem hiding this comment.
We can actually avoid using WorkspaceMnaager here since we can pass WorkspaceConfig attributes here. And we can get them from Workspace object or K8s environment object. I'm not sure we really need that but would want to hear about that from @sleshchenko @ibuziuk . This doesn't block the PR.
There was a problem hiding this comment.
when I tested PR on minishift for some reason K8s environment does not seem to contain WorkspaceConfig attributes, so I had to use WorkspaceManager instead
There was a problem hiding this comment.
@ibuziuk I think it should be considered it as a bug because it must be there https://github.com/eclipse/che/blob/27bed82d5c57dc0c95093a1cea6043cfa47877f1/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceRuntimes.java#L740
Otherwise, WorkspaceNext won't be working on Kubernetes infra. And three weeks ago I tested it and it worked.
There was a problem hiding this comment.
@sleshchenko I will re-test and provide a comment about it. AFAIK k8sEnv.getAttributes() always returned emptyMap for me
`
There was a problem hiding this comment.
ok, seems I was wrong and all the config attributes are actually located in k8sEnv.getAttributes()
I will remove the usage of WorkspaceMnaager. Thanks for noticing
There was a problem hiding this comment.
done, WorkspaceMnaager usage has been removed from PR
sleshchenko
left a comment
There was a problem hiding this comment.
In general LGTM
Please take a look my inlined comments
| */ | ||
| @Singleton | ||
| public class EphemeralWorkspaceAdapter { | ||
| private final String EPHEMERAL_VOLUME_NAME_PREFIX = "ephemeral-che-workspace-"; |
| * PVC strategies</a> | ||
| * @see <a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir">emptyDir</a> | ||
| */ | ||
| public static final String MOUNT_SOURCES_ATTRIBUTE = "mountSources"; |
There was a problem hiding this comment.
-
Just interesting to know, is there similar functionality for Docker infrastructure?
-
Does
sourcesmean source code here? If yes, then actually it is related not to sources only but to all workspaces volumes, like maven repository may be declared by a user. Maybe it makes sense to choose another name for this attribute that won't be source related by that will indicate non-persistent volumes.
There was a problem hiding this comment.
-
I was not able to find anything similar for docker infra.
VolumesConverterjust grabs all the volumes from workspace config and adds them to container config. -
yeah, this is a good point. Maybe
persistVolumeswould be a better option ? @l0rd @garagatyi wdyt ?
There was a problem hiding this comment.
- I think we don't have to support this in Docker infra. It can be implemented later in case it would be needed.
persistVolumeslooks good to me
There was a problem hiding this comment.
@sleshchenko attribute has been renamed to persistVolumes
| return isEphemeral(workspace); | ||
| } catch (NotFoundException | ServerException e) { | ||
| throw new InternalInfrastructureException( | ||
| "Failed to load workspace info" + e.getMessage(), e); |
There was a problem hiding this comment.
Your message and message from exception will be merged. Consider adding space or another separator.
| * this case regardless of the PVC strategy, workspace volumes would be created as `emptyDir`. | ||
| * When a workspace Pod is removed for any reason, the data in the `emptyDir` volume is | ||
| * deleted forever | ||
| * @throws InternalInfrastructureException |
There was a problem hiding this comment.
Actually this exception can not be thrown here
…ests Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
…aceManager. Renaming atribute to 'persistVolumes' Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
emptyDir volume instead of PVC) via 'mountSources' attributeemptyDir volume instead of PVC) via 'persistVolumes' attribute
|
ci-test |
amisevsk
left a comment
There was a problem hiding this comment.
Great work! Looks good to me, but I have one question:
Since the persistVolumes attribute is mutable (i.e. I can start a workspace with bound volume and then later modify the config), how does this interact with workspace deletion? What's the UX if e.g. we create a workspace with persistVolumes true, do some work, set it to false, restart the workspace?
What will happen if I delete a workspace that is ephemeral? We currently don't do anything if the clean up job fails but ideally in the future we would work to ensure the PVC is cleaned up. I suppose this is more an issue with cleanup though.
|
@amisevsk yeah, good point. Currently there are no checks for such scenarios during cleanup. Basically, if workspace is ephmeral no pvc cleanup is performed, even if it was originally non-ephemeral. However, I believe the main usage of the ephemeral workspaces would be when the |
|
@amisevsk Really good point 👍
it's OK for me to leave it as it is for now. But: |
|
Results of automated E2E tests of Eclipse Che Multiuser on OCP: |
|
@sleshchenko I'm mostly worried about the common strategy since rm pod which mounts PVC would be still created and since the main goal of the ephemeral workspaces is to avoid volume mount problems always cleaning PVC would potentially bring more problems than benefits. But let me create a separate issue for the PVC cleanup situation. |
|
We should document how to configure an ephemeral workspaces in https://www.eclipse.org/che/docs/ |
|
@sleshchenko @amisevsk I have created a separate issue to start the cleanup discussion - #11391 |
…nstead of PVC) via 'persistVolumes' attribute (eclipse-che#11343) che eclipse-che#11350 Adding support of the ephemeral workspaces (using emptyDir volume instead of PVC) via 'persistVolumes' attribute Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
What does this PR do?
Adding support of the ephemeral workspaces (using
emptyDirvolume instead of PVC) viamountSourcesattribute. OncepersistVolumesattribute is set tofalseall workspace volumes would be created not according to the defined asemptyDirs:What issues does this PR fix or reference?
#11350
redhat-developer/rh-che#860
WIP
Release Notes
WIP
Docs PR
WIP