Skip to content

feat: custom dagger config file - #8800

Merged
jedevc merged 7 commits into
dagger:mainfrom
jedevc:custom-config-file
Dec 4, 2024
Merged

jedevc merged 7 commits into
dagger:mainfrom
jedevc:custom-config-file

Conversation

@jedevc

@jedevc jedevc commented Oct 28, 2024 •

Copy link
Copy Markdown
Contributor

This PR adds a custom engine config file for dagger - this doesn't currently replace our existing buildkit engine.toml (that format will still continue to work).

However, our custom engine config should be the preferred way to edit config moving forwards. By detaching ourselves from the upstream buildkit toml config, we can do a few important things that we couldn't easily before:

  • Keep the config clean and relevant to what we do - we don't need config items for multiple oci/containerd workers, configuring buildkit frontends doesn't make sense, we don't expose the history API, etc.
  • Add our own config properties for the engine, instead of needing to hack it using lots of environment variables.
  • Document our own config format! We can ideally document this using JSON schema, and add high-quality docs for this in our admin guide.

TODO:

Bikeshedding topics:

  • What's the format of this file? I have a slight preference for JSON here, we should be incredibly unimaginative, something that serializes/deserializes easily would be good.
  • What should the file be called? I've gone with a basic engine.json to start, but that's not a great name.
  • How will this interact with live configuration using dagger core engine ...? (suggested by @sipsma in feat: use new cache policies #8725 (comment))
    • Would changes just persist for the runtime?
    • Would they write to some long-term volume and get merged with this file?
    • Would they write-back to the same file?
  • Do we include an engineVersion here? Might be good for backwards compatibility (we could ignore it for time being, and introduce compat checks later?)

@sipsma

sipsma commented Oct 30, 2024

Copy link
Copy Markdown
Contributor

What's the format of this file? I have a slight preference for JSON here, we should be incredibly unimaginative, something that serializes/deserializes easily would be good.

Yep SGTM, will make it easier to interop with our API potentially too.

What should the file be called? I've gone with a basic engine.json to start, but that's not a great name.

Sounds great enough to me 😄

How will this interact with live configuration using dagger core engine ...? (suggested by @sipsma in #8725 (comment))
Would changes just persist for the runtime?
Would they write to some long-term volume and get merged with this file?
Would they write-back to the same file?

Good questions, but to start I'd probably just make the file configuration be the config when the engine starts and anything applied at runtime is just maintained in memory. Persistence would be potentially useful but can be layered on later once needed.

Do we include an engineVersion here? Might be good for backwards compatibility (we could ignore it for time being, and introduce compat checks later?)

Probably doesn't hurt, informational if nothing else.

@jedevc
jedevc force-pushed the custom-config-file branch 2 times, most recently from c540ec7 to d200e58 Compare November 1, 2024 12:08
@jedevc jedevc added area/engine About dagger core engine needs/changelog Pull requests that require a changelog entry needs/docs Pull requests that require a docs change labels Nov 1, 2024
@jedevc
jedevc force-pushed the custom-config-file branch from d200e58 to c8d6a19 Compare November 1, 2024 14:30
@jedevc

jedevc commented Nov 1, 2024

Copy link
Copy Markdown
Contributor Author

engine.json it is 🎉 The current behavior is to have the docker driver attempt to read from ~/.config/dagger/engine.json, and mount it into the container - that way, you can configure dagger settings on your machine.

I've ported a few of the most interesting configs:

  • GC policy.
  • The insecure capabilities.
  • Log levels.

However, a couple questions on some of the others:

I think the end goal is that we would be able to spin up a dagger engine entirely from this config file, and ideally avoid the need to manually start and manage an engine container out-of-band.

@jedevc

jedevc commented Nov 1, 2024

Copy link
Copy Markdown
Contributor Author

Also wanted to note that this is also interesting in the context of external compute providers #5583 (and other associated issues). Some of these settings might be interesting for remote compute - others don't make sense.

E.g. it doesn't make sense to configure engine logging, security settings or even gc in the context of a remote provider - those would be the responsibility of the provider. But allowing configuration of proxy settings, or registry settings does feel useful - would we maybe want to go the direction of having a single engine config file for all of this, so users could easily take their existing local config to a compute provider?

@jedevc
jedevc force-pushed the custom-config-file branch from c8d6a19 to b85b061 Compare November 1, 2024 14:55
@nipuna-perera

Copy link
Copy Markdown
Contributor

I think the end goal is that we would be able to spin up a dagger engine entirely from this config file, and ideally avoid the need to manually start and manage an engine container out-of-band.

Love what I'm reading here! I would indeed be awesome to be able to set up proxies and CA certificates this way so we don't have to maintain our own version of the engine.

My ask is make the config location configurable via ENV. Something like DAGGER_ENGINE_CONFIG so we can include this custom config in our daggerverse repo and ask devs to add an env var to use the custom engine.

What about environment variables?
HTTP_PROXY, HTTPS_PROXY, etc from #7255
DAGGER_ENGINE_SYSTEMENV*?

Yes, at least in my case I need http_proxy. But something that I know I'll need in the future is GOPROXY. So it makes sense to allow configuring arbitrary env vars.

@grouville

Copy link
Copy Markdown
Member

engine.json it is 🎉 The current behavior is to have the docker driver attempt to read from ~/.config/dagger/engine.json, and mount it into the container - that way, you can configure dagger settings on your machine.

I wonder if it would make sense to also mount the .gitconfig / .ssh/config as part of those configurations too, and maybe some of the .dockerconfig that we use for registry auth (might be time to decouple from that?) ?

Idea: adding a symlink of those into the ~/.config/dagger/ would mount them and make them accessible ?

This could be a nice UX to centrally declare how / when to mount those for #8809, and #8766

@jedevc

jedevc commented Nov 15, 2024 •

Copy link
Copy Markdown
Contributor Author

Okay, I have decided that conceptually, these config options probably don't belong engine wide - I think these should somehow only be session-wide - #8766 (comment). I'm still not sure of the exact config mechanism (it might even be something like ~/.config/dagger/client.json, and not module-specific), but the config should ideally not be part of the whole engine config.

A couple reasons why:

  • Reloading the whole engine on making changes to the registry/proxy/network settings makes it trickier to configure
  • It means you can't run one engine and have different sets of registry settings (e.g. with a persistent engine in k8s, where you might want to run jobs with different requirements)

Anyways, I think it's ambiguous enough that I don't want to put it in this PR, and might try and do it separately.

@jedevc
jedevc force-pushed the custom-config-file branch 4 times, most recently from 67198ec to d9b5682 Compare November 19, 2024 17:17
@jedevc jedevc mentioned this pull request Nov 20, 2024
@jedevc
jedevc force-pushed the custom-config-file branch 2 times, most recently from fb8cf57 to 97101a7 Compare November 20, 2024 14:33
@jedevc
jedevc marked this pull request as ready for review November 20, 2024 14:56
@jedevc
jedevc requested a review from a team as a code owner November 20, 2024 14:56
@jedevc

jedevc commented Nov 20, 2024

Copy link
Copy Markdown
Contributor Author

This is now ready-for-review - however, the new ProvisionSuite that tests that the new ~/.config/dagger/engine.json is actually applied when creating a new dagger engine fail in CI.

We've previously discussed this in #t-infrastructure before, but we should try and find a longer term solution. If we can't, this suite can be split out and run on the ubuntu-latest runner which doesn't have this issue.

@jedevc
jedevc requested review from sipsma and vito November 20, 2024 14:58
@jedevc

jedevc commented Nov 22, 2024

Copy link
Copy Markdown
Contributor Author

Worked around the ProvisionSuite issue by running it on ubuntu-latest, exactly how we do for helm test today.

https://dagger.cloud/dagger/traces/7a505333193220b491e0d2dd6a919032#28ff250b26c960f1
image

@jedevc jedevc removed the needs/docs Pull requests that require a docs change label Nov 22, 2024

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Couple nits but LGTM overall!

Comment thread engine/client/drivers/docker.go Outdated
Comment on lines +130 to +132
} else if !errors.Is(err, os.ErrNotExist) {
fmt.Println(err)
return nil, errors.Wrapf(err, "could not stat config at %s", engineConfigPath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like there could plausibly be some other errors worth ignoring here, especially since this code runs on linux/macos/windows (e.g. permission errors). Maybe it would be safest to just always print the error but ignore it? At least for now? Just don't want the engine to become unstartable due to us missing some obscure error handling on one of the platforms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, fair! Just changed this to be a logging statement for now.

Comment thread engine/config/config.go Resolved
Comment thread engine/config/config.go Resolved
@jedevc
jedevc force-pushed the custom-config-file branch 2 times, most recently from 8bcef17 to 4d8abf6 Compare December 4, 2024 11:32
This PR adds a custom engine config file for dagger - this doesn't
*currently* replace our existing buildkit `engine.toml` (that format
will still continue to work).

However, our custom engine config should be the preferred way to edit
config moving forwards. By detaching ourselves from the upstream
buildkit toml config, we can do a few important things that we couldn't
easily before:
- Keep the config clean and relevant to what we do - we don't need
  config items for multiple oci/containerd workers, configuring buildkit
  frontends doesn't make sense, we don't expose the history API, etc.
- Add our own config properties for the engine, instead of needing to
  hack it using lots of environment variables.
- Document our own config format! We can ideally document this using
  JSON schema.

Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
jedevc force-pushed the custom-config-file branch from 4d8abf6 to a50fcc5 Compare December 4, 2024 12:39
@jedevc
jedevc merged commit 7efce52 into dagger:main Dec 4, 2024
@jedevc
jedevc deleted the custom-config-file branch December 4, 2024 14:41
@TomChv TomChv mentioned this pull request Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/engine About dagger core engine needs/changelog Pull requests that require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants