✨ feat: add experimental clusterctl convert command#12843
✨ feat: add experimental clusterctl convert command#12843ramessesii2 wants to merge 2 commits intokubernetes-sigs:mainfrom
clusterctl convert command#12843Conversation
|
[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 |
|
Welcome @ramessesii2! |
|
Hi @ramessesii2. Thanks for your PR. I'm waiting for a kubernetes-sigs 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-sigs/prow repository. |
db40551 to
1bf4039
Compare
clusterctl alpha migrate commandclusterctl migrate command
6f90e35 to
c2050f4
Compare
clusterctl migrate commandclusterctl migrate command
c2050f4 to
f67227b
Compare
|
/ok-to-test |
f67227b to
dd58aab
Compare
|
/area clusterctl |
cmd/clusterctl/cmd/migrate.go
Outdated
|
|
||
| Examples: | ||
| # Migrate from file to stdout | ||
| clusterctl migrate cluster.yaml |
There was a problem hiding this comment.
would migrate from new to old be supported?
e.g. v1beta2 -> v1beta1
There was a problem hiding this comment.
I'm thinking what are the usecase where a user would downgrade! And even with warnings, there might be data loss while downgrading.
If may suggest, could we please keep it to the scope of the issue as it's already experimental but definitely mark your question.
fabriziopandini
left a comment
There was a problem hiding this comment.
@ramessesii2 thanks for this PR and sorry for the delay in the review.
Two main comments from my side
- The code should be structured to support usage of clusterctl as a library
- I would suggest to simplify the code as much as possible, the code target a specific use case and we do not expect to change this code frequently (let's prefer simplicity over extensibility)
See comments for more details; also feel free to pin me in the CAPI channel if you need more clarifications
|
@ramessesii2 Do you have time to address the findings above? |
Hey @sbueringer, sorry for the delay. I've been working on the major refactoring suggested in the reviews. Almost there, I'll push it by EDO |
- Experimental migration support focuses on v1beta1 to v1beta2
conversions for core Cluster API resources
Signed-off-by: Satyam Bhardwaj <[email protected]>
dd58aab to
5303b74
Compare
ramessesii2
left a comment
There was a problem hiding this comment.
I've addressed most of the reviews, other might not be applicable post the refactoring.
clusterctl migrate commandclusterctl convert command
- Move to new `Convert` method in clusterctl client interface from
the proposed migrate.
- Create new conversion package with parsing and conversion utilities
- Remove deprecated `migrate` command and related internal migration code
Signed-off-by: Satyam Bhardwaj <[email protected]>
5303b74 to
e2b91c1
Compare
|
@neolit123 @fabriziopandini @sbueringer Thanks for your initial reviews. Based on those, I've refactored code into a new commit. I'll squash it once we're ready to merge or let me know if you prefer that right away. |
|
@ramessesii2: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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-sigs/prow repository. I understand the commands that are listed here. |
|
/cc @fabriziopandini when you have some time (I'll be on PTO for a while) |
| func contains(s, substr string) bool { | ||
| return len(s) >= len(substr) && (s == substr || len(s) > len(substr) && containsHelper(s, substr)) | ||
| } | ||
|
|
||
| func containsHelper(s, substr string) bool { | ||
| for i := 0; i <= len(s)-len(substr); i++ { | ||
| if s[i:i+len(substr)] == substr { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } |
There was a problem hiding this comment.
Isn't it enought to use strings.Contains ?
| obj := &unstructured.Unstructured{} | ||
| _, gvk, err := unstructuredDecoder.Decode(trimmed, nil, obj) | ||
| if err != nil { | ||
| return document{}, errors.Wrap(err, "unable to decode document: invalid YAML structure") |
There was a problem hiding this comment.
| return document{}, errors.Wrap(err, "unable to decode document: invalid YAML structure") | |
| return document{}, errors.Wrap(err, "failed to decode document: invalid YAML structure") |
| return document{}, errors.Wrap(err, "unable to decode document: invalid YAML structure") | ||
| } | ||
| if gvk == nil || gvk.Empty() || gvk.Kind == "" || (gvk.Group == "" && gvk.Version == "") { | ||
| return document{}, errors.New("unable to decode document: missing or empty apiVersion/kind") |
There was a problem hiding this comment.
| return document{}, errors.New("unable to decode document: missing or empty apiVersion/kind") | |
| return document{}, errors.New("failed to decode document: missing or empty apiVersion/kind") |
| var ( | ||
| // sourceGroupVersions defines the source GroupVersions that should be converted. | ||
| sourceGroupVersions = []schema.GroupVersion{ | ||
| clusterv1.GroupVersion, |
There was a problem hiding this comment.
| clusterv1.GroupVersion, | |
| clusterv1beta1.GroupVersion, |
There was a problem hiding this comment.
It will result in pass through.
Implements a new
clusterctl convertcommand to convert core CAPI resources i.e.,cluster.x-k8s.ioresources between API versions, currently supporting v1beta1 → v1beta2 migration.✅ Tests
✅ Docs
Implements #12716