Skip to content
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

Closed
wants to merge 7 commits into from
Closed

WIP: Moved oVirt installconfig to externalprovider #4517

wants to merge 7 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 4, 2021

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.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 4, 2021
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign sdodson after the PR has been reviewed.
You can assign the PR to them by writing /assign @sdodson in a comment when ready.

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

Copy link
Contributor

@Gal-Zaidman Gal-Zaidman left a 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.
Copy link
Contributor

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

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

[1]https://github.com/openshift/installer/pull/4517/files?file-filters%5B%5D=.go#diff-95c3eb6370ff093d7d65c61022511d7286d41e57f067925081077b6ded9fb55fR3

Copy link
Author

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

Copy link
Contributor

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?

Copy link
Author

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

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

Copy link
Author

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

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.

Copy link
Author

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.

Comment on lines +25 to +28
Config *types.InstallConfig,
File *asset.File,
AWS *aws.Metadata,
Azure *icazure.Metadata,
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

@patrickdillon patrickdillon Jan 4, 2021

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.

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

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.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 14, 2021

@janoszen: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/yaml-lint 0091074 link /test yaml-lint
ci/prow/e2e-aws-fips 0091074 link /test e2e-aws-fips
ci/prow/e2e-aws-upgrade 0091074 link /test e2e-aws-upgrade
ci/prow/openstack-manifests 0091074 link /test openstack-manifests

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.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 15, 2021
@mtnbikenc
Copy link
Member

/uncc

@openshift-ci-robot openshift-ci-robot removed the request for review from mtnbikenc April 22, 2021 15:32
@staebler
Copy link
Contributor

/lifecycle frozen

@openshift-ci-robot
Copy link
Contributor

@staebler: The lifecycle/frozen label cannot be applied to Pull Requests.

In response to this:

/lifecycle frozen

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.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 29, 2021

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

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 29, 2021
@ghost ghost closed this Apr 29, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants