-
Notifications
You must be signed in to change notification settings - Fork 96
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
✨ Add Support for FailureDomains #793
Open
sf1tzp
wants to merge
4
commits into
metal3-io:main
Choose a base branch
from
sf1tzp:failure-domains
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!
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.
@lentzi90 Sorry, I'm uninitated on conversion-gen. In the
make generate
output, I seeAnd in the generated conversion file
But I am not sure where to make this manual conversion. I read a bit into it, and found in our v1alpha5
doc.go
Which looks right... but do I need to add annotations to the M3Cluster and M3Machine types in v1alpha5 as well?
If you could help point me in the right direction, I would appreciate it! :) Thanks!
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.
Sure!
Since you are adding a new field here to v1beta1 that does not exist in v1alpha5, conversion-gen does not know what to do with it. We cannot really do anything about it, other than just dropping the field and "taking the responsibility" for it 😅 . We do that by creating a conversion function and then just calling the automatically generated function, similar to this:
cluster-api-provider-metal3/api/v1alpha5/conversion.go
Lines 219 to 232 in cde6c51
In other words, you need to add something like
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.
Ah okay, thank you! I should have looked at this file, maybe I would have figured it out on my own. One more question though, why are we converting from v1beta1 to v1alpha5? Shouldn't these conversions be forward-looking?
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.
We actually convert both ways. 🙂 This is a common pattern, and it works like this: There is one version that the controller handles, that is called the "hub" version. Then there can be any number of other supported versions called "spoken" versions. We add conversion functions to convert between the hub and the spoken versions (not between spoken versions directly, everything is always converted to/from the hub).
This system allows the controller to support any number of API versions simultaneously as long as we can convert them to/from the hub. The user can work with v1alpha5 as long as it is supported even though the controller is actually working with v1beta1. If the user asks for an object using v1alpha5, the webhook automatically converts it before returning it. Similarly, if the user creates an object using v1alpha5, it will be automatically converted and stored as v1beta1.
Kube-builder has some nice documentation around this if you want to read more: https://book.kubebuilder.io/multiversion-tutorial/conversion-concepts
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.
Thank you for explaining! And for the link. Cheers