-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
WIP: Moved oVirt installconfig to externalprovider #4517
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Code looks good
|
||
// InstallConfigExternalProvider describes the methods required for the installconfig asset. | ||
type InstallConfigExternalProvider interface { | ||
// AddToInstallConfigPlatform adds the current platform to the installconfig. |
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.
Maybe change to "adds the current provider to the installconfig Platform"
) | ||
|
||
// InstallConfigExternalProvider describes the methods required for the installconfig asset. | ||
type InstallConfigExternalProvider 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.
The name is a bit confusing "InstallConfigExternalProvider", I understood that platforms are the "external providers", because of "ExternalProvider is a provider that is not maintained by the core installer team." [1] maybe you should use a different name? it seems like the InstallConfigExternalProvider is something that the installer team will want to maintain
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'm up for ideas instead of "External Provider", I'd like to wait for some feedback from the installer team on this.
package externalprovider | ||
|
||
var providerRegistry = NewRegistry() | ||
|
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.
can you just name the file "api" why simple?
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.
Ideally, at some point this API should be removed, but that's up in the air.
func ValidateInstallConfig( | ||
ProviderName Name, | ||
Config *types.InstallConfig, | ||
File *asset.File, |
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.
Seems like most providers will not need File, AWS or Azure...
This is totally a design decision and I can go either way here, maybe a variadic function with the empty interface(a ...interface{}) can replace it?
I just hate to ignore them for all providers just because it is needed by some...
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 API is designed to 1:1 replace the current switch-cases with minimal changes to the code. Adding parameters to existing APIs is harder than adding new API calls.
@@ -0,0 +1,10 @@ | |||
package provider | |||
|
|||
// ExternalProvider is a provider that is not maintained by the core installer team. |
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.
Perfect example of Conway's Law
I don't think the providers should be grouped based on installer team/non-installer team.
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 API is designed to be consumable by all providers, but I'm pragmatic about the adoption.
Config *types.InstallConfig, | ||
File *asset.File, | ||
AWS *aws.Metadata, | ||
Azure *icazure.Metadata, |
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 would make more sense to just have this signature match the dependencies of the asset being genereated:
https://github.com/openshift/installer/blob/master/pkg/asset/installconfig/platformcredscheck.go#L37
oVirt should never have a function that takes *aws.Metadata
as a parameter.
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.
That is true, but the API is designed to be adopted by all providers, so I added all parameters that are used by any provider at this time. Adding new methods is easier than adding new parameters to existing methods.
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.
IMHO my suggestion would make it easier and more ergonomic for this API to be adopted by all providers. Also, I meant this as a general suggestion. The one function I picked here is just an example, but this should be applied to all platform interface functions related to an asset. By mapping the parameters to the asset dependencies you ensure that every platform would have all needed resources. It would then be the responsibility of the provider to extract those resources from the dependencies.
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.
Ideally, we would pass on the install config directly, but if we do that we have a circular dependency because the IC structure is in the same package as the code needing to call the new API.
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, I see how the circular dependency is a problem now. I think there should be a way around the circular dependency by having a common interface. The asset package should not really need to depend on the external providers, and I think that is a benefit of the approach. I think moving the definition of the interface to the asset package could resolve this, but it is a bit too much for me to map it all out now.
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 main issue is this piece of code:
func init() {
providerRegistry.Register(ovirt.NewOvirtProvider())
}
If we can call this from somewhere that is not in the installconfig flow (e.g. some main.go) then that would solve the whole problem as the registry and the API interface could be split into two packages resolving the circular dependency. However, I don't know what would be a good place to add this.
@janoszen: The following tests failed, say
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/test-infra repository. I understand the commands that are listed here. |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
/uncc |
/lifecycle frozen |
@staebler: The In response to this:
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. |
@janoszen: PR needs rebase. 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. |
This is the first PR of many as detailed in openshift/enhancements/pull/566. This PR is WIP and intended as a basis for discussion and will be amended later.