chaos-mesh
chaos-mesh copied to clipboard
Multi version support helper
Add a code generator to support multiple versions. To add a new version, you need to do the following things:
./bin/chaos-multiversion-helper create --from v1alpha1 --to v1alpha2 --as-storage-version. It will copy the v1alpha1 to v1alpha2, and mark it as the storage version./bin/chaos-multiversion-helper migrate --from v1alpha1 --to v1alpha2. It will modify every reference to v1alpha1 in the chaos mesh code base to becomev1alpha2./bin/chaos-multiversion-helper autoconvert --version v1alpha1 --hub v1alpha2It will automatically generate the convert file. You may need to look at theapi/v1alpha1/zz_generated.convert.chaosmesh.goto make sure it works as expected, as this program is not guaranteed to work for all situations../bin/chaos-multiversion-helper addoldobjs --version v1alpha1. It will add the old version objects to thecmd/chaos-controller-manager/provider/convert.goto register the convert webhook for them.- Modify the graphql schema in
pkg/ctrl/server/schema.graphqlsfromv1alpha1tov1alpha2, which can be achieved throughsed -i "s/v1alpha1/v1alpha2/g" pkg/ctrl/server/schema.graphqls - Modify the version in
cmd/chaos-builder/version.gofromv1alpha1tov1alpha2 - Modify the groupversion_info in api/v1alpha2 from
v1alpha1tov1alpha2 - Add old scheme to the
cmd/chaos-controller-manager/provider/controller.go
Or, you can use a single command:
OLD_VERSION="v1alpha1" NEW_VERSION="v1alpha2" make migrate-version
TODO:
- [x] Take care of the error and log
[REVIEW NOTIFICATION]
This pull request has been approved by:
- Andrewmatilde
To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.
The full list of commands accepted by this bot can be found here.
Reviewer can indicate their review by submitting an approval review. Reviewer can cancel approval by submitting a request changes review.
Codecov Report
Merging #3009 (e170528) into master (6cc3590) will decrease coverage by
1.59%. The diff coverage is7.37%.
@@ Coverage Diff @@
## master #3009 +/- ##
==========================================
- Coverage 41.09% 39.51% -1.59%
==========================================
Files 165 170 +5
Lines 13850 14507 +657
==========================================
+ Hits 5692 5732 +40
- Misses 7725 8334 +609
- Partials 433 441 +8
| Impacted Files | Coverage Δ | |
|---|---|---|
| api/v1alpha1/awschaos_types.go | 0.00% <ø> (ø) |
|
| api/v1alpha1/azurechaos_types.go | 0.00% <ø> (ø) |
|
| api/v1alpha1/blockchaos_types.go | 0.00% <ø> (ø) |
|
| api/v1alpha1/dnschaos_type.go | 0.00% <ø> (ø) |
|
| api/v1alpha1/gcpchaos_types.go | 0.00% <ø> (ø) |
|
| api/v1alpha1/httpchaos_types.go | 0.00% <ø> (ø) |
|
| api/v1alpha1/iochaos_types.go | 0.00% <ø> (ø) |
|
| api/v1alpha1/jvmchaos_types.go | 33.33% <ø> (ø) |
|
| api/v1alpha1/kernelchaos_types.go | 0.00% <ø> (ø) |
|
| api/v1alpha1/networkchaos_types.go | 0.00% <ø> (ø) |
|
| ... and 17 more |
... and 4 files with indirect coverage changes
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 6cc3590...e170528. Read the comment docs.
@STRRL @iguoyr @cwen0 PTAL
I got an error when running ./bin/chaos-multiversion-helper create --from v1alpha1 --to v2 --as-storage-version on my mac m1.
./bin/chaos-multiversion-helper create --from v1alpha1 --to v2 --as-storage-version
2022-03-17T17:15:19.659+0800 ERROR chaos-multiversion-helper.create create/create.go:43 create new version {"error": "exit status 1", "errorVerbose": "exit status 1\ngithub.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create.run\n\t/Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create/create.go:124\ngithub.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create.NewCreateCmd.func1\n\t/Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create/create.go:41\ngithub.com/spf13/cobra.(*Command).execute\n\t/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:860\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:974\ngithub.com/spf13/cobra.(*Command).Execute\n\t/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:902\nmain.main\n\t/Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/main.go:47\nruntime.main\n\t/Users/cwenyin/dev/local/go/src/runtime/proc.go:255\nruntime.goexit\n\t/Users/cwenyin/dev/local/go/src/runtime/asm_arm64.s:1133"}
github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create.NewCreateCmd.func1
/Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create/create.go:43
github.com/spf13/cobra.(*Command).execute
/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:860
github.com/spf13/cobra.(*Command).ExecuteC
/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:974
github.com/spf13/cobra.(*Command).Execute
/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main
/Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/main.go:47
runtime.main
/Users/cwenyin/dev/local/go/src/runtime/proc.go:255
I got an error when running
./bin/chaos-multiversion-helper create --from v1alpha1 --to v2 --as-storage-versionon my mac m1../bin/chaos-multiversion-helper create --from v1alpha1 --to v2 --as-storage-version 2022-03-17T17:15:19.659+0800 ERROR chaos-multiversion-helper.create create/create.go:43 create new version {"error": "exit status 1", "errorVerbose": "exit status 1\ngithub.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create.run\n\t/Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create/create.go:124\ngithub.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create.NewCreateCmd.func1\n\t/Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create/create.go:41\ngithub.com/spf13/cobra.(*Command).execute\n\t/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:860\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:974\ngithub.com/spf13/cobra.(*Command).Execute\n\t/Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:902\nmain.main\n\t/Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/main.go:47\nruntime.main\n\t/Users/cwenyin/dev/local/go/src/runtime/proc.go:255\nruntime.goexit\n\t/Users/cwenyin/dev/local/go/src/runtime/asm_arm64.s:1133"} github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create.NewCreateCmd.func1 /Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/create/create.go:43 github.com/spf13/cobra.(*Command).execute /Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 github.com/spf13/cobra.(*Command).ExecuteC /Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 github.com/spf13/cobra.(*Command).Execute /Users/cwenyin/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:902 main.main /Users/cwenyin/dev/go/src/github.com/chaos-mesh/chaos-mesh/cmd/chaos-multiversion-helper/main.go:47 runtime.main /Users/cwenyin/dev/local/go/src/runtime/proc.go:255
It seems that the sed command is different between mac and GNU/Linux. It runs the sed -i /+kubebuilder:storageversion/d for every old API, but this command fails to run in a mac.
Maybe I should run this command in a container, but not on the host, which is unpredictable 😢
@STRRL Please help 😢
@STRRL Please help cry
Hi @cwen0 , please use homebrew to install the gnu-sed, then alias sed=gsed. I think that's the temporary solution before we moving the tool into dev-env image
@YangKeao Hi, as we need to execute 8 steps according the document, maybe adding a command that including the above 8 steps could provide more convenient experience to users. 🤔
I suggest to add some log in the PR . At least a word
SUCCESSwhen it woks well.
Done :smile:
@iguoyr Fixed. PTAL
@YangKeao: PR needs rebase.
Instructions 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.

@YangKeao PTAL
![]()
![]()
@YangKeao PTAL
Fixed. All new version will be renamed to "chaosmeshapi" + version, for example chaosmeshapiv1.
@cwen0 PTAL
@YangKeao: PR needs rebase.
Instructions 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.