Skip to content

Separate configuration, data, state and runtime directories#484

Merged
mathetake merged 1 commit intomasterfrom
config-xds
Oct 13, 2025
Merged

Separate configuration, data, state and runtime directories#484
mathetake merged 1 commit intomasterfrom
config-xds

Conversation

@codefromthecrypt
Copy link
Copy Markdown
Contributor

@codefromthecrypt codefromthecrypt commented Oct 13, 2025

This refactors func-e to use config_home, data_home, state_home and runtime_dir conventions defined in XDG.

Instead of the now deprecated api.HomeDir()/$FUNC_E_HOME, we have four tiers:

  • api.ConfigHome()/$FUNC_E_CONFIG_HOME: Configuration files like version preferences (default: ~/.config/func-e)
  • api.DataHome()/$FUNC_E_DATA_HOME: Envoy binaries and downloaded data (default: ~/.local/share/func-e)
  • api.StateHome()/$FUNC_E_STATE_HOME: Run logs and persistent state (default: ~/.local/state/func-e)
  • api.RuntimeDir()/$FUNC_E_RUNTIME_DIR: Ephemeral temporary files (default: /tmp/func-e-${UID})

This separation aligns with XDG Base Directory Specification principles:

  • Configuration (envoy-version) is distinct from data (binaries)
  • State (logs) is separate from ephemeral temporary files (admin addresses)
  • Each directory can be independently configured for different storage tiers
  • Docker deployments can easily map volumes to appropriate directories

Run ID

This also adds api.RunID()/$FUNC_E_RUN_ID to override the formerly epoch timestamp with something else for predictable paths in Docker which only support one run typically. For example, we can set it to zero and always know where the logs are.

Here are details on the implementation:

  • --run-id: Sets custom run identifier for current execution (or $FUNC_E_RUN_ID)
  • Default: YYYYMMDD_HHMMSS_UUU (human-readable timestamp)
  • Previous: epoch nanoseconds (less readable)
  • Enables predictable paths for docker (e.g. setting to zero)

Migration

func-e begins immediately to use these conventions except in cases where the deprecated $FUNC_E_HOME was overridden, such as envoyproxy/gateway. This allows tools to migrate on their own schedule.

Unless you set the now deprecated api.HomeDir()/$FUNC_E_HOME, files end up in the new layout described above:

  • Version preference: $FUNC_E_CONFIG_HOME/envoy-version (was: $FUNC_E_HOME/version)
  • Binaries: $FUNC_E_DATA_HOME/envoy-versions/{version}/bin/envoy (was: $FUNC_E_HOME/versions/{version}/bin/envoy)
  • Run logs: $FUNC_E_STATE_HOME/envoy-runs/{runID}/stdout.log (was: $FUNC_E_HOME/runs/{epoch}/stdout.log)
  • Admin address: $FUNC_E_RUNTIME_DIR/{runID}/admin-address.txt (was: $FUNC_E_HOME/runs/{epoch}/admin-address.txt)

@codefromthecrypt codefromthecrypt marked this pull request as ready for review October 13, 2025 01:50
@codefromthecrypt codefromthecrypt changed the title Adopt XDG base directory specification for improved file organization Migrate XDG conventions for persistent, run and ephemeral files Oct 13, 2025
@codefromthecrypt codefromthecrypt changed the title Migrate XDG conventions for persistent, run and ephemeral files Migrate to XDG conventions for persistent, run and ephemeral files Oct 13, 2025
@codefromthecrypt codefromthecrypt changed the title Migrate to XDG conventions for persistent, run and ephemeral files Separate directory config for persistent, run and ephemeral files Oct 13, 2025
@codefromthecrypt codefromthecrypt marked this pull request as draft October 13, 2025 10:24
This refactors func-e to use config_home, data_home, state_home and runtime_dir conventions defined in [XDG](https://specifications.freedesktop.org/basedir-spec/latest/).

Instead of the now deprecated `api.HomeDir()`/`$FUNC_E_HOME`, we have four tiers:
- `api.ConfigHome()`/`$FUNC_E_CONFIG_HOME`: Configuration files like version preferences (default: ~/.config/func-e)
- `api.DataHome()`/`$FUNC_E_DATA_HOME`: Envoy binaries and downloaded data (default: ~/.local/share/func-e)
- `api.StateHome()`/`$FUNC_E_STATE_HOME`: Run logs and persistent state (default: ~/.local/state/func-e)
- `api.RuntimeDir()`/`$FUNC_E_RUNTIME_DIR`: Ephemeral temporary files (default: /tmp/func-e-${UID})

This separation aligns with XDG Base Directory Specification principles:
- **Configuration** (envoy-version) is distinct from **data** (binaries)
- **State** (logs) is separate from ephemeral **temporary** files (admin addresses)
- Each directory can be independently configured for different storage tiers
- Docker deployments can easily map volumes to appropriate directories

**Run ID**

This also adds `api.RunID()`/`$FUNC_E_RUN_ID` to override the formerly epoch timestamp with something else for predictable paths in Docker which only support one run typically. For example, we can set it to zero and always know where the logs are.

Here are details on the implementation:
- --run-id: Sets custom run identifier for current execution (or $FUNC_E_RUN_ID)
- Default: YYYYMMDD_HHMMSS_UUU (human-readable timestamp)
- Previous: epoch nanoseconds (less readable)
- Enables predictable paths for docker (e.g. setting to zero)

**Migration**

func-e begins immediately to use these conventions except in cases where the deprecated $FUNC_E_HOME was overridden, such as envoyproxy/gateway. This allows tools to migrate on their own schedule.

Unless you set the now deprecated `api.HomeDir()`/`$FUNC_E_HOME`, files end up in the new layout described above:
- Version preference: $FUNC_E_CONFIG_HOME/envoy-version (was: $FUNC_E_HOME/version)
- Binaries: $FUNC_E_DATA_HOME/envoy-versions/{version}/bin/envoy (was: $FUNC_E_HOME/versions/{version}/bin/envoy)
- Run logs: $FUNC_E_STATE_HOME/envoy-runs/{runID}/stdout.log (was: $FUNC_E_HOME/runs/{epoch}/stdout.log)
- Admin address: $FUNC_E_RUNTIME_DIR/{runID}/admin-address.txt (was: $FUNC_E_HOME/runs/{epoch}/admin-address.txt)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt codefromthecrypt changed the title Separate directory config for persistent, run and ephemeral files Separate configuration, data, state and runtime directories Oct 13, 2025
@codefromthecrypt codefromthecrypt marked this pull request as ready for review October 13, 2025 12:45
@mathetake mathetake merged commit a7eb48b into master Oct 13, 2025
5 checks passed
@mathetake mathetake deleted the config-xds branch October 13, 2025 14:36
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.

2 participants