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: make layers with label prefix "pebble-" reserved #403

Merged
merged 8 commits into from
Apr 8, 2024

Conversation

IronCore864
Copy link
Contributor

@IronCore864 IronCore864 commented Apr 1, 2024

Making layers with label "pebble-*" reserved for pebble use only.

Closes #220.

Test:

/home/ubuntu/PEBBLE_HOME
└── layers
    └── 001-pebble-test.yaml

1 directory, 1 file
$ go run ./cmd/pebble run
cannot run daemon: cannot load plan: cannot use reserved layer label "pebble-test"
exit status 1

@IronCore864
Copy link
Contributor Author

IronCore864 commented Apr 1, 2024

Hi @benhoyt, I'm creating a draft PR, I'm not sure if this is the right way to implement it:

In order to use pebble-service-args in PlanManager.SetServiceArgs after making pebble-* as reserved layer label, the function SetServiceArgs has to check if the returned err, if the error suggests a reserved label is used, ignore it, because pebble itself should be able to use reserved label, right?

Then I found out Layer.Validate() currently returns only type FormatError, in which case, I'd have to check on the error message, something like strings.Contains(err.Error(), "cannot use reserved layer label").

But I think in Go it is generally recommended to avoid relying on error messages and it's better to handle errors based on types, right?

So in my draft I created another type ReservedLabelError, and in SetServiceArgs I ignore the error if it's this type. Does this make sense?

@IronCore864 IronCore864 requested a review from benhoyt April 1, 2024 02:55
@IronCore864 IronCore864 marked this pull request as ready for review April 3, 2024 00:56
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.

Looks good -- just some minor changes requested.

internals/overlord/planstate/manager.go Outdated Show resolved Hide resolved
internals/plan/plan.go Outdated Show resolved Hide resolved
internals/plan/plan.go Outdated Show resolved Hide resolved
internals/plan/plan_test.go Outdated Show resolved Hide resolved
internals/plan/plan_test.go Outdated Show resolved Hide resolved
@IronCore864 IronCore864 removed the request for review from tonyandrewmeyer April 8, 2024 01:46
@benhoyt benhoyt merged commit 996c12a into canonical:master Apr 8, 2024
15 checks passed
@IronCore864 IronCore864 deleted the reserved-layer-label branch June 5, 2024 04:34
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.

Make layer labels starting with the "pebble-" prefix reserved
2 participants