Skip to content

Implement support for Volume components #237

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

Merged
merged 14 commits into from
Jan 21, 2021

Conversation

amisevsk
Copy link
Collaborator

@amisevsk amisevsk commented Jan 7, 2021

What does this PR do?

This PR is the first part of a (probably 3-part) series in removing remaining devfile 1.0 functionality from the controller.

It's a fairly significant departure in flow: the Component reconciler is disabled (and will be removed in the next PR). Instead we use libraries to resolve container and volume components directly. This changes how storage is provisioned for a workspace and makes it clearer where this happens (now: happens right after components are processed, as opposed to before, where it would happen during Deployment provisioning).

Note: Only flattened (i.e. no plugins, no parents) DevWorkspaces are supported as of this PR. This functionality will be re-added soon in a separate PR.

There are some TODOs left in the code, largely for tasks which are out of scope for now (they are labelled TODO#185 to reference the issue this PR closes), and TODOs on package docs for ambiguities in the devfile API spec; these reference issues in devfile/api where appropriate.

Short summary of changes

  • Add library functions for converting container components to k8s components (based largely off of the current adaptor code)
  • Add library functions for provisioning common PVC storage to a set of podAdditions based off volume components in a devfile
  • Add a shim library for re-generating ComponentDescriptions as required for che-rest-apis
  • Remove usage of our Component reconciler and disable support for plugins; use libraries instead. This means only flattened devfiles are supported for now
  • Add flattened samples to allow for testing (prefixed by flattened_*)
  • Add tests for library code (:tada: :tada: :tada:)
  • Fix TODO to only add storage + the storage finalizer when a workspace requires storage (we can now tell if persistent storage is needed)

The commit history should be fairly linear with self-explanatory commit messages; except for commit c6cbe19 which does some refactoring to better support kind of subtle mountSources functionality.

Next PRs will feature:

  1. Flattening functionality via a subcontroller, to re-enable support for plugins.
  2. Remove ComponentDescriptions from codebase, as they exist mostly to support Theia.
  3. A "storage provisioner" abstraction to allow for other potential storage setups (unique PVC, ephemeral only, etc.)

What issues does this PR fix or reference?

Closes #185

Is it tested? How?

Tested on minikube. Since this PR disables support for unflattened devfiles, new files are provided in the samples directory for testing (they are prefixed with flattened_).

@amisevsk
Copy link
Collaborator Author

amisevsk commented Jan 8, 2021

/retest

@sleshchenko
Copy link
Member

locally tests fail with error Error processing devfile: devfile is not flattened

@amisevsk
Copy link
Collaborator Author

locally tests fail with error Error processing devfile: devfile is not flattened

Fixed in fd0b0f1 -- forgot to update e2e tests to accomodate the changes :)

amisevsk added a commit to amisevsk/devworkspace-operator that referenced this pull request Jan 12, 2021
@amisevsk amisevsk mentioned this pull request Jan 12, 2021
3 tasks
Copy link
Contributor

@JPinkney JPinkney left a comment

Choose a reason for hiding this comment

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

LGTM, I also tried it out and everything seemed to be working as expected for me

Add tests for library code (:tada: :tada: :tada:)

🎉 🎉 🎉 🎉 🎉 🎉

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amisevsk, JPinkney

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

Nothing major is found in the code. Proceeding to testing.

@sleshchenko
Copy link
Member

sleshchenko commented Jan 15, 2021

  1. That's not really related to the current PR but I got devworkspace hanging in removing state, but if I get it, I see it's reported as Running. So, we should update state to probably something liek Terminating, before we run finalizers.
    Screenshot_20210115_130925
    Screenshot_20210115_130931
  2. I got ^ due RBAC roles caused local changes which appeared after I executed make test 🤯
diff --git a/config/components/rbac/role.yaml b/config/components/rbac/role.yaml
@@ -22,8 +22,6 @@ rules:
   - namespaces
   verbs:
   - get
-  - list
-  - watch

@amisevsk
Copy link
Collaborator Author

I got ^ due RBAC roles caused local changes which appeared after I executed make test exploding_head

I ran make manifests yesterday and noticed it removed a couple of roles -- I'll look into it, that shouldn't be happening.

@amisevsk
Copy link
Collaborator Author

@sleshchenko It looks like the RBAC issue came from commit a7db052 -- we add a couple of lines to role.yaml but not the annotations needed to generate them. I'll fixup.

@openshift-ci-robot
Copy link
Collaborator

New changes are detected. LGTM label has been removed.

@amisevsk
Copy link
Collaborator Author

amisevsk commented Jan 15, 2021

Commit c757a56 fixes the RBAC issue. I've also broken it out as a separate PR here: #246 in case we want to merge it separately. PR merged; I'll rebase this one before merging

@amisevsk amisevsk force-pushed the devfile-volumes branch 2 times, most recently from 5c6e94d to 993c1bf Compare January 15, 2021 19:54
amisevsk added a commit to amisevsk/devworkspace-operator that referenced this pull request Jan 15, 2021
amisevsk added a commit to amisevsk/devworkspace-operator that referenced this pull request Jan 15, 2021
@amisevsk
Copy link
Collaborator Author

/test v5-devworkspaces-operator-e2e

2 similar comments
@amisevsk
Copy link
Collaborator Author

/test v5-devworkspaces-operator-e2e

@amisevsk
Copy link
Collaborator Author

/test v5-devworkspaces-operator-e2e

@amisevsk
Copy link
Collaborator Author

Fixed tests and also cherry-picked commit 846689a from #240 to fix machine-exec (and web terminal)

@amisevsk
Copy link
Collaborator Author

/test v5-devworkspaces-operator-e2e

Move files in pkg/library to pkg/library/lifecycle to make adding more
library functions cleaner.

Signed-off-by: Angel Misevski <[email protected]>
Add library function GetKubeContainersFromDevfile to convert container
components in a flattened devfile into k8s Container objects.

Signed-off-by: Angel Misevski <[email protected]>
Add library function RewriteContainerVolumeMounts that converts
containers and initContainers VolumeMounts to use a common PVC.

Signed-off-by: Angel Misevski <[email protected]>
Add package pkg/library/shim which is used to reconstruct
ComponentMetadata as required by che-rest-apis (which is in turn
required by Che-Theia). This package is necessary as a shim between
purely devfile 2.0 devworkspaces and current devworkspaces, which use
devfile 1.0 concepts (plugin meta.yaml, Theia's dependence on Che
server, etc.).

Eventually this library should be deprecated.

Signed-off-by: Angel Misevski <[email protected]>
Replace usage of Component subresource with straight conversion of
devfile components to k8s objects. This commit disables support for
un-flattened devfiles (i.e. devfiles that contain parents or plugins).

For flattened devfiles, functionality is identical.

Signed-off-by: Angel Misevski <[email protected]>
- Add documentation to various methods as library functions deal with
more edge cases
- Split package pkg/library/container into multiple files for
readability
- Improve handling of mountSources to respect sourceMapping, correctly
define projects volume
- Improve common PVC provisioning to not add PVC if not needed

Signed-off-by: Angel Misevski <[email protected]>
- Only set storage finalizer on workspace if workspace needs storage as
defined by storage library
- Only generate and sync PVC if workspace needs storage

Signed-off-by: Angel Misevski <[email protected]>
Need to make sure we only add each exposed port once on a container

Signed-off-by: Angel Misevski <[email protected]>
This avoids an issue where a container can mount the projects volume
directly and have `mountSources: true`, which results in a duplicate
mount and invalid deployment.

Related to issue devfile/api#290 and how
projects volume should be handled with `mountSources`.

Signed-off-by: Angel Misevski <[email protected]>
Improve check for whether the volumeMount subpaths workaround is
required for a particular deployment. Previously, we only checked
whether any volumes were defined, which failed on OpenShift due to a
secret volume being in the list. Now we check to make sure the common
PVC volume is present in the deployment before applying the workaround.

Signed-off-by: Angel Misevski <[email protected]>
Machine exec depends on the CHE_MACHINE_NAME plugin to find the right
container to exec into. Add a function for populating env vars to the
shim library.

Signed-off-by: Angel Misevski <[email protected]>
@amisevsk
Copy link
Collaborator Author

/test v5-devworkspaces-operator-e2e

@amisevsk
Copy link
Collaborator Author

/retest

@amisevsk
Copy link
Collaborator Author

I've tested our usual flows on minikube and crc and haven't found any major defects. I'm merging this PR to unblock other issues; any problems that arise can be fixed in follow-up PRs.

@amisevsk amisevsk merged commit ea28204 into devfile:master Jan 21, 2021
@amisevsk amisevsk deleted the devfile-volumes branch January 21, 2021 22:00
@amisevsk amisevsk mentioned this pull request Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Volume component
4 participants