Add profile system to elastic-package stack#301
Add profile system to elastic-package stack#301fearful-symmetry merged 44 commits intoelastic:masterfrom
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪 |
|
There's a lot to digest in this feature (which is great!) so I'll start by focussing first on the interface and the overall design before diving into the implementation.
I'd be okay with
I'm good with keeping this out of scope for now. As you said, as long as the design is fairly modular we can expand it as needed later.
My understanding (@mtojek can correct me if I'm wrong) is that the application configs are the ones set by |
@ycombinator I'm mostly looking at the code here: #275 which was basically a shim while we dealt with a bunch of elastic-agent bugs. |
|
Hmm, okay, |
|
Okay, so adding |
|
@fearful-symmetry Don't bother removing the deprecated |
mtojek
left a comment
There was a problem hiding this comment.
My biggest concern with this PR is that it's huge! I think we need to split it intro reviewable pieces. Per feature? What do you think about the following order:
- List profiles and create new profile for elastic-package stack
- Create new profile from existing one.
- Delete profiles.
- Boot up the stack using selected profile.
So we would end up with 4 PRs.
|
@mtojek that might work? A huge chunk of this code is basally reorganizing (see |
|
Well, 30 files is definitely too much for a single PR and will probably slow us down with merging this in. If you are able to split this codebase more into features, so that we have 7-8 files per PR, then it will make reading this easier.
I see your point, but we need to cut this into reviewable pieces. I don't mind if two libraries need to go together, but for me the most important part is value added to the codebase (new feature). Thus, I suggest to split it. |
I definitely agree, I'm just worried about merging something half-broken. I think the best way to do this would be like this:
That should work, as a good part of the PR is just the renames associated with creating the |
|
Ok, let's try such approach. I personally prefer to open pull requests which add a real value for the end user, not just a library or simple refactoring, but you're the driver here :) I'm looking forward to reviewing the first PR. If it's easier for you to split this PR, you can keep open as a draft. |
Agreed, but I think it's the only way to break the whole feature addition down into manageable chunks, as 6-7 of the files are just changes associated with |
|
I'd like to see this split into multiple PRs as well, even if it means the first PR or two are mostly refactoring / prep for later PRs that actually implement the profiles feature. Alternatively, we also have the option of creating a feature branch and targeting the PRs to it initially if we don't want to land half-baked code into |
|
@fearful-symmetry @mtojek Before we start breaking this up into smaller PRs and reviewing them, it would be good to settle on the overall design and interface for this feature. @fearful-symmetry raised some questions in #301 (comment) and I added some comments in #301 (comment). Do either/both of you have anything to add? It would be good to reach some consensus on these points before we start reviewing smaller PRs. Otherwise we might merge a couple of initial PRs and then have to change course later, which wouldn't be a great use of time IMO. |
|
Let me respond to raised questions too:
This is a great question. We may leverage from keeping profiles independent from the stack only in the future. I would be for keeping it as a separate feature.
I agree with Shaunak, let's not introduce additional complexity here. We can iterate on this later on, even leave it for further improvement if it becomes a problem (missing feature).
This piece of code is a safety switch to be used in case of problems with stable SNAPSHOTs. If we know that the SNAPSHOT is faulty, we can mark a particular revision as the recommended one. Unfortunately it's required due to many drawbacks of current unified building process (one piece can block the entire snapshot). |
|
Thanks for the updates @fearful-symmetry. Don't worry about the pace at which this PR is progressing. AFAIK we don't have an urgent demand for profiles (although they will solve some configuration problems rather nicely once ready) and I think it's more important to design this feature right than rush something out. I tried out the latest set of changes and the contents under Moving on from the folder structure, I have a suggestion: could we rename the |
|
I created a new profile It would be nice if the user and version were repeated for the |
|
After creating a However, I wonder — for a follow up PR — if we should introduce a notion of a current profile, something that could be set via |
|
I'm a little concerned that a profile is simply a copy of all internal configuration and script files like One one hand it gives a user an incredible amount of control to do whatever they want, including shooting themselves in their feet. BTW, I'm less concerned about users making changes to their profiles and consequently shooting themselves in their feet because, presumably, a user could always use the On the other hand, it exposes a lot of internals of Also, by implementing a profile as a copy of all internal configuration and script files like FWIW, I was imagining file(s) under a profile to be just properties/settings file(s), much like |
I was actually contemplating something like this earlier today, and figured it was outside the scope of the current PR. I think you're definitely right, we should have some some kind of "current" profile. As far as what APIs we're exposing to the user via the profile system--that's something I was wondering about as well. On one hand, you're right, and we risk giving users a bit of a foot-cannon when they upgrade the tooling and their old profile doesn't work any more. On the other hand, I've had to do some "creative" hacks in the past when testing components of the system module, so I kind of developed this from a perspective of "the user should be able to spin up the stack in a way that's very different from what we anticipate." I should probably try to pull out the health check, since that seems a tad unnecessary. I wonder if there's a clever way to manage files under the profile system. Version tagging? Some kind of merge function? Copy on Write? |
|
Alright @ycombinator fixed the way |
|
Created #361 for the follow up enhancement of current profiles. Checked out the latest changes. The table produced by
Fair point, and I'll happily defer to you on the right level of interface exposure here as you are the most experienced user for this use case.
Merging sounds fraught with other potential problems — like how to recover from conflicts? By "version tagging" I assume you mean something like "this profile is compatible with versions X through Y of Similarly, could you elaborate on how copy-on-write could help? Thanks for your patience with working through these issues. I love how powerful this feature is but I'm also glad we're taking the time to think through user experience for it! |
@ycombinator I was mostly throwing ideas out there, most of which would require a certain bit of over-engineering. The simplest would be some kind of version tagging attached to managed files. If we push an update that requires a new |
|
Version conflicts might be annoying but on the hand the user might have messed up with their config so much that even the smartest handling won't solve conflicts. I'm fine with postponing this for later. |
There was a problem hiding this comment.
I'm concerned about the current directory layout as it's a bit tangled:
/Users/marcin.tojek/.elastic-package
├── config.yml
├── deployer
│ ├── kubernetes
│ │ └── elastic-agent.yml
│ └── terraform
│ ├── Dockerfile
│ ├── run.sh
│ └── terraform-deployer.yml
├── profiles
│ └── default
│ ├── Dockerfile.package-registry
│ ├── kibana.config.yml
│ ├── package-registry.config.yml
│ ├── profile.json
│ └── snapshot.yml
├── stack
│ ├── development
│ └── healthcheck.sh
├── tmp
│ └── service_logs
└── version
We suggested a different layout: #301 (comment) .
Let me bring it here as well:
~/.elastic-package
profiles/
default/
stack/
Dockerfile.package-registry
kibana.config.yml
healthcheck.sh # not sure why did you detached the healthcheck file. IMHO it's part of the stack too.
<other stack files>
foo/
stack/
<stack files as above>
bar/
stack/
<stack files as above>
...
stack/
development/
<built packages>
Such layout allows for extensions - profiles are not just coupled with "stack" but potentially other future features. I understand that the "stack/development" with built packages is aside, but I'm afraid we can't do anything with this one.
|
@mtojek that was the directory structure I tried to implement, I think I was a tad confused with what you were suggesting. So we just want each profile to have it's own |
Correct. There would be also a global "stack" directory for built packages in "development".
Ok, it seems that I missed this discussion. I'm ok with leaving it as it's now - global healthcheck. My counter-argument is that's a bit scattered across two places (global + profile's). It's up to you to decide, Alex. One last thought: If we agree on preserving the layout above, will "profile.json" be present in the profile directory? e.g.: |
It's a bit scattered, yah, but I think we should be selective about what we put under the Either way, let me tinker with the file paths a bit more. |
|
Alright, I think this looks a tad cleaner: |
mtojek
left a comment
There was a problem hiding this comment.
I tested the feature and looks to be working correctly (left one nit-pick). Thanks for all adjustment, I think you can get this in.
Once it's merged - could you please update the dependency on elastic-package in the Integration repo? (go get github.com/elastic/elastic-package@master and go mod tidy). We'll make sure that it doesn't harm development of any of our integrations.
|
@ycombinator did you still want to approve this? |
|
@fearful-symmetry I think you can proceed with this PR and dep change in integrations as Shaunak will not continue work on package tooling. |
|
Glad to see this PR merged! I was on PTO all last week so ++ for not waiting for my review. |
This PR addresses #179 and adds an
elastic stack profilescommand to manage multiple configs used bydocker-composeThis can be used to manage and select config profiles that correspond do to the config files under
~/.elastic-package/stack/This is a follow-up to my earlier PR that added the
locationspackage. This should be the "final" PR to add a profile system. It's still a tad large, but at this point I don't know if it can be paired down much further, as the profile system has its fingers in a lot of the docker-compose code.There's still a few bits of design I'd like input on.
Do we want to keep the command structure as-is? This only applies to the logic of
stackso I made it a sub-command, but I guess we do could doelastic-package profiles ...Also, do we want to lasso the
deployerconfigs into this? This is limited to thestackconfig used bydocker-compose, but there's no reason we can't expand it. Also, never used terraform and I don't have much experience with K8s in general, so I'm not sure if we want to touch those configs. I tried to make this fairly modular, so it shouldn't be too hard to expand the files managed by profiles.There's also the issue of
application_config, which I sort of left in. I'm not sure if we just want to flat-out remove the code that creates~/.elastic-package/config.yml?