feat(cache): generate a shell-format runtime config alongside runtime.json - #6191
feat(cache): generate a shell-format runtime config alongside runtime.json#6191btxu-db wants to merge 3 commits into
Conversation
….json A cache system without a FUSE client has no way to consume runtime.json unless its image ships a JSON parser. Generate runtime.sh into the same ConfigMap, flattening the config into shell exports, so that such a client can source it directly. Values are single-quoted so the shell takes them literally whatever the dataset spec contains, and maps are exported as JSON with sorted keys so the script stays byte-stable across reconciles. String slices are exported as a count plus one variable per element rather than joined on a separator: a mount path or a quota may legally contain one, and paths and quotas are paired by position, so a stray separator would shift the pairing silently. A disabled component exports only its ENABLED flag, so consumers can test it without unset checks. Part of fluid-cloudnative#6176. Signed-off-by: btxu-db <btxu-db@outlook.com>
The runtime.sh work targets cache systems that run without a FUSE client. Pin the behaviour the creation and sync paths already have when the client component is disabled, so that the no-client topology is covered before anything else changes around it. Part of fluid-cloudnative#6176. Signed-off-by: btxu-db <btxu-db@outlook.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @btxu-db. Thanks for your PR. I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6191 +/- ##
==========================================
+ Coverage 65.24% 65.40% +0.16%
==========================================
Files 486 486
Lines 34194 34284 +90
==========================================
+ Hits 22309 22423 +114
+ Misses 10135 10097 -38
- Partials 1750 1764 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
getRuntimeShPath had no caller: the injector that needs the script's in-Pod path belongs to phase 2, so the helper can come back with it. Removing it clears the unused (golangci-lint) and U1000 (staticcheck) failures. Spell reflect.Ptr as reflect.Pointer in cm_test.go, as the govet inline check now requires. Part of fluid-cloudnative#6176. Signed-off-by: btxu-db <btxu-db@outlook.com>
|



Ⅰ. Describe what this PR does
Phase 1 of #6176: generate
runtime.shinto the runtime ConfigMap alongsideruntime.json, so that a cache system without a FUSE client (Mooncake is the motivating case) can source its runtime configuration instead of parsing JSON.generateRuntimeConfigDatanow returns both keys, built from the sameCacheRuntimeConfig, so the two files cannot drift apart. The script flattens the config into shell exports following the naming convention in #6176:A few choices worth calling out, since some differ from the example in the issue:
export KEY="VALUE". Values here are single-quoted with'\''escaping, so the shell takes them literally: a$, a backtick or a quote in a dataset option cannot expand or execute when the script is sourced.set -ucan read any of them.<COMPONENT>_ENABLEDalone tells an absent component from a present one.json.Marshalsorts map keys, so the script is byte-stable across reconciles and does not rewrite the ConfigMap on every sync.The volume, setup and client code needed no change for the client-disabled path. The second commit adds tests that pin the existing behaviour there rather than altering it.
Ⅱ. Does this pull request fix one issue?
Part of #6176 (phase 1). I have not marked it as fixing the issue, because phase 2, the webhook plugin that injects
runtime.shinto application Pods, is still to come.Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
cm_test.go:TestGenerateRuntimeConfigDataIncludesRuntimeSh: both keys are generated, and the script agrees with the JSON field by field.TestRuntimeShCoversEveryConfigField: walks every field reachable fromCacheRuntimeConfigand fails if one is not exported toruntime.sh, or if the export table names a field that no longer exists. Adding a field to the config without exporting it fails this test.TestRuntimeShExportsEveryComponentAlike: the master and the worker, populated identically, export the same variables.TestRuntimeShExportsAbsentComponentsUnderNounset: an absent component exports the same variables as a present one, and the script can be sourced and read underset -u.TestGenerateRuntimeShQuotesHostileValues: quotes,$, backticks, spaces and newlines round-trip through a realsh.TestGenerateRuntimeShIsDeterministic,TestGenerateRuntimeShWithoutAnyEnabledComponent,TestGenerateRuntimeShExportsTieredStoreLevels.volume_test.go:TestCreateVolumeWithClientDisabled, the PV and PVC are still created when the client is disabled.sync_test.go: three specs covering how the creation and sync paths treat a disabled client.The tests that source the script shell out to
sh, and skip if it is not available.Ⅳ. Describe how to verify it
On a cluster, create a CacheRuntime with
spec.client.disabled: trueand read the script back:Ⅴ. Special notes for reviews
The in-Pod path of
runtime.shis not defined here. It is left to phase 2, together with its first consumer, the injector.