Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion workspaces/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ curl -X POST http://localhost:4000/api/v1/workspaces/default \
"name": "dora",
"kind": "jupyterlab",
"paused": false,
"deferUpdates": false,
"podTemplate": {
"podMetadata": {
"labels": {
Expand Down
5 changes: 2 additions & 3 deletions workspaces/backend/api/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ func NewExampleWorkspace(name string, namespace string, workspaceKind string) *k
Namespace: namespace,
},
Spec: kubefloworgv1beta1.WorkspaceSpec{
Paused: ptr.To(false),
DeferUpdates: ptr.To(false),
Kind: workspaceKind,
Paused: ptr.To(false),
Kind: workspaceKind,
PodTemplate: kubefloworgv1beta1.WorkspacePodTemplate{
PodMetadata: &kubefloworgv1beta1.WorkspacePodMetadata{
Labels: nil,
Expand Down
8 changes: 3 additions & 5 deletions workspaces/backend/api/workspaces_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,9 @@ var _ = Describe("Workspaces Handler", func() {

By("defining a WorkspaceCreate model")
workspaceCreate := &models.WorkspaceCreate{
Name: workspaceName,
Kind: workspaceKindName,
Paused: false,
DeferUpdates: false,
Name: workspaceName,
Kind: workspaceKindName,
Paused: false,
PodTemplate: models.PodTemplateMutate{
PodMetadata: models.PodMetadataMutate{
Labels: map[string]string{
Expand Down Expand Up @@ -763,7 +762,6 @@ var _ = Describe("Workspaces Handler", func() {
Expect(createdWorkspace.ObjectMeta.Name).To(Equal(workspaceName))
Expect(createdWorkspace.Spec.Kind).To(Equal(workspaceKindName))
Expect(createdWorkspace.Spec.Paused).To(Equal(&workspaceCreate.Paused))
Expect(createdWorkspace.Spec.DeferUpdates).To(Equal(&workspaceCreate.DeferUpdates))
Expect(createdWorkspace.Spec.PodTemplate.PodMetadata.Labels).To(Equal(workspaceCreate.PodTemplate.PodMetadata.Labels))
Expect(createdWorkspace.Spec.PodTemplate.PodMetadata.Annotations).To(Equal(workspaceCreate.PodTemplate.PodMetadata.Annotations))
Expect(createdWorkspace.Spec.PodTemplate.Volumes.Home).To(Equal(workspaceCreate.PodTemplate.Volumes.Home))
Expand Down
1 change: 0 additions & 1 deletion workspaces/backend/internal/models/workspaces/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func NewWorkspaceListItemFromWorkspace(ws *kubefloworgv1beta1.Workspace, wsk *ku
Icon: iconRef,
Logo: logoRef,
},
DeferUpdates: ptr.Deref(ws.Spec.DeferUpdates, false),
Paused: ptr.Deref(ws.Spec.Paused, false),
PausedTime: ws.Status.PauseTime,
PendingRestart: ws.Status.PendingRestart,
Expand Down
16 changes: 7 additions & 9 deletions workspaces/backend/internal/models/workspaces/funcs_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,19 @@ import (
// NewWorkspaceCreateModelFromWorkspace creates WorkspaceCreate model from a Workspace object.
func NewWorkspaceCreateModelFromWorkspace(ws *kubefloworgv1beta1.Workspace) *WorkspaceCreate {
return &WorkspaceCreate{
Name: ws.Name,
Kind: ws.Spec.Kind,
Paused: ptr.Deref(ws.Spec.Paused, false),
DeferUpdates: ptr.Deref(ws.Spec.DeferUpdates, false),
PodTemplate: buildPodTemplateMutate(ws),
Name: ws.Name,
Kind: ws.Spec.Kind,
Paused: ptr.Deref(ws.Spec.Paused, false),
PodTemplate: buildPodTemplateMutate(ws),
}
}

// NewWorkspaceUpdateModelFromWorkspace creates WorkspaceUpdate model from a Workspace object.
func NewWorkspaceUpdateModelFromWorkspace(ws *kubefloworgv1beta1.Workspace) *WorkspaceUpdate {
return &WorkspaceUpdate{
Revision: CalculateWorkspaceRevision(ws),
Paused: ptr.Deref(ws.Spec.Paused, false),
DeferUpdates: ptr.Deref(ws.Spec.DeferUpdates, false),
PodTemplate: buildPodTemplateMutate(ws),
Revision: CalculateWorkspaceRevision(ws),
Paused: ptr.Deref(ws.Spec.Paused, false),
PodTemplate: buildPodTemplateMutate(ws),
}
}

Expand Down
1 change: 0 additions & 1 deletion workspaces/backend/internal/models/workspaces/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ type WorkspaceListItem struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
WorkspaceKind WorkspaceKindInfo `json:"workspaceKind"`
DeferUpdates bool `json:"deferUpdates"`
Paused bool `json:"paused"`
PausedTime int64 `json:"pausedTime"`
PendingRestart bool `json:"pendingRestart"`
Expand Down
14 changes: 6 additions & 8 deletions workspaces/backend/internal/models/workspaces/types_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ import (

// WorkspaceCreate is used to create a new workspace.
type WorkspaceCreate struct {
Name string `json:"name"`
Kind string `json:"kind"`
Paused bool `json:"paused"`
DeferUpdates bool `json:"deferUpdates"`
PodTemplate PodTemplateMutate `json:"podTemplate"`
Name string `json:"name"`
Kind string `json:"kind"`
Paused bool `json:"paused"`
PodTemplate PodTemplateMutate `json:"podTemplate"`
}

// Validate validates the WorkspaceCreate struct.
Expand Down Expand Up @@ -61,9 +60,8 @@ type WorkspaceUpdate struct {
// other than for equality, as the format is not guaranteed to be stable.
Revision string `json:"revision"`

Paused bool `json:"paused"` // TODO: remove `paused` once we have an "actions" api for pausing workspaces
DeferUpdates bool `json:"deferUpdates"` // TODO: remove `deferUpdates` once the controller is no longer applying redirects
PodTemplate PodTemplateMutate `json:"podTemplate"`
Paused bool `json:"paused"` // TODO: remove `paused` once we have an "actions" api for pausing workspaces
PodTemplate PodTemplateMutate `json:"podTemplate"`
}

// Validate validates the WorkspaceUpdate struct.
Expand Down
5 changes: 2 additions & 3 deletions workspaces/backend/internal/repositories/workspaces/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ func (r *WorkspaceRepository) CreateWorkspace(ctx context.Context, workspaceCrea
Namespace: namespace,
},
Spec: kubefloworgv1beta1.WorkspaceSpec{
Paused: &workspaceCreate.Paused,
DeferUpdates: &workspaceCreate.DeferUpdates,
Kind: workspaceKindName,
Paused: &workspaceCreate.Paused,
Kind: workspaceKindName,
PodTemplate: kubefloworgv1beta1.WorkspacePodTemplate{
PodMetadata: &kubefloworgv1beta1.WorkspacePodMetadata{
Labels: workspaceCreate.PodTemplate.PodMetadata.Labels,
Expand Down
13 changes: 0 additions & 13 deletions workspaces/backend/openapi/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2379,16 +2379,12 @@ const docTemplate = `{
"workspaces.WorkspaceCreate": {
"type": "object",
"required": [
"deferUpdates",
"kind",
"name",
"paused",
"podTemplate"
],
"properties": {
"deferUpdates": {
"type": "boolean"
},
"kind": {
"type": "string"
},
Expand Down Expand Up @@ -2431,7 +2427,6 @@ const docTemplate = `{
"required": [
"activity",
"audit",
"deferUpdates",
"name",
"namespace",
"paused",
Expand All @@ -2450,9 +2445,6 @@ const docTemplate = `{
"audit": {
"$ref": "#/definitions/common.Audit"
},
"deferUpdates": {
"type": "boolean"
},
"name": {
"type": "string"
},
Expand Down Expand Up @@ -2510,16 +2502,11 @@ const docTemplate = `{
"workspaces.WorkspaceUpdate": {
"type": "object",
"required": [
"deferUpdates",
"paused",
"podTemplate",
"revision"
],
"properties": {
"deferUpdates": {
"description": "TODO: remove ` + "`" + `deferUpdates` + "`" + ` once the controller is no longer applying redirects",
"type": "boolean"
},
"paused": {
"description": "TODO: remove ` + "`" + `paused` + "`" + ` once we have an \"actions\" api for pausing workspaces",
"type": "boolean"
Expand Down
13 changes: 0 additions & 13 deletions workspaces/backend/openapi/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2377,16 +2377,12 @@
"workspaces.WorkspaceCreate": {
"type": "object",
"required": [
"deferUpdates",
"kind",
"name",
"paused",
"podTemplate"
],
"properties": {
"deferUpdates": {
"type": "boolean"
},
"kind": {
"type": "string"
},
Expand Down Expand Up @@ -2429,7 +2425,6 @@
"required": [
"activity",
"audit",
"deferUpdates",
"name",
"namespace",
"paused",
Expand All @@ -2448,9 +2443,6 @@
"audit": {
"$ref": "#/definitions/common.Audit"
},
"deferUpdates": {
"type": "boolean"
},
"name": {
"type": "string"
},
Expand Down Expand Up @@ -2508,16 +2500,11 @@
"workspaces.WorkspaceUpdate": {
"type": "object",
"required": [
"deferUpdates",
"paused",
"podTemplate",
"revision"
],
"properties": {
"deferUpdates": {
"description": "TODO: remove `deferUpdates` once the controller is no longer applying redirects",
"type": "boolean"
},
"paused": {
"description": "TODO: remove `paused` once we have an \"actions\" api for pausing workspaces",
"type": "boolean"
Expand Down
6 changes: 0 additions & 6 deletions workspaces/controller/api/v1beta1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ type WorkspaceSpec struct {
// +kubebuilder:default=false
Paused *bool `json:"paused,omitempty"`

// if true, pending updates are NOT applied when the Workspace is paused
// if false, pending updates are applied when the Workspace is paused
// +kubebuilder:validation:Optional
// +kubebuilder:default=false
DeferUpdates *bool `json:"deferUpdates,omitempty"`

// the WorkspaceKind to use
// +kubebuilder:validation:MinLength:=2
// +kubebuilder:validation:MaxLength:=63
Expand Down
5 changes: 0 additions & 5 deletions workspaces/controller/api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions workspaces/controller/internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ func NewExampleWorkspace1(name string, namespace string, workspaceKind string) *
Namespace: namespace,
},
Spec: kubefloworgv1beta1.WorkspaceSpec{
Paused: ptr.To(false),
DeferUpdates: ptr.To(false),
Kind: workspaceKind,
Paused: ptr.To(false),
Kind: workspaceKind,
PodTemplate: kubefloworgv1beta1.WorkspacePodTemplate{
PodMetadata: &kubefloworgv1beta1.WorkspacePodMetadata{
Labels: nil,
Expand Down
21 changes: 0 additions & 21 deletions workspaces/controller/internal/controller/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,6 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
// will result in a forced restart of all Workspaces using the WorkspaceKind.
//

// if a restart is pending and the Workspace is paused, update the Workspace with the new options
if workspace.Status.PendingRestart && *workspace.Spec.Paused && !*workspace.Spec.DeferUpdates {

// update the Workspace with the new options
workspace.Spec.PodTemplate.Options.ImageConfig = workspace.Status.PodTemplateOptions.ImageConfig.Desired
workspace.Spec.PodTemplate.Options.PodConfig = workspace.Status.PodTemplateOptions.PodConfig.Desired

// update the Workspace
if err := r.Update(ctx, workspace); err != nil {
if apierrors.IsConflict(err) {
log.V(2).Info("update conflict while updating Workspace, will requeue")
return ctrl.Result{Requeue: true}, nil
}
log.Error(err, "unable to update Workspace")
return ctrl.Result{}, err
}

// return and requeue to pick up the changes
return ctrl.Result{Requeue: true}, nil
}

// generate StatefulSet
statefulSet, err := generateStatefulSet(workspace, workspaceKind, currentImageConfig.Spec, currentPodConfig.Spec)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ var _ = Describe("Workspace Controller", func() {
// - when adding a redirect to the currently selected `imageConfig` or `podConfig`
// - if the workspace is NOT paused, NO resource changes are made except setting `status.pendingRestart`
// and `status.podTemplateOptions` (`desired` along with `redirectChain`)
// - if the workspace IS paused, but `deferUpdates` is true, the same as above
// - if the workspace IS paused and `deferUpdates` is false:
// - if the workspace IS paused:
// - the selected options (under `spec`) should be changed to the redirect
// and `status.pendingRestart` should become false, and `podTemplateOptions` should be empty
// - the new options should be applied to the StatefulSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ spec:
spec:
description: WorkspaceSpec defines the desired state of Workspace
properties:
deferUpdates:
default: false
description: |-
if true, pending updates are NOT applied when the Workspace is paused
if false, pending updates are applied when the Workspace is paused
type: boolean
kind:
description: the WorkspaceKind to use
example: jupyterlab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ spec:
## if the workspace is paused (no pods running)
paused: false

## if true, pending updates are NOT applied when the Workspace is paused
## if false, pending updates are applied when the Workspace is paused
deferUpdates: false

## the WorkspaceKind to use
kind: "jupyterlab"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ spec:
## - hidden options are still available to the controller and manually created Workspace resources
## - options may be "redirected" by setting `redirect.to` to another option:
## - redirected options are NOT shown in the Spawner UI
## - redirected options are like an HTTP 302 redirect, the controller will use the target option
## without actually changing the `spec.podTemplate.options` field of the Workspace
## - redirected options are computed by the controller and shown in status fields
## - users must explicitly update their Workspace via the API to apply redirects
## - the Spawner UI will warn users about Workspaces with pending restarts
##

Expand Down