Skip to content

Commit cacbe3b

Browse files
committed
ci: validate legacy filestore flags after the upstream rebase
Signed-off-by: 月可 <hukeyang.hky@antgroup.com>
1 parent d39377e commit cacbe3b

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

‎.github/workflows/akernel-pr.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ jobs:
2121
include:
2222
- arch: amd64
2323
runner: ubuntu-24.04
24+
bazel_config: x86_64
2425
- arch: arm64
2526
runner: ubuntu-24.04-arm
27+
bazel_config: aarch64
2628
runs-on: ${{ matrix.runner }}
2729
timeout-minutes: 120
2830
steps:
@@ -48,3 +50,12 @@ jobs:
4850
run: |
4951
set -euo pipefail
5052
bash tools/akernel-release-archive.sh build "${ARCH}" "${RUNNER_TEMP}/gvisor-pr"
53+
54+
- name: Test runtime compatibility
55+
shell: bash
56+
env:
57+
BAZEL_OPTIONS: --config=${{ matrix.bazel_config }}
58+
run: |
59+
set -euo pipefail
60+
make test OPTIONS="-c opt --test_timeout=600" \
61+
TARGETS="//runsc/config:config_test //runsc/boot:boot_test //runsc/container:filestore_snapshot_test"

‎runsc/config/flags_test.go‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ var boolFlagAllowlist = map[string]struct{}{
8080
"vfs2": {},
8181
}
8282

83+
// akernelLegacyBoolFlags preserves the boolean CLI contract of downstream
84+
// filestore flags that existed before rebasing onto the upstream enum policy.
85+
// Keep the upstream allowlist and its fixed size unchanged; new AKernel flags
86+
// must also use enums.
87+
var akernelLegacyBoolFlags = map[string]struct{}{
88+
"filestore-clone-on-adopt": {},
89+
"filestore-parent-mountns": {},
90+
}
91+
8392
// TestNoNewBoolFlagsPlease enforces the policy that no new boolean-typed
8493
// flags may be added. New flags must be enum-typed instead.
8594
func TestNoNewBoolFlagsPlease(t *testing.T) {
@@ -91,16 +100,19 @@ func TestNoNewBoolFlagsPlease(t *testing.T) {
91100
return
92101
}
93102
registered[fl.Name] = struct{}{}
94-
if _, ok := boolFlagAllowlist[fl.Name]; !ok {
103+
_, legacyAKernelFlag := akernelLegacyBoolFlags[fl.Name]
104+
if _, ok := boolFlagAllowlist[fl.Name]; !ok && !legacyAKernelFlag {
95105
t.Errorf(
96106
"Cannot add new boolean flags (found new flag --%s).", fl.Name)
97107
t.Errorf("The policy is to only ever use enum-typed flags. Boolean cannot grow new states, and cannot distinguish the 'unset' from 'explicitly set' state, preventing the addition of automatic selection logic down the line.")
98108
t.Errorf("Instead, define an enum flag with at least two named values instead. See e.g. --host-settings or `--sidecar-release-enforcement-policy`.")
99109
}
100110
})
101-
for name := range boolFlagAllowlist {
102-
if _, ok := registered[name]; !ok {
103-
t.Errorf("Flag --%s is in boolFlagAllowlist but is not a registered boolean flag. Thank you for removing boolean flags! Now please remove it from the allowlist.", name)
111+
for _, allowlist := range []map[string]struct{}{boolFlagAllowlist, akernelLegacyBoolFlags} {
112+
for name := range allowlist {
113+
if _, ok := registered[name]; !ok {
114+
t.Errorf("Flag --%s is in a boolean allowlist but is not a registered boolean flag. Thank you for removing boolean flags! Now please remove it from the allowlist.", name)
115+
}
104116
}
105117
}
106118
}
@@ -111,3 +123,10 @@ func TestDoNotAddNewFlagsToAllowlist(t *testing.T) {
111123
t.Errorf("Cannot add new boolean flags to allowlist")
112124
}
113125
}
126+
127+
func TestDoNotAddNewAKernelBoolFlags(t *testing.T) {
128+
const legacyFlags = 2 // Decrease this when retiring a legacy boolean flag.
129+
if len(akernelLegacyBoolFlags) != legacyFlags {
130+
t.Errorf("Cannot add new AKernel boolean flags; use enum-typed flags instead")
131+
}
132+
}

0 commit comments

Comments
 (0)