-
Notifications
You must be signed in to change notification settings - Fork 111
fix: include all Linux network actions in k8s spec regardless of build platform #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/chaosblade-io/chaosblade-exec-os/exec/file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/chaosblade-io/chaosblade-exec-os/exec/mem" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/chaosblade-io/chaosblade-exec-os/exec/network" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/chaosblade-io/chaosblade-exec-os/exec/network/tc" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/chaosblade-io/chaosblade-exec-os/exec/process" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/chaosblade-io/chaosblade-exec-os/exec/script" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/chaosblade-io/chaosblade-spec-go/spec" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -31,12 +32,33 @@ type OSSubResourceModelSpec struct { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BaseSubResourceExpModelSpec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // newK8sNetworkCommandSpec returns all Linux-compatible network actions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // regardless of the build platform, since k8s pods always run on Linux. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func newK8sNetworkCommandSpec() spec.ExpModelCommandSpec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &network.NetworkCommandSpec{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BaseExpModelCommandSpec: spec.BaseExpModelCommandSpec{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ExpActions: []spec.ExpActionCommandSpec{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tc.NewDelayActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network.NewDropActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network.NewDnsActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network.NewDnsDownActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tc.NewLossActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tc.NewDuplicateActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tc.NewCorruptActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tc.NewReorderActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network.NewOccupyActionSpec(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ExpFlags: []spec.ExpFlagSpec{}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+51
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // newK8sNetworkCommandSpec returns all Linux-compatible network actions | |
| // regardless of the build platform, since k8s pods always run on Linux. | |
| func newK8sNetworkCommandSpec() spec.ExpModelCommandSpec { | |
| return &network.NetworkCommandSpec{ | |
| BaseExpModelCommandSpec: spec.BaseExpModelCommandSpec{ | |
| ExpActions: []spec.ExpActionCommandSpec{ | |
| tc.NewDelayActionSpec(), | |
| network.NewDropActionSpec(), | |
| network.NewDnsActionSpec(), | |
| network.NewDnsDownActionSpec(), | |
| tc.NewLossActionSpec(), | |
| tc.NewDuplicateActionSpec(), | |
| tc.NewCorruptActionSpec(), | |
| tc.NewReorderActionSpec(), | |
| network.NewOccupyActionSpec(), | |
| }, | |
| ExpFlags: []spec.ExpFlagSpec{}, | |
| // k8sNetworkActions defines the full set of network actions that are exposed | |
| // via the k8s OS subresource, independent of the current build platform. | |
| // This list is centralized here to reduce the risk of it silently drifting | |
| // from the underlying chaosblade-exec-os network actions. | |
| var k8sNetworkActions = []spec.ExpActionCommandSpec{ | |
| tc.NewDelayActionSpec(), | |
| network.NewDropActionSpec(), | |
| network.NewDnsActionSpec(), | |
| network.NewDnsDownActionSpec(), | |
| tc.NewLossActionSpec(), | |
| tc.NewDuplicateActionSpec(), | |
| tc.NewCorruptActionSpec(), | |
| tc.NewReorderActionSpec(), | |
| network.NewOccupyActionSpec(), | |
| } | |
| // K8sNetworkActionSpecs returns a copy of the k8s network action specs. | |
| // It can be used by tests to assert that the k8s-exposed actions stay | |
| // in sync with the expected set of network actions. | |
| func K8sNetworkActionSpecs() []spec.ExpActionCommandSpec { | |
| out := make([]spec.ExpActionCommandSpec, len(k8sNetworkActions)) | |
| copy(out, k8sNetworkActions) | |
| return out | |
| } | |
| // newK8sNetworkCommandSpec returns all Linux-compatible network actions | |
| // regardless of the build platform, since k8s pods always run on Linux. | |
| func newK8sNetworkCommandSpec() spec.ExpModelCommandSpec { | |
| return &network.NetworkCommandSpec{ | |
| BaseExpModelCommandSpec: spec.BaseExpModelCommandSpec{ | |
| ExpActions: k8sNetworkActions, | |
| ExpFlags: []spec.ExpFlagSpec{}, |
Copilot
AI
Mar 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is meant to guarantee that the generated k8s spec always includes the tc-based actions even when the spec generator is built on macOS. There’s currently no automated test covering the resulting action set; adding a small unit test (e.g., asserting NewOSSubResourceModelSpec() includes delay/loss/duplicate/corrupt/reorder/dnsdown) would prevent regressions and catch future dependency changes.
Copilot
AI
Mar 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newK8sNetworkCommandSpec is used by NewOSSubResourceModelSpec() (shared by node/pod/container), so the name is misleading (it’s not pod-only and not purely “k8s network” as a standalone spec). Consider renaming it to reflect that this is the operator’s Linux-targeted network spec used across k8s resources (e.g., newLinuxNetworkCommandSpecForK8sResources).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says “k8s pods always run on Linux”, but this helper is also used for node/container specs and the repo’s stated constraint is broader/clearer: build docs list the target platforms as Linux (amd64/arm64). Consider rewording the comment to reflect the project’s Linux-target assumption (per BUILD.md) rather than a universal Kubernetes property.