Skip to content

Revendor installer, repair OpenStack MachinePool UT#2251

Merged
openshift-merge-bot[bot] merged 3 commits intoopenshift:masterfrom
2uasimojo:HIVE-2476/repair-openstack-machinepool-ut
Apr 2, 2024
Merged

Revendor installer, repair OpenStack MachinePool UT#2251
openshift-merge-bot[bot] merged 3 commits intoopenshift:masterfrom
2uasimojo:HIVE-2476/repair-openstack-machinepool-ut

Conversation

@2uasimojo
Copy link
Member

@2uasimojo 2uasimojo commented Mar 28, 2024

A subsequent PR will use this to

  • Expand unit tests to reproduce the error in the referenced card
  • Fix it.

Part of HIVE-2476

@openshift-ci openshift-ci bot requested review from dlom and lleshchi March 28, 2024 21:31
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 28, 2024
@2uasimojo
Copy link
Member Author

/assign @lleshchi
/cc @pierreprinetti

Specifically to pick up openshift/installer#8187
and openshift/installer#8209 so we can fix our
unit tests around MachinePools+OpenStack. But also just because we do
this periodically.

Needed by HIVE-2476
A prior commit revendored installer to pull in
openshift/installer#8187 and
openshift/installer#8209 which decoupled the
OpenStack cloud call for trunk support discovery from the
`MachineSets()` generator.

This commit refactors our invocation of that generator accordingly, and
repairs our long-broken unit test framework around it by attaching a
`trunkSupportDiscoverer` func to the actuator. In the production code
path, this is set to the `CheckNetworkExtensionAvailability` function
publicized by the aforementioned installer PRs, whereas in the unit test
path it is set to a no-op shim. Future tests can make this shim return
any permutation of possible values to exercise different code paths.

Subsequent commits will enhance this unit test suite to reproduce the
issue in the referenced card.

Part of HIVE-2476
logger: logger,
osImage: osImage,
kubeClient: kubeClient,
trunkSupportDiscoverer: installosp.CheckNetworkExtensionAvailability,
Copy link
Member

Choose a reason for hiding this comment

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

nit: the function can be scoped to only care about the Trunk extension, if that's all we're interested about:

type OpenStackActuator struct {
	// ...
	trunkSupportDiscoverer func(cloud string, opts *clientconfig.ClientOpts) (bool, error)
actuator := &OpenStackActuator{
	// ...
	trunkSupportDiscoverer: func(cloud string, opts *clientconfig.Clientopts) (bool, error) {
		return installosp.CheckNetworkExtensionAvailability(cloud, "trunk", opts)
	},

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review!

I like your suggestion. (And actually since we know we're passing in a non-nil opts we could even use a dummy/nil value for cloud -- though that does require knowledge of the internals of CheckNetworkExtensionAvailability and is thus not particularly future-proof.)

I feel like this controller has way too many func-of-func indirections already, and the existing approach is just a tiny bit cleaner looking. So I might keep it.

@lleshchi what are your thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I also think you should use what your team is used to! :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I do think the current approach is cleaner in terms of readability

@2uasimojo 2uasimojo force-pushed the HIVE-2476/repair-openstack-machinepool-ut branch from a493487 to 632f4be Compare March 29, 2024 23:03
@2uasimojo
Copy link
Member Author

/cc @patrickdillon

would you please have a look at the third commit, which incorporates the new CAPI SG filters from openshift/installer#8006

@openshift-ci openshift-ci bot requested a review from patrickdillon March 29, 2024 23:05
@codecov
Copy link

codecov bot commented Mar 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.47%. Comparing base (fe0e302) to head (6de60ba).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2251      +/-   ##
==========================================
+ Coverage   58.32%   58.47%   +0.14%     
==========================================
  Files         182      182              
  Lines       25704    25719      +15     
==========================================
+ Hits        14993    15038      +45     
+ Misses       9452     9411      -41     
- Partials     1259     1270      +11     
Files Coverage Δ
pkg/controller/machinepool/awsactuator.go 77.43% <ø> (+0.06%) ⬆️
pkg/controller/machinepool/openstackactuator.go 50.00% <ø> (+30.90%) ⬆️
pkg/installmanager/installmanager.go 33.50% <ø> (+0.39%) ⬆️

@2uasimojo
Copy link
Member Author

/test e2e-gcp

A previous commit revendored installer which picked up
openshift/installer#8006 which adds two default
security group filters. We need to take this into account when the
`extra-worker-security-group` annotation is in play, as we need to add
that additional SG name and its VPC filter to *all* the SecurityGroups
in the worker MachineSets. This needs to be done both for day 0 (install
manager) and day 2 (MachinePool controller).

Carried along with HIVE-2476
@2uasimojo 2uasimojo force-pushed the HIVE-2476/repair-openstack-machinepool-ut branch from 632f4be to 6de60ba Compare April 1, 2024 22:26
@lleshchi
Copy link
Contributor

lleshchi commented Apr 2, 2024

/test e2e-gcp

1 similar comment
@2uasimojo
Copy link
Member Author

/test e2e-gcp

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 2, 2024

@2uasimojo: all tests passed!

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@lleshchi
Copy link
Contributor

lleshchi commented Apr 2, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2024
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 2uasimojo, lleshchi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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-merge-bot openshift-merge-bot bot merged commit 5f27f3c into openshift:master Apr 2, 2024
@2uasimojo 2uasimojo deleted the HIVE-2476/repair-openstack-machinepool-ut branch April 2, 2024 21:49
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Apr 30, 2024
This is *not* a cherry-pick of openshift#2253 / (c6b37ee & f59f327). That
solution revendored installer to pick up the fix from upstream. In older
branches, this would have dragged in too many dependencies, so we
instead fix it "locally" with an explicit nil check.

Note also that the original fix added unit tests. We can't do that here
either because the new tests rely on the OpenStack UT suite being
un-broken [1], which again relied on upstream changes [2][3] we can't pull into
older branches.

[1] openshift#2251
[2] openshift/installer#8187
[3] openshift/installer#8209

HIVE-2476
assert.Contains(t, awsMachineTemplate.SecurityGroups[0].Filters[1].Values, "testvpc123", "expected testvpc123 to be configured within Security Group Filters in AWSMachineProviderConfig")
if assert.Equal(t, tc.expectModified, len(awsMachineTemplate.SecurityGroups), "unexpected number of security groups") {
for i := 0; i < tc.expectModified; i++ {
assert.Contains(t, awsMachineTemplate.SecurityGroups[i].Filters[0].Values, "test-security-group", "expected test-security-group to be configured within Security Group Filters in AWSMachineProviderConfig")
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to verify that this contains the original name (test-czcpt-worker-sg) as well!

openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/hive that referenced this pull request Aug 8, 2024
This is *not* a cherry-pick of openshift#2253 / (c6b37ee & f59f327). That
solution revendored installer to pick up the fix from upstream. In older
branches, this would have dragged in too many dependencies, so we
instead fix it "locally" with an explicit nil check.

Note also that the original fix added unit tests. We can't do that here
either because the new tests rely on the OpenStack UT suite being
un-broken [1], which again relied on upstream changes [2][3] we can't pull into
older branches.

[1] openshift#2251
[2] openshift/installer#8187
[3] openshift/installer#8209

HIVE-2476
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/hive that referenced this pull request Aug 9, 2024
This is *not* a cherry-pick of openshift#2253 / (c6b37ee & f59f327). That
solution revendored installer to pick up the fix from upstream. In older
branches, this would have dragged in too many dependencies, so we
instead fix it "locally" with an explicit nil check.

Note also that the original fix added unit tests. We can't do that here
either because the new tests rely on the OpenStack UT suite being
un-broken [1], which again relied on upstream changes [2][3] we can't pull into
older branches.

[1] openshift#2251
[2] openshift/installer#8187
[3] openshift/installer#8209

HIVE-2476
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