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: add WorkspaceStopped method to RoutingSolver #839

Closed
wants to merge 1 commit into from

Conversation

dkwon17
Copy link
Collaborator

@dkwon17 dkwon17 commented May 16, 2022

Signed-off-by: David Kwon dakwon@redhat.com

What does this PR do?

Adds a func (s *ClusterSolver) WorkspaceStopped(routing *controllerv1alpha1.DevWorkspaceRouting, workspaceMeta DevWorkspaceMetadata) error method to RoutingSolver interface. This function runs when the corresponding devworkspace has stopped.

What issues does this PR fix or reference?

This PR was created to help support eclipse-che/che-operator#1386

Is it tested? How?

  1. Check out this branch: https://github.com/dkwon17/devworkspace-operator/tree/workspacestoppedtesting
    This branch contains the same commit as this current PR's branch, except that there is a new commit on top of it with a print statement that can be used for testing.
  2. After checking out the above branch, run the code locally by following these instructions: https://github.com/devfile/devworkspace-operator#run-controller-locally
  3. Run the following to create a devworkspace in the devworkspace-controller namespace from the devworkspace samples:
kubectl apply -f samples/theia-latest.yaml -n devworkspace-controller
  1. Stop the devworkspace by setting spec.started to false.

  2. In the output from the terminal used to run DWO from step 2, verify that the we see the print statement:
    image

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
    • v8-devworkspace-operator-e2e: DevWorkspace e2e test
    • v8-che-happy-path: Happy path for verification integration with Che

@dkwon17
Copy link
Collaborator Author

dkwon17 commented May 17, 2022

For more context, the approach for eclipse-che/che-operator#1386 is that the traefik config is updated when the devworkspace stops. The traefik config is updated so that the mainurl for the workspace is routed to the dashboard.

I use the WorkspaceStopped method in that PR: https://github.com/eclipse-che/che-operator/blob/a8cbf103af1a108fab4d10d53b8fd1255dbaa7e2/controllers/devworkspace/solver/solver.go#L200-L206 so that I can provision new traefik config when the workspace has stopped.

Signed-off-by: David Kwon <dakwon@redhat.com>
Copy link
Contributor

@ibuziuk ibuziuk left a comment

Choose a reason for hiding this comment

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

This is a nice improvement 👍

@openshift-ci
Copy link

openshift-ci bot commented May 18, 2022

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dkwon17, ibuziuk
To complete the pull request process, please assign amisevsk after the PR has been reviewed.
You can assign the PR to them by writing /assign @amisevsk in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Collaborator

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

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

Generally looks good, great addition!

Comment on lines +210 to +212
func (d *DevWorkspaceRouting) IsWorkspaceStopped() bool {
return d.Annotations != nil && d.Annotations[constants.DevWorkspaceStartedStatusAnnotation] == "false"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not 100% on whether or not the type definition files should include struct methods like this, but this one is probably fine.

}

if instance.IsWorkspaceStopped() {
err := solver.WorkspaceStopped(instance, workspaceMeta)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a case where stopping a workspace may require a second reconcile? I'm wonder if we need an error type (or to just reuse RoutingNotReady) to signify that a requeue is needed but no actual error occurred.

@dkwon17
Copy link
Collaborator Author

dkwon17 commented Jun 22, 2022

Thank you so much for the review @amisevsk . Sorry, I should've mentioned this feature is not needed for eclipse-che/che-operator#1386 anymore since a different approach was merged instead.

Should I close this PR?

@amisevsk
Copy link
Collaborator

@dkwon17 it's up to you -- if there's no intention of merging this PR at the moment it can be closed and re-implemented later if need be.

@dkwon17
Copy link
Collaborator Author

dkwon17 commented Jun 23, 2022

Sounds good, I will close for now

@dkwon17 dkwon17 closed this Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants