Pilot Metadata Config Patches

A plan to replace fixed config blocks in instance metadata with three generic JSON patches, applied one time at bootstrap. Plan Agreed

The situation

Pilot manages Frappe benches on a host. When a new VM starts from an image, Pilot reads its first settings from instance metadata. Instance metadata is a small key-value service that the cloud makes available inside the VM at 169.254.169.254. Each key is an attribute.

Today Pilot reads three fixed attributes. Each one has its own required keys, its own parser and its own write function.

AttributeContentWritten to
pilot-centralCentral endpoint, token, JWKS URL and audiencecommon_config.toml
pilot-storageSix fixed S3 keysbench.toml [s3]
pilot-telemetryEndpoint and token[telemetry]

To deliver one more setting, a developer must add a key list, a parser, a write function and a docs change. Also, the cloud limits each attribute value to 1 KiB.

Before: one custom code path for each attribute.

The idea

Deliver settings as patches. A patch is a JSON object that names only the keys to change. Central writes one attribute for each config file. Pilot merges each attribute into its file one time, when the host bootstraps.

AttributeTarget fileScope
pilot-common-configcommon_config.tomlAll benches on the host
pilot-configbench.tomlOne bench
pilot-common-site-configsites/common_site_config.jsonAll sites of one bench (Frappe reads it)

The value of each attribute is the patch itself. There is no envelope and no version field.

pilot-common-config       {"telemetry": {"endpoint": "https://...", "token": "..."}}
pilot-config        {"s3": {"bucket": "...", "region": "..."}}
pilot-common-site-config  {"max_file_size": 104857600}

After: one merge step. Each attribute has one target file. The Central credential stays structured.

How a patch merges

Pilot uses JSON Merge Patch (RFC 7396). It is a published standard, so Pilot does not invent its own rules. The rules are:

Example. The file has {"s3": {"bucket": "a", "region": "x"}}. The patch is {"s3": {"bucket": "b"}}. The result is {"s3": {"bucket": "b", "region": "x"}}.

A patch changes only the keys that it names. Settings that a user adds, for example mail settings, stay. If Pilot applies the same patch two times, the result does not change. Thus a retry after a partial failure is safe.

When it runs

Pilot reads the config attributes one time, during bootstrap, before it marks the host as bootstrapped. After bootstrap, Pilot does not read them again. pilot setup central --rebootstrap clears the bootstrap flag, so it applies the credential and the patches again.

We examined later updates through metadata (revision numbers, content hashes, polling) and rejected them for now. A host usually gets its settings only one time, and a one-time apply cannot lose an update or revert a user change.

Rules for Central

  1. Write the config attributes before pilot-central. Pilot bootstraps when pilot-central appears, and it reads the other attributes only at that time. An attribute that arrives later is not applied.
  2. Keep each value under 1 KiB. S3 and telemetry are in different attributes, so each one fits.

Safety rules

Breaking change

This change is not backward compatible. Pilot no longer reads pilot-storage or pilot-telemetry. Central sends S3 settings in pilot-config and telemetry in pilot-common-config. pilot-central does not change.

Limits

Next steps

  1. Add a raw, validated read-modify-write mode for common_config.toml, with a schema for unknown keys.
  2. Add the merge code and read the three attributes during bootstrap.
  3. Remove the pilot-storage and pilot-telemetry code.
  4. Add tests: merge rules, each target, unknown keys, user settings that stay, retry after failure.
  5. Update the configuration docs.