-
Notifications
You must be signed in to change notification settings - Fork 63
feat: Allow external DWOC to be merged with internal DWOC on a per-workspace basis #909
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
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: AObuchow The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
883c8d0
to
4ea4873
Compare
fcfe74f
to
b3ccdad
Compare
09866b8
to
09f8406
Compare
@amisevsk Though you are free to take an early look (e.g. checking out the TODO comments), this PR is unfortunately still in progress. I still need to add some tests, document some stuff and try and make the commit history a bit cleaner. |
7a796ee
to
592b788
Compare
Use config from workspaceWithConfig instead of global config (almost) everywhere Signed-off-by: Andrew Obuchowicz <[email protected]>
Allow specifying an external DWOC that gets merged with the workspace's internal DWOC. The external DWOC's name and namespace are specified with the `controller.devfile.io/devworkspace-config` DevWorkspace attribute, which has the following structure: attributes: controller.devfile.io/devworkspace-config: name: <string> namespace: <string> Part of eclipse-che/che#21405 Signed-off-by: Andrew Obuchowicz <[email protected]>
…lver to get config from annotations Signed-off-by: Andrew Obuchowicz <[email protected]>
Signed-off-by: Andrew Obuchowicz <[email protected]>
Signed-off-by: Andrew Obuchowicz <[email protected]>
Signed-off-by: Andrew Obuchowicz <[email protected]>
Signed-off-by: Andrew Obuchowicz <[email protected]>
592b788
to
e8f8040
Compare
The git history is unfortunately still very messy, so it might be better to review this PR as a whole (as difficult as that may be, due to the number of files modified in this PR :/ ) |
e8f8040
to
250c77e
Compare
@amisevsk Should I make note of the new attribute in the additional configuration documentation? Or do we want to keep this as an internal/undocumented feature for the time being, seeing as it was intended for a specific use case (che)? |
Signed-off-by: Andrew Obuchowicz <[email protected]>
250c77e
to
0a68b02
Compare
controllers/controller/devworkspacerouting/solvers/basic_solver.go
Outdated
Show resolved
Hide resolved
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.
First pass at reviewing. Looking okay so far but I'm still not 100% on the approach we're taking -- there's some mess and inconsistency on whether we pass the extended struct (WorkspaceWithConfig) or whether we pass the config separately (e.g. in library packages) and I'm not sure which approach is better.
Signed-off-by: Andrew Obuchowicz <[email protected]>
…asic solver to get config from annotations
cd8ec7a
to
2f91085
Compare
|
||
// Don't accidentally suppress errors by overwriting here; only check for timeout when no error | ||
// encountered in main reconcile loop. | ||
if err == nil { | ||
if timeoutErr := checkForStartTimeout(&clusterWorkspaceWithConfig.DevWorkspace, workspaceWithConfig.Config); timeoutErr != nil { | ||
reconcileResult, err = r.failWorkspace(workspaceWithConfig, timeoutErr.Error(), metrics.ReasonInfrastructureFailure, reqLogger, &reconcileStatus) | ||
if timeoutErr := checkForStartTimeout(&clusterWorkspace.DevWorkspace, clusterWorkspace.Config); timeoutErr != nil { |
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.
It's not really necessary, but I decided to call checkForStartTimeout()
with the clusterWorkspace.Config
rather than workspace.Config
2f91085
to
2983848
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'm still having some issues with how we can do this cleanly in the code. Currently, we have a split between functions that take DevWorkspaceWithConfig and those that take DevWorkspace alone, and it leads to a really confusing interaction:
- There are two types of functions -- those that take DevWorkspaceWithConfig (DWWC functions) and those that take DevWorkspace alone (DW functions).
- A DW function cannot call a DWWC function
- In other words -- for any DWWC function, all functions up the call chain to
Reconcile
must also be DWWC functions
- In other words -- for any DWWC function, all functions up the call chain to
- If a DWWC function calls a DW function, it must unpack the DevWorkspaceWithConfig into just a DevWorkspace
This leads to strange blocks, like
switch newPhase {
case dw.DevWorkspaceStatusRunning:
metrics.WorkspaceRunning(workspace, logger) // Use DWWC here
case dw.DevWorkspaceStatusFailed:
metrics.WorkspaceFailed(&workspace.DevWorkspace, logger) // Have to unpack the DWWC here
it also removes the convenience of having a "common" config that can be read where needed -- if a function decides it wants its behavior to depend on configuration, it and all functions that call it recursively have to be updated to take DWWC instead of DW.
I'm thinking about approaches:
-
We can continue down this path, but consider updating our internal APIs to always take DevWorkspaceWithConfig and only use DevWorkspaces when necessary (i.e. in k8s API calls). This would look something like amisevsk@e5465c0 though note I haven't tested it thoroughly.
-
Diff against main (including existing PR changes): main...amisevsk:devworkspace-operator:use-dwwc
-
This makes the API less convenient to use -- there's generally more friction and we're passing around a struct that may just never be used, and it always has to be present.
-
On the other hand, the changes in the PR could be summarized to
- Update all functions to take DWWC instead of DW (i.e. don't use plain DevWorkspaces anywhere)
- Update all k8s API calls to unpack DWWC to DW
rather than the current issue which is some functions are half-updated
-
-
We can take a step back and pass the config separately where it is needed. This has the same problems as above, but at least makes where the config is necessary explicit
-
We could also completely abandon the idea of an anywhere-accessible config for the DevWorkspace and instead propagate specific values as required, but this is a significant change and I have no idea how it would play out in the repo.
This PR has been reworked and moved to #918 |
What does this PR do?
This PR aims to make 2 changes to DWO:
The external DWOC's name and namespace are specified with the
controller.devfile.io/devworkspace-config
DevWorkspace attribute, which has the following structure:What issues does this PR fix or reference?
Part of eclipse-che/che#21405
Is it tested? How?
I added 2 automated tests.
For manual testing, perform the following steps:
controller.devfile.io/devworkspace-config
attribute set, e.g.test-external-dwoc.yaml
. Also, ensure its name field is set to the same value as thecontroller.devfile.io/devworkspace-config-name
attribute in the devfile from step 2:controller.devfile.io/devworkspace-config-namespace
(in my example, the default namespace is used):kubectl apply -f test-external-dwoc.yaml
29Gi
instead of the default10Gi
controller.devfile.io/devworkspace-config
attribute set are not affected by the external DWOC, and instead, they use the global/internal DWOC. For instance, start up the per-workspace example and ensure the PVC created for it is10Gi
big:kubectl apply -f per-workspace-storage.yaml -n $NAMESPACE
.Some notes and limitations:
20Gi
is applied for a specific workspace, then other (future) workspaces that use the common storage strategy will also be using a PVC of20Gi
, even if they aren't using an external DWOC.PR Checklist
/test v8-devworkspace-operator-e2e, v8-che-happy-path
to trigger)v8-devworkspace-operator-e2e
: DevWorkspace e2e testv8-che-happy-path
: Happy path for verification integration with Che