-
Notifications
You must be signed in to change notification settings - Fork 257
Refactor some things #2775
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
Refactor some things #2775
Conversation
|
NOTE: Currently on top of #2729. Review top commit only. |
3c3fddd to
25ce097
Compare
|
/retest |
|
Caution There are some errors in your PipelineRun template.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2775 +/- ##
==========================================
+ Coverage 50.19% 50.34% +0.14%
==========================================
Files 284 279 -5
Lines 34267 34167 -100
==========================================
+ Hits 17200 17201 +1
+ Misses 15713 15612 -101
Partials 1354 1354
🚀 New features to boost your workflow:
|
25ce097 to
975ea68
Compare
|
/test e2e-azure infra flake |
|
/hold because
|
975ea68 to
8aa2c15
Compare
2uasimojo
left a comment
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.
notes for reviewers
| log.WithField("pprof_host_port", pprofHostPort).Info("Enabling pprof") | ||
| log.Println(http.ListenAndServe(pprofHostPort, nil)) | ||
| }() | ||
| rand.Seed(time.Now().UnixNano()) |
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.
deprecated/obsolete/no-op
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.
It was interesting to learn why this was done in the first place - glad it is no longer needed.
| cloudAWS = "aws" | ||
| cloudGCP = "gcp" | ||
| cloudAzure = "azure" |
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.
use global consts
| // create a default one once run. | ||
| hc := &hivev1.HiveConfig{} | ||
| o.hiveClient.Get(context.TODO(), types.NamespacedName{Name: hiveConfigName}, hc) | ||
| if err != nil { |
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 was checking the wrong err (which couldn't be nil if we got here).
| const ( | ||
| // privateLinkHubAcctCredsName is the name of the AWS PrivateLink Hub account credentials Secret | ||
| // created by the "hiveutil awsprivatelink enable" command | ||
| privateLinkHubAcctCredsName = "awsprivatelink-hub-acct-creds" | ||
|
|
||
| // privateLinkHubAcctCredsLabel is added to the AWS PrivateLink Hub account credentials Secret | ||
| // created by the "hiveutil awsprivatelink enable" command and | ||
| // referenced by HiveConfig.spec.awsPrivateLink.credentialsSecretRef. | ||
| privateLinkHubAcctCredsLabel = "hive.openshift.io/awsprivatelink-hub-acct-credentials" | ||
| ) |
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.
only used in this package, so moved here from github.com/openshift/hive/contrib/pkg/utils/aws
| @@ -0,0 +1,192 @@ | |||
| package endpointvpc | |||
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.
All of these only used in this package, so moved from #2775 and unexported. Should be direct cut/paste (other than capitalization).
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.
I think you provided the wrong link here.
Note to self: moved from contrib/pkg/utils/aws
| &appsv1.Deployment{}, | ||
| 0, | ||
| cache.ResourceEventHandlerFuncs{ | ||
| _, controller := cache.NewInformerWithOptions(cache.InformerOptions{ |
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.
"
| &corev1.Service{}, | ||
| 0, | ||
| cache.ResourceEventHandlerFuncs{ | ||
| _, controller := cache.NewInformerWithOptions(cache.InformerOptions{ |
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.
"
| return nil | ||
| } | ||
|
|
||
| func failTestFunc(t *testing.T, logger *log.Entry) func(string, ...interface{}) { |
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.
collapse single use func to inline
| default: | ||
| t.Log("found cluster autoscaler") | ||
| break | ||
| break poll |
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.
linter be like, I don't think this was doing what you think it was doing.
| clusterAutoscaler := &autoscalingv1.ClusterAutoscaler{} | ||
| for i := 0; i < 10; i++ { | ||
| poll: | ||
| for range 10 { |
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.
soft lint squiggle
|
/assign @suhanime |
suhanime
left a comment
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.
Nice set of changes! I only have 1 comment you might want to address - and can also squash the second commit, rest LGTM
| log.WithField("pprof_host_port", pprofHostPort).Info("Enabling pprof") | ||
| log.Println(http.ListenAndServe(pprofHostPort, nil)) | ||
| }() | ||
| rand.Seed(time.Now().UnixNano()) |
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.
It was interesting to learn why this was done in the first place - glad it is no longer needed.
| @@ -0,0 +1,192 @@ | |||
| package endpointvpc | |||
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.
I think you provided the wrong link here.
Note to self: moved from contrib/pkg/utils/aws
| } | ||
|
|
||
| func mockGetVPCZonesForRegion(ibmClient *mockibm.MockAPI, zones []string, region string) { | ||
| func mockGetVPCZonesForRegion(ibmClient *mockibm.MockAPI, zones []string) { |
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.
A true mock for GetVPCZonesForRegion should be using the arg region instead of hardcoded testRegion but given that we always called it with testRegion anyways, I guess this is alright.
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 changes in this file might need to be revisited. At the bare minimum, if these args aren't needed, all the relevant docstrings need to be updated
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.
They're not args; they're type declarations for the generics. They were redundant because go can infer them based on the types of the params/returns.
|
|
||
| wh := requiredObj.(*admregv1.ValidatingWebhookConfiguration) | ||
| validatingWebhooks[i] = wh | ||
| validatingWebhooks[i] = readRuntimeObjectOrDie[*admregv1.ValidatingWebhookConfiguration]( |
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.
I was going to comment for the same in the previous commit, glad you caught it
What started this was HIVE-2302 / openshift#2729 where I wanted to be able to use the ConfigureCreds map from installmanager as well as deprovision, but couldn't do it easily due to circular imports. I got that done, but also knocked down some other tech debt at the same time. I moved things closer to where they're used, in many cases eliminating the packages they came from, addressed some deprecations, deleted some unused stuff, shaved off a few lines of code in some places, got rid of some soft linting squiggles, DRYed some duplicated symbols, that kind of thing.
a7645be to
9ccaa4c
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 2uasimojo, suhanime The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@2uasimojo: all tests passed! Full PR test history. Your PR dashboard. 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-sigs/prow repository. I understand the commands that are listed here. |
In openshift#2775 we rearranged the way installmanager figures out which platform-specific ConfigureCreds() function to call, but forgot to include IBMCloud in the lookup table. (BareMetal is there, which we don't use, and which is probably why this was missed, as it made the number of entries correct.)
What started this was HIVE-2302 / #2729 where I wanted to be able to use the ConfigureCreds map from installmanager as well as deprovision, but couldn't do it easily due to circular imports. I got that done, but also knocked down some other tech debt at the same time. I moved things closer to where they're used, in many cases eliminating the packages they came from, addressed some deprecations, deleted some unused stuff, shaved off a few lines of code in some places, got rid of some soft linting squiggles, DRYed some duplicated symbols, that kind of thing.