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

ws-manager: Provide more detail of DiposalStatus. #11950

Merged
merged 5 commits into from
Aug 19, 2022
Merged

ws-manager: Provide more detail of DiposalStatus. #11950

merged 5 commits into from
Aug 19, 2022

Conversation

utam0k
Copy link
Contributor

@utam0k utam0k commented Aug 8, 2022

Description

The StartDisposal annotation so far has only shown that it has started, so we will provide more detailed information.

Related Issue(s)

Fixes #

How to test

  1. Open a workspace
  2. Stop a workspace with monitoring workspace pod's annotation

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@utam0k utam0k requested a review from a team August 8, 2022 08:30
@github-actions github-actions bot added the team: workspace Issue belongs to the Workspace team label Aug 8, 2022
Copy link
Contributor

@jenting jenting left a comment

Choose a reason for hiding this comment

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

/hold

components/ws-manager/pkg/manager/monitor.go Outdated Show resolved Hide resolved
components/ws-manager/pkg/manager/monitor.go Outdated Show resolved Hide resolved
components/ws-manager/pkg/manager/monitor.go Outdated Show resolved Hide resolved
components/ws-manager/pkg/manager/annotations.go Outdated Show resolved Hide resolved
@utam0k
Copy link
Contributor Author

utam0k commented Aug 10, 2022

/werft with-preview

👎 unknown command: with-preview
Use /werft help to list the available commands

@utam0k
Copy link
Contributor Author

utam0k commented Aug 10, 2022

/werft run with-preview

👍 started the job as gitpod-build-to-ds.12
(with .werft/ from main)

@utam0k
Copy link
Contributor Author

utam0k commented Aug 10, 2022

/werft with-preview

👎 unknown command: with-preview
Use /werft help to list the available commands

@jenting
Copy link
Contributor

jenting commented Aug 10, 2022

The unit tests fail.

@utam0k
Copy link
Contributor Author

utam0k commented Aug 10, 2022

/werft run with-preview

👍 started the job as gitpod-build-to-ds.15
(with .werft/ from main)

@utam0k
Copy link
Contributor Author

utam0k commented Aug 10, 2022

/werft run with-preview

👍 started the job as gitpod-build-to-ds.17
(with .werft/ from main)

@utam0k
Copy link
Contributor Author

utam0k commented Aug 10, 2022

@jenting PTAL

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-to-ds.19 because the annotations in the pull request description changed
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-to-ds.21 because the annotations in the pull request description changed
(with .werft/ from main)

components/ws-manager/pkg/manager/annotations.go Outdated Show resolved Hide resolved
components/ws-manager/pkg/manager/monitor.go Outdated Show resolved Hide resolved
components/ws-manager/pkg/manager/monitor.go Outdated Show resolved Hide resolved
components/ws-manager/pkg/manager/monitor.go Show resolved Hide resolved
components/ws-manager/pkg/manager/monitor.go Show resolved Hide resolved
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-to-ds.24 because the annotations in the pull request description changed
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-to-ds.26 because the annotations in the pull request description changed
(with .werft/ from main)

@utam0k
Copy link
Contributor Author

utam0k commented Aug 18, 2022

/werft run

👍 started the job as gitpod-build-to-ds.27
(with .werft/ from main)

@utam0k
Copy link
Contributor Author

utam0k commented Aug 18, 2022

/werft run

👍 started the job as gitpod-build-to-ds.29
(with .werft/ from main)

@utam0k
Copy link
Contributor Author

utam0k commented Aug 19, 2022

/werft run

👍 started the job as gitpod-build-to-ds.33
(with .werft/ from main)

@sagor999
Copy link
Contributor

/unhold

@roboquat roboquat merged commit 3917ed8 into main Aug 19, 2022
@roboquat roboquat deleted the to/ds branch August 19, 2022 17:54
Comment on lines -67 to -70
// startedDisposalAnnotation sets to true when finalizeWorkspaceContent is called to prevent finalize from
// being called more then once, which can happen due to race between disposalStatusAnnotation update and actOnPodEvent
startedDisposalAnnotation = "gitpod.io/startedDisposal"

Copy link
Contributor

@jenting jenting Aug 22, 2022

Choose a reason for hiding this comment

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

It's nice to see we could minimize the number of annotations affecting the state change. ❤️

Comment on lines +1014 to 1017
if disposalStatus.Status == DisposalEmpty {
span.LogKV("disposalStatus", "empty")
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could consider checking if the disposalStatus be updated or not.
If not, return it. Otherwise, call the markDisposalStatus.
For example

disposalStatus := &workspaceDisposalStatus{}
existingDisposalStatus := disposalStatus
if reflect.DeepEqual(existingDisposalStatus, disposalStatus) {
	return
}

err := m.manager.markDisposalStatus(ctx, workspaceID, disposalStatus)
if err != nil {
	tracing.LogError(span, err)
	log.WithError(err).Error("was unable to update pod's disposal status - this will break someone's experience")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or rather, should we have it updated every time I make a change rather than mark it with a defer?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or rather, should we have it updated every time I make a change rather than mark it with a defer?

It depends on our code convention.

I'd vote to update the status with defer function because it makes the code simple and we only have to update it once before we exit the function. Otherwise, we might update the status within a function more than once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know the conventions of the Go language, but is it correct to use defer that way? mark should be reflected immediately, and it seemed natural to have the code in a set with the status structure changes. Could you please tell me what the convention is?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, it's not the Go language code convention, it's more like the code convention within Gitpod, and I think we don't have the convention on when to update the status. Never mind for the defer function discussion 😄

But, it's good to check whether the resource needs to be updated before calling the kubernetes client API to update it, ref https://github.com/kubernetes/kubernetes/blob/a1128e380c2cf1c2d7443694673d9f1dd63eb518/pkg/controller/volume/persistentvolume/pv_controller.go#L794

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'm not sure I felt we should avoid using DeepEqual if possible, right?

But, it's good to check whether the resource needs to be updated before calling the kubernetes client API to update it, ref

I wonder In what scenarios would DeepEqual be needed? I believe that the current comparison is sufficient. If you have a case in mind, please let me know. Thanks for the learning opportunity.

components/ws-manager/pkg/manager/monitor.go Show resolved Hide resolved
@roboquat roboquat added deployed: workspace Workspace team change is running in production deployed Change is completely running in production labels Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: workspace Workspace team change is running in production deployed Change is completely running in production release-note-none size/L team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants