PWX-30292: Migrating related CRDs to destination cluster with similar categories#1494
PWX-30292: Migrating related CRDs to destination cluster with similar categories#1494diptiranjanpx merged 1 commit intomasterfrom
Conversation
e5b4b1c to
305f9a4
Compare
|
Can one of the admins verify this patch? |
305f9a4 to
fc86979
Compare
pp511
left a comment
There was a problem hiding this comment.
Core logic looks good to me. Some nits and comments to be addressed
| destClnt, err := apiextensionsclient.NewForConfig(remoteClient.remoteAdminConfig) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
There was a problem hiding this comment.
You don't need to call NewForConfig again here. You can just use remoteClient.adminClient as destClnt.
There was a problem hiding this comment.
destClnt is *apiextensionsclient.Clientset whereas remoteClient.adminClient is *kubernetes.Clientset. Hence keeping it.
| // | ||
| // a. CRD matching with the required groups. | ||
| // b. CRDs which are related with the CRDs from above list (#a) | ||
| func getRelatedCRDListWRTGroupAndComponents(client *apiextensionsclient.Clientset, ruleset *inflect.Ruleset, crdList *stork_api.ApplicationRegistrationList, resGroups map[string]string) []*stork_api.ApplicationRegistration { |
There was a problem hiding this comment.
nit.. Didn't you want to name the function getRelatedCRDListWRTGroupAndCategories instead of getRelatedCRDListWRTGroupAndComponents?
| func getRelatedCRDListWRTGroupAndComponents(client *apiextensionsclient.Clientset, ruleset *inflect.Ruleset, crdList *stork_api.ApplicationRegistrationList, resGroups map[string]string) []*stork_api.ApplicationRegistration { | ||
| filteredCRDList := make([]*stork_api.ApplicationRegistration, 0) | ||
| reqCategoriesMap := make(map[string]bool) | ||
| //categoriesToCRDMap := make(map[string][]*stork_api.ApplicationRegistrationList) |
| filteredCRDList = append(filteredCRDList, &crd) | ||
| continue | ||
| } | ||
| crdName := ruleset.Pluralize(strings.ToLower(v.Kind)) + "." + v.Group |
There was a problem hiding this comment.
nit..nit..I think we can move the statement in the below if condition.
| // getRelatedCRDListWRTGroupAndComponents takes input of AppRegs | ||
| // and find out all CRDs those need to be collected. | ||
| // The CRD list should contain | ||
| // |
There was a problem hiding this comment.
nit..Just rewording a bit
getRelatedCRDListWRTGroupAndCategories takes AppRegs as input and
finds out all the CRDs that need to be collected.
This CRD list should contain
- Also remove the space after this line
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #1494 +/- ##
==========================================
+ Coverage 65.90% 65.96% +0.05%
==========================================
Files 43 43
Lines 5139 5139
==========================================
+ Hits 3387 3390 +3
+ Misses 1425 1423 -2
+ Partials 327 326 -1 ☔ View full report in Codecov by Sentry. |
pp511
left a comment
There was a problem hiding this comment.
Just one nit. Rest lgtm.
Just a general concern. We do not have any UT coverage for migration.go. I think we should plan to start adding UTs for the new code we are adding [if feasible]. For eg. We can start by adding UTs for getRelatedCRDListWRTGroupAndCategories here. Let's start by filing a ticket to track this and label it good-first-issue.
| // getRelatedCRDListWRTGroupAndCategories takes AppRegs as input and | ||
| // finds out all the CRDs that need to be collected. | ||
| // The CRD list should contain | ||
| // |
There was a problem hiding this comment.
nit..I don't think a blank line is required here.
There was a problem hiding this comment.
make do-fmt is adding that line.
1ae2a0a to
ee8d6de
Compare
PWX-30292: Migrating related CRDs to destination cluster.
ee8d6de to
d478679
Compare
Signed-Off-By: Diptiranjan
What type of PR is this?
improvement
What this PR does / why we need it:
Migrating related CRDs with similar categories as some apps activation requires CRDs other than their group.
Does this PR change a user-facing CRD or CLI?:
Is a release note needed?:
Does this change need to be cherry-picked to a release branch?:
Test