Skip to content

OpenstackProviderSpec moved to machine v1alpha1#2117

Merged
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
2uasimojo:HIVE-2308/openstackproviderspec-moved
Sep 19, 2023
Merged

OpenstackProviderSpec moved to machine v1alpha1#2117
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
2uasimojo:HIVE-2308/openstackproviderspec-moved

Conversation

@2uasimojo
Copy link
Copy Markdown
Member

@2uasimojo 2uasimojo commented Sep 18, 2023

Since the recent revendor (#2052 / 26a0b81), OpenstackProviderSpec (embedded in MachineSets under OpenStack) stopped being able to unmarshal. This is because its schema moved from
github.com/openshift/cluster-api-provider-openstack to github.com/openshift/api/machine/v1alpha1 and the revendor picked up this move from the installer code: see
openshift/installer#6382

This commit moves our references accordingly to match that upstream code.

Quirk 1: Strangely, this one type is in o/api/machine v1alpha1 even though everything else in o/api/machine is in v1beta1.

Quirk 2: o/api/machine v1alpha1's registration methods don't actually register the OpenstackProviderSpec type. (Why??) So we have to register it explicitly, as the installer does.

This more or less reverts the prior attempt at #2114 / 1f1ec2c, which turned out to be completely redundant (the added registration call ended up in the same place as the one on the previous line).

HIVE-2308

Since the recent revendor (openshift#2052 / 26a0b81), OpenstackProviderSpec
(embedded in MachineSets under OpenStack) stopped being able to
unmarshal. This is because its schema moved from
github.com/openshift/cluster-api-provider-openstack to
github.com/openshift/api/machine/v1alpha1 and the revendor picked up
this move from the installer code: see
openshift/installer#6382

This commit moves our references accordingly to match that upstream
code.

Quirk 1: Strangely, this one type is in o/api/machine v1alpha1 even
though everything else in o/api/machine is in v1beta1.

Quirk 2: o/api/machine v1alpha1's registration methods don't actually
register the OpenstackProviderSpec type. (Why??) So we have to register
it explicitly, as the installer does.

This more or less reverts the prior attempt at openshift#2114 / 1f1ec2c, which
turned out to be completely redundant (the added registration call ended
up in the same place as the one on the previous line).

HIVE-2308
@2uasimojo
Copy link
Copy Markdown
Member Author

/assign @lleshchi

@openshift-ci openshift-ci Bot requested review from dlom and suhanime September 18, 2023 22:21
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 18, 2023
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 19, 2023

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 19, 2023

Codecov Report

Merging #2117 (43376d8) into master (bb2b8bb) will decrease coverage by 0.01%.
Report is 5 commits behind head on master.
The diff coverage is 40.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2117      +/-   ##
==========================================
- Coverage   57.55%   57.55%   -0.01%     
==========================================
  Files         187      187              
  Lines       25815    25824       +9     
==========================================
+ Hits        14859    14864       +5     
- Misses       9711     9715       +4     
  Partials     1245     1245              
Files Changed Coverage Δ
pkg/controller/machinepool/openstackactuator.go 0.00% <0.00%> (ø)
pkg/util/scheme/scheme.go 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

@lleshchi
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 19, 2023
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 19, 2023

[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

@2uasimojo
Copy link
Copy Markdown
Member Author

tide seems to be sleeping.

But I want to add some UT for this niche anyway.

/hold

@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 Sep 19, 2023
@2uasimojo
Copy link
Copy Markdown
Member Author

I want to add some UT for this niche

Well, that turns out not to be possible. The existing UT for this code path is disabled, noted as broken, because the installer's MachineSets() func tries to call into OpenStack.

We can't mock any part of this because there are no interfaces.

We can't bypass it and call generateProviderSpec directly because it's private.

And that's as low as we could go while still achieving the goal of matching the GroupVersion of the returned OpenstackProviderSpec.

Le sigh.

/hold cancel

@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 Sep 19, 2023
@openshift-merge-robot openshift-merge-robot merged commit 5121695 into openshift:master Sep 19, 2023
@2uasimojo 2uasimojo deleted the HIVE-2308/openstackproviderspec-moved branch September 19, 2023 16:57
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 2, 2024
Another attempt to address the move of OpenstackProviderSpec from
cluster-api-provider-openstack to openstack/api/machine. See openshift#2117 for
background. In that PR, we simply replaced our imports. The result is
that we could only decode the _new_ thing. The problem is that we may
still get the _old_ thing if we're talking to an old cluster.

We only need the decoding to steal the osImage from the master machines
so we can use that value for new workers. Rather than importing both
schemata, trying to figure out which version we're talking to, and
decoding against the correct one, this commit unmarshals the
providerSpec as raw JSON into an Unstructured object and explicitly
paths into it map-wise.

On the creation side, we're told that the spoke cluster itself will
understand the new thing even if it's an old version (MAPI also
unmarshals the JSON raw). So it should be fine to continue using recent
vendored installer code to generate MachineSets (which will contain
new-apiVersion OpenstackProviderSpec).

HIVE-2308
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 4, 2024
Another attempt to address the move of OpenstackProviderSpec from
cluster-api-provider-openstack to openstack/api/machine. See openshift#2117 for
background. In that PR, we simply replaced our imports. The result is
that we could only decode the _new_ thing. The problem is that we may
still get the _old_ thing if we're talking to an old cluster.

We only need the decoding to steal the osImage from the master machines
so we can use that value for new workers. Rather than importing both
schemata, trying to figure out which version we're talking to, and
decoding against the correct one, this commit unmarshals the
providerSpec as raw JSON into an Unstructured object and explicitly
paths into it map-wise.

On the creation side, we're told that the spoke cluster itself will
understand the new thing even if it's an old version (MAPI also
unmarshals the JSON raw). So it should be fine to continue using recent
vendored installer code to generate MachineSets (which will contain
new-apiVersion OpenstackProviderSpec).

HIVE-2308
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 6, 2024
Another attempt to address the move of OpenstackProviderSpec from
cluster-api-provider-openstack to openstack/api/machine. See openshift#2117 for
background. In that PR, we simply replaced our imports. The result is
that we could only decode the _new_ thing. The problem is that we may
still get the _old_ thing if we're talking to an old cluster.

We only need the decoding to steal the osImage from the master machines
so we can use that value for new workers. Rather than importing both
schemata, trying to figure out which version we're talking to, and
decoding against the correct one, this commit unmarshals the
providerSpec as raw JSON into an Unstructured object and explicitly
paths into it map-wise.

On the creation side, we're told that the spoke cluster itself will
understand the new thing even if it's an old version (MAPI also
unmarshals the JSON raw). So it should be fine to continue using recent
vendored installer code to generate MachineSets (which will contain
new-apiVersion OpenstackProviderSpec).

HIVE-2308
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 6, 2024
Another attempt to address the move of OpenstackProviderSpec from
cluster-api-provider-openstack to openstack/api/machine. See openshift#2117 for
background. In that PR, we simply replaced our imports. The result is
that we could only decode the _new_ thing. The problem is that we may
still get the _old_ thing if we're talking to an old cluster.

We only need the decoding to steal the osImage from the master machines
so we can use that value for new workers. Rather than importing both
schemata, trying to figure out which version we're talking to, and
decoding against the correct one, this commit unmarshals the
providerSpec as raw JSON into an Unstructured object and explicitly
paths into it map-wise.

On the creation side, we're told that the spoke cluster itself will
understand the new thing even if it's an old version (MAPI also
unmarshals the JSON raw). So it should be fine to continue using recent
vendored installer code to generate MachineSets (which will contain
new-apiVersion OpenstackProviderSpec).

HIVE-2308
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 6, 2024
Another attempt to address the move of OpenstackProviderSpec from
cluster-api-provider-openstack to openstack/api/machine. See openshift#2117 for
background. In that PR, we simply replaced our imports. The result is
that we could only decode the _new_ thing. The problem is that we may
still get the _old_ thing if we're talking to an old cluster.

We only need the decoding to steal the osImage from the master machines
so we can use that value for new workers. Rather than importing both
schemata, trying to figure out which version we're talking to, and
decoding against the correct one, this commit unmarshals the
providerSpec as raw JSON into an Unstructured object and explicitly
paths into it map-wise.

On the creation side, we're told that the spoke cluster itself will
understand the new thing even if it's an old version (MAPI also
unmarshals the JSON raw). So it should be fine to continue using recent
vendored installer code to generate MachineSets (which will contain
new-apiVersion OpenstackProviderSpec).

HIVE-2308

(cherry picked from commit 28dac77)
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 6, 2024
Another attempt to address the move of OpenstackProviderSpec from
cluster-api-provider-openstack to openstack/api/machine. See openshift#2117 for
background. In that PR, we simply replaced our imports. The result is
that we could only decode the _new_ thing. The problem is that we may
still get the _old_ thing if we're talking to an old cluster.

We only need the decoding to steal the osImage from the master machines
so we can use that value for new workers. Rather than importing both
schemata, trying to figure out which version we're talking to, and
decoding against the correct one, this commit unmarshals the
providerSpec as raw JSON into an Unstructured object and explicitly
paths into it map-wise.

On the creation side, we're told that the spoke cluster itself will
understand the new thing even if it's an old version (MAPI also
unmarshals the JSON raw). So it should be fine to continue using recent
vendored installer code to generate MachineSets (which will contain
new-apiVersion OpenstackProviderSpec).

HIVE-2308

(cherry picked from commit 28dac77)
(cherry picked from commit 567cdd3)
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