Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 workloads to the plan #571
base: master
Are you sure you want to change the base?
feat: add workloads to the plan #571
Changes from 8 commits
c5147ab
3bcacec
df6760e
1549f34
40ce30e
5c8915f
f4d0bb9
4dfa7ee
2dce94f
4694cd7
988a31f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
If workload changed from "foo" to "" with the previous update, I think you do want to update
s.workload
to not contain a copy of the previous workload ?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.
Also if the plan.Service is the same, and the workload changed, replan will not restart the service.
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.
Nice catch!
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 was going to comment the same thing as Fred: don't we want to also restart the service if the workload details have changed (its user/group), not just the service.workload name?
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 would argue this shouldn't be in
servstate
-- that just happens to be the only "consumer" of workloads for now. I think should should go in the plan package (internals/plan/workloads.go
). Or maybe it's ownworkloads
package, but I think plan is fine.Naming suggestions:
plan
package, let's call itplan.WorkloadsExtension
(section seems obvious/redundant there)workloads.PlanExtension
or similarThere 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've seen people quote with
%q
which is a single quote. Would it make sense to follow that convention using'workloads'
and just use normal double quotes on the outside ? Maybe I am missing something. It also applies to the next line.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.
Maybe I did not understand correctly, but
%q
uses double quotation marks. I personally don't like mixing up single/double quotes, and also found this in existing code:pebble/internals/plan/plan.go
Lines 732 to 736 in e3b81e1
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 wonder if there's same way we can factor this logic out into a helper function (likely in the
plan
package), generic/parametrized on the section type, that does this tricky switch/merge dance and provides error messages (you'd pass it the field name and anything else needed). This is already done three times inplan.go
and now again here, and it's quite tricky.