-
Notifications
You must be signed in to change notification settings - Fork 57
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(run): Add the --dry option to the run command #550
base: master
Are you sure you want to change the base?
Conversation
The --dry option changes the behavior of the run command to only execute the setting-up of the pebble daemon without actually starting it. Side-effects of initialization on the state file are also disabled. This allows checking the validity of a plan without launching pebble proper. For example, if you have a plan layer at /tmp/layers/123-layer.yaml, you can check it using `PEBBLE=/tmp go run ./cmd/pebble run --dry` provided this command is invoked from the root of this repository.
Just a little bit of background - @paul-rodriguez work is based on a CTO approved spec. The reason I mention this is because the approved design would allow for a dry run to make a |
Moving Mattermost conversation here for reference: @paul-rodriguez: As you will see, the code is quite simple. So my instinct is to suspect that there must be something I'm missing. All I'm really doing to achieve a dry-run of pebble is disabling writes to the state backend file and interrupting the starting process immediately after the plan has been loaded (and therefore validated). What's your opinion about this? Anything missing? Does this actually correspond to your idea of what dry-run should be in the first place? @cjdcordeiro: This is great timing 😅 I just told my team about this PR. Somone, probably @rebornplusplus, will be reviewing it (tomorrow or Friday most likely). Conceptually, yes it makes sense to me. A few questions I may have are:
@flotter: It may be difficult to achieve 2 I think, but with PEBBLE_DEBUG=1 at least we could instrument some path with logger.Debug and it would then show on CLI. At least you will see the error that caused the dry-run to fail. @paul-rodriguez: I think it would make sense for run --dry to say if it's going to write anything, but ideally that should just never happen, otherwise it's not really a dry run. Do note that right now if you do run --dry and the PEBBLE directory isn't readable for some reason, it will error out. Right now the answer to your first question is that the other options behave exactly in the same way, but of course they might therefore not have any effect because they influence something that never happens in the --dry case. --hold is such an option. In a sense, --dry implies --hold. I think there's a legitimate case for --create-dirs being an option that the user may want to use or not in combination with --dry though to be honest, it strikes me as odd. If you use --create-dirs it implies your layers directory is empty, so there's no need for validation. |
I think this is a good starting point for discussion, however, I think
Which admittedly is pretty sparse on details. But I believe a dry-run option 1) definitely shouldn't perform changes/writes, and 2) should try to dry-run as much as it can. If I use the AWS CLI, I expect to be able to tack on As it stands, this PR is not fulfilling #1, because if It's also not fulfilling #2. I don't think it should necessarily check ports for Some of these will be tricky to get right (or even specify), hence my preference for |
internals/cli/cmd_run.go
Outdated
@@ -62,22 +63,29 @@ var sharedRunEnterArgsHelp = map[string]string{ | |||
"--args": "Provide additional arguments to a service", | |||
"--identities": "Seed identities from file (like update-identities --replace)", | |||
} | |||
var runArgsHelp = map[string]string{ | |||
"--dry": "Start {{.DisplayName}} without side-effects", |
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.
It doesn't "start" Pebble though, right? I think we need a more accurate description here.
internals/overlord/backend.go
Outdated
} | ||
|
||
func (osb *overlordStateBackend) Checkpoint(data []byte) error { | ||
if osb.DryRun { |
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.
Instead of checking a flag in Checkpoint
, could we provide a different type for the state backend, a do-nothing implementation?
I think conceptionally the goal here is to have a way to "test-run" pebble and derivative projects as part of craft artefact creation (i.e. Rockcraft and friends) to detect incompatibilities between generated metadata, the actual binary version and the expected run-time requirements. Already today, even if we only consider the Plan, derivative Pebble projects would be required to consult additional metadata files to validate the plan. For example, in the craft artefact, is So I think we need to solve this as part of this exercise - where do we place additional system validation ? I think the idea of the spec is to say that beyond Plan schema validation, each manager (i.e. servstate) could perform early validation. The ideal way in my head would be to run the pebble binary in a way that is as close as possible to the real startup, because otherwise we would be maintaining two complete separate entry points. Also, as per the examples above, "validation" may be manager specific, which could be difficult to pull out outside the daemon/overlord framework, so it may have to live inside the daemon during the normal startup flow. Pebble itself is the simplest case, but at least one of the derivative projects, there are a lot of pre-daemon startup code that will also form part of the "test-run", expecting various additional files to exist. |
I also agree that That said, assuming the goal is to get a meaningful dry-run beyond checking the plan, I'll push a few fixes for 1) and 2) in Ben's message above. |
I have pushed a couple of fixes that should address the issues raised. Note that I chose to skip adding an explicit message saying "pebble would use identities X and Y if it ran" in the case where I think all these switches make the |
The --dry option changes the behavior of the run command to only execute
the setting-up of the pebble daemon without actually starting it.
Side-effects of initialization on the state file are also disabled.
This allows checking the validity of a plan without launching pebble
proper.
For example, if you have a plan layer at
/tmp/layers/123-layer.yaml
, youcan check it using
PEBBLE=/tmp go run ./cmd/pebble run --dry
providedthis command is invoked from the root of this repository.