Skip to content

Conversation

@2uasimojo
Copy link
Member

@2uasimojo 2uasimojo commented Oct 31, 2025

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.

@openshift-ci openshift-ci bot requested a review from jstuever October 31, 2025 22:50
@2uasimojo
Copy link
Member Author

NOTE: Currently on top of #2729. Review top commit only.

@openshift-ci openshift-ci bot requested a review from suhanime October 31, 2025 22:50
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 31, 2025
@2uasimojo
Copy link
Member Author

/retest

@red-hat-konflux
Copy link
Contributor

Caution

There are some errors in your PipelineRun template.

PipelineRun Error
hive-mce-210-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\"\n&& !body.pull_request.draft\n&& target_branch == \"master\"\n&& !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-26-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\"\n&& !body.pull_request.draft\n&& target_branch == \"master\"\n&& !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-27-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\"\n&& !body.pull_request.draft\n&& target_branch == \"master\"\n&& !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-28-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\"\n&& !body.pull_request.draft\n&& target_branch == \"master\"\n&& !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-29-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\"\n&& !body.pull_request.draft\n&& target_branch == \"master\"\n&& !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\"\n&& !body.pull_request.draft\n&& target_branch == \"master\"\n&& !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 12.04819% with 365 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.34%. Comparing base (161a023) to head (9ccaa4c).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
contrib/pkg/awsprivatelink/endpointvpc/helpers.go 0.00% 113 Missing ⚠️
pkg/creds/aws/aws.go 0.00% 41 Missing ⚠️
contrib/pkg/createcluster/create.go 0.00% 30 Missing ⚠️
pkg/operator/hive/hive_controller.go 0.00% 21 Missing ⚠️
pkg/resource/helper.go 0.00% 20 Missing ⚠️
contrib/pkg/adm/managedns/enable.go 0.00% 13 Missing ⚠️
pkg/operator/hive/apply.go 0.00% 13 Missing ⚠️
contrib/pkg/clusterpool/clusterpool.go 0.00% 12 Missing ⚠️
pkg/operator/hive/hiveadmission.go 0.00% 11 Missing ⚠️
contrib/pkg/awsprivatelink/endpointvpc/remove.go 0.00% 10 Missing ⚠️
... and 33 more
Additional details and impacted files

Impacted file tree graph

@@            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              
Files with missing lines Coverage Δ
cmd/manager/main.go 0.00% <ø> (ø)
contrib/pkg/awsprivatelink/awsprivatelink.go 0.00% <ø> (ø)
pkg/clusterresource/builder.go 63.02% <100.00%> (ø)
pkg/constants/constants.go 100.00% <ø> (ø)
...g/controller/clusterpool/clusterpool_controller.go 59.05% <100.00%> (ø)
pkg/controller/clustersync/templates.go 76.00% <100.00%> (ø)
pkg/controller/images/controller_images.go 77.77% <ø> (+14.14%) ⬆️
pkg/controller/machinepool/gcpactuator.go 71.22% <100.00%> (ø)
...g/controller/machinepool/machinepool_controller.go 63.40% <100.00%> (ø)
pkg/controller/utils/clientwrapper.go 42.85% <100.00%> (+0.75%) ⬆️
... and 65 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@2uasimojo
Copy link
Member Author

/test e2e-azure

infra flake

@2uasimojo
Copy link
Member Author

/hold because

NOTE: Currently on top of #2729.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 3, 2025
Copy link
Member Author

@2uasimojo 2uasimojo left a 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())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deprecated/obsolete/no-op

Copy link
Contributor

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.

Comment on lines -49 to -51
cloudAWS = "aws"
cloudGCP = "gcp"
cloudAzure = "azure"
Copy link
Member Author

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 {
Copy link
Member Author

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).

Comment on lines +20 to +29
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"
)
Copy link
Member Author

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
Copy link
Member Author

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).

Copy link
Contributor

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{
Copy link
Member Author

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{
Copy link
Member Author

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{}) {
Copy link
Member Author

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
Copy link
Member Author

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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soft lint squiggle

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 5, 2025
@2uasimojo
Copy link
Member Author

/assign @suhanime

Copy link
Contributor

@suhanime suhanime left a 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())
Copy link
Contributor

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
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Member Author

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](
Copy link
Contributor

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.
@suhanime
Copy link
Contributor

suhanime commented Nov 6, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 6, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 6, 2025

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 161a023 and 2 for PR HEAD 9ccaa4c in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 6, 2025

@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.

@openshift-merge-bot openshift-merge-bot bot merged commit d12d5f1 into openshift:master Nov 6, 2025
26 checks passed
@2uasimojo 2uasimojo deleted the le-big-refactor branch November 7, 2025 18:11
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Nov 18, 2025
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.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants