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

fix: validate whole plan, rather than topmost two layers #363

Merged
merged 15 commits into from
Feb 23, 2024

Conversation

tonyandrewmeyer
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer commented Feb 20, 2024

This PR moves layer/plan validation into dedicated functions, with Layer.Validate covering validation that is specific to a layer (such as an invalid value) and Plan.Validate covering validation that covers the plan as a whole (such as cycles or missing values).

Plan validation includes layer validation, and is done in the service manager's updatePlanLayers and in plan.CombineLayers.

We also use the check period as the upper bound for the timeout in checks, which was happening before, but less explicitly.

No additional validation is done - all of the validation code is moved rather than changed.

Fixes #349

Copy link
Contributor

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

This looks excellent to me for a first PR in Pebble, thanks! No real issues, just a couple of nit comments. I'll also ask @flotter to go over this as he's looking at the whole plan/layers area (from another angle).

.gitignore Outdated Show resolved Hide resolved
internals/plan/plan.go Outdated Show resolved Hide resolved
internals/plan/plan.go Outdated Show resolved Hide resolved
@benhoyt benhoyt requested a review from flotter February 20, 2024 04:35
Copy link
Contributor

@flotter flotter left a comment

Choose a reason for hiding this comment

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

Some minor comments for consideration, but overall looks great.

internals/plan/plan.go Outdated Show resolved Hide resolved
internals/plan/plan.go Outdated Show resolved Hide resolved
internals/plan/plan.go Show resolved Hide resolved
internals/plan/plan.go Outdated Show resolved Hide resolved
@flotter
Copy link
Contributor

flotter commented Feb 21, 2024

@tonyandrewmeyer b.t.w this is a real coincidence that you are cleaning this up a bit, because I am on a kind of similar mission for slightly different reasons, and I've done in my PoC exactly what you conceptionally doing here. I've also split it up between Layer and Plan validation, but you went a bit further, actually cleaning up what is inside each category, which is super nice and brave :) Looking forward getting this merged.

internals/plan/plan.go Outdated Show resolved Hide resolved
internals/plan/plan.go Show resolved Hide resolved
internals/plan/plan.go Outdated Show resolved Hide resolved
Copy link
Contributor

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

This looks great. Just one final comment/question about not mutating in Layer.Validate.

internals/plan/plan.go Outdated Show resolved Hide resolved
Copy link
Contributor

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Excellent, thank you.

@benhoyt benhoyt merged commit ed3b601 into canonical:master Feb 23, 2024
15 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the validate-whole-plan-349 branch February 27, 2024 01:52
benhoyt pushed a commit to benhoyt/pebble that referenced this pull request Mar 5, 2024
This PR moves layer/plan validation into dedicated functions, with `Layer.Validate` covering validation that is specific to a layer (such as an invalid value) and `Plan.Validate` covering validation that covers the plan as a whole (such as cycles or missing values).

Plan validation includes layer validation, and is done in the service manager's `updatePlanLayers` and in `plan.CombineLayers`.

We also use the check period as the upper bound for the timeout in checks, which was happening before, but less explicitly.

No additional validation is done - all of the validation code is moved rather than changed.

Fixes canonical#349
jujubot added a commit to juju/juju that referenced this pull request Mar 6, 2024
#17011

This is to pull in this Pebble fix to the Juju 3.4 branch: canonical/pebble#363. It fixes an issue a couple of people have had with adding and merging layers (described in canonical/pebble#349).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When combining layers, Pebble should validate the whole plan rather than a single combined layer
3 participants