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(ws): set status.pauseTime on workspace #26

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

Adembc
Copy link

@Adembc Adembc commented Jul 22, 2024

This PR populates the status.pauseTime on the Workspace:

  • Set status.pauseTime to current Unix epoch when paused.
  • Reset status.pauseTime to 0 when unpaused.

@@ -906,7 +902,15 @@ func generateService(workspace *kubefloworgv1beta1.Workspace, imageConfigSpec ku
// generateWorkspaceStatus generates a WorkspaceStatus for a Workspace
func generateWorkspaceStatus(workspace *kubefloworgv1beta1.Workspace, pod *corev1.Pod) kubefloworgv1beta1.WorkspaceStatus {
status := workspace.Status

if workspace.Spec.Paused != nil && *workspace.Spec.Paused {
Copy link
Member

@thesuperzapper thesuperzapper Jul 22, 2024

Choose a reason for hiding this comment

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

This can be simplified:

Suggested change
if workspace.Spec.Paused != nil && *workspace.Spec.Paused {
if !*workspace.Spec.Paused {

Copy link
Member

Choose a reason for hiding this comment

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

really? https://go.dev/play/p/36NkL4Ra68g

package main

import "fmt"

type Spec struct {
	Paused *bool
}

func main() {
	var spec Spec
	if !*spec.Paused {
		fmt.Println("We're paused and there's some details here")
	}
}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x480410]

goroutine 1 [running]:
main.main()
	/tmp/sandbox2639457518/prog.go:13 +0x10

Program exited.

Copy link
Member

Choose a reason for hiding this comment

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

@jiridanek yes, this is fine, because the Kubernetes version will always populate the field with false if not specified, because we set +kubebuilder:default=false:

// if the workspace is paused (no pods running)
//+kubebuilder:validation:Optional
//+kubebuilder:default=false
Paused *bool `json:"paused,omitempty"`

@thesuperzapper
Copy link
Member

@Adembc can you please add a unit test.

@google-oss-prow google-oss-prow bot added size/M and removed size/S labels Jul 23, 2024
@Adembc
Copy link
Author

Adembc commented Jul 23, 2024

I have added unit tests to ensure the pause time is correctly set.
Please review it @thesuperzapper @jiridanek

@thesuperzapper thesuperzapper added project/notebooks-v2 project - kubeflow notebooks v2 area/ci area - related to ci area/controller area - related to controller components and removed area/ci area - related to ci labels Aug 1, 2024
@thesuperzapper thesuperzapper added this to the v2.0.0-alpha.0 milestone Aug 1, 2024
Adembc and others added 3 commits August 5, 2024 18:06
Signed-off-by: Adem Baccara <71262172+Adembc@users.noreply.github.com>
Signed-off-by: Adem Baccara <71262172+Adembc@users.noreply.github.com>
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
@thesuperzapper thesuperzapper changed the title feat(ws): populate the status.pauseTime on the workspace feat(ws): set status.pauseTime on workspace Aug 6, 2024
@thesuperzapper
Copy link
Member

@Adembc thanks for your work on this, I have rebased this PR and made the following changes in def97ba

  • Used the ~ operator with a tolerance of 5 seconds when ensuring the status.pauseTime is correctly set
  • Use the global timeout and interval settings for all the Eventually( methods on workspaces/controller/internal/controller/workspace_controller_test.go

@thesuperzapper
Copy link
Member

I am going to merge this now, since all the tests are passing.

/lgtm
/approve

Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: thesuperzapper

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

@google-oss-prow google-oss-prow bot merged commit 38b8955 into kubeflow:notebooks-v2 Aug 6, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/controller area - related to controller components lgtm project/notebooks-v2 project - kubeflow notebooks v2 size/M
Projects
Development

Successfully merging this pull request may close these issues.

3 participants