Skip to content

Comments

Allow to define several API groups#157

Merged
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
Fedosin:apigroups
Feb 24, 2022
Merged

Allow to define several API groups#157
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
Fedosin:apigroups

Conversation

@Fedosin
Copy link
Contributor

@Fedosin Fedosin commented Feb 23, 2022

Currently approver can work with just one API group, which is defined by --apigroup option. This patch allows to set several API groups, so that the component is able to approve certificates for machines created by various APIs.

For OpenShift it means that we don't have to deploy 2 approvers: one for MAPI and another for CAPI. Instead we can use one instance that manages them all.

Also, using of api-group-version instead of just api-group allows us to define what API version we'd like to use. It's important because In openshift/machine-api-operator#992, we are introducing a new CRD which is in the machine.openshift.io/v1 group. This means that the server preferred version of the API is now v1 and not v1beta1. Because Machines don't yet exist in the v1 group, this means the CMA is currently broken on that PR.

E0223 11:12:04.550754       1 controller.go:134] csr-mwwzt: Failed to list machines: no matches for kind "Machine" in version "machine.openshift.io/v1"

If we were to merge openshift/machine-api-operator#992 we would break the CMA across openshift. To mitigate this, we must allow the version to be set manually as a part of api-group-version, and only rely on discovery when the preferred version is not set there.

Deprecations:
--apigroup is deprecated in favor of --apigroupversion option

New options:
--api-group-version allows to specify both API group and version. This option can be given multiple times.

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

I understood from slack that we would be adding versioning to this, but it doesn't seem to be handled yet? What's the plan here?

@Fedosin Fedosin force-pushed the apigroups branch 3 times, most recently from 9e69b21 to 2495880 Compare February 23, 2022 15:57
main.go Outdated
if len(apiGroupVersions) > 0 {
// Parsing API Group Versions
for _, apiGroupVersion := range apiGroupVersions {
parsedAPIGroupVersion, err := schema.ParseGroupVersion(apiGroupVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

This parse function assumes that if you haven't got a slash, the entire string is the version, that's not our intended behaviour right?

Copy link
Contributor

Choose a reason for hiding this comment

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

If that is our intended behaviour, please document it within the flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I updated the patch - now a string without / means the group, not the version. It is described in the description

@enxebre
Copy link
Member

enxebre commented Feb 23, 2022

Can you please clarify on the desc what's the use case that motivates this change?

@JoelSpeed
Copy link
Contributor

Can you please clarify on the desc what's the use case that motivates this change?

The versioning motivation is because of introducing new v1 resources within machine.openshift.io, I had originally raised #156

The multiple groups is because, at the moment, having a CAPI and MAPI CSR approver causes lots of errors in the logs. Half the CSRs cannot be approved by one or the other, so if we want to reduce the errors, we need to just have a single CMA within the cluster that can handle both types

@JoelSpeed
Copy link
Contributor

I'm happy with the code changes, but would like to check with @enxebre about his concerns before we merge

@enxebre
Copy link
Member

enxebre commented Feb 24, 2022

ok thanks I see, why did we put this APIs in v1 https://github.com/openshift/api/tree/master/machine/v1 rather than being with the core types in v1beta1?

@JoelSpeed
Copy link
Contributor

@Fedosin can you update the PR so that the CMA deployed on HA clusters has the correct flag? That file is in the same folder

@JoelSpeed
Copy link
Contributor

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 24, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoelSpeed

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 24, 2022
@elmiko
Copy link
Contributor

elmiko commented Feb 24, 2022

ok thanks I see, why did we put this APIs in v1 https://github.com/openshift/api/tree/master/machine/v1 rather than being with the core types in v1beta1?

we've been asked to not bring new API objects into the v1beta1 version. that's why we created the alibaba providerspec in the v1, and also for the placement groups as well. as i understand it, the api team does not want to introduce new resources in the v1beta1 version, and i gather this has to do with our support life cycle around APIs that are not v1.

you can see David's explanation (which is much better than mine) here: openshift/api#1045 (comment)

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

/lgtm cancel

This is broken right now as both flags are set (the old flag needs its default removed)

main.go Outdated
if err := validateAPIGroup(APIGroup); err != nil {
klog.Fatalf(err.Error())
// Deprecated options
flagSet.StringVar(&apiGroup, "apigroup", "machine.openshift.io", "API group for machines")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should now have an empty value else you can't set the new flag

Suggested change
flagSet.StringVar(&apiGroup, "apigroup", "machine.openshift.io", "API group for machines")
flagSet.StringVar(&apiGroup, "apigroup", "", "API group for machines")

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2022
Currently approver can work with just one API group, which is defined
by --apigroup option. This patch allows to set several API groups,
so that the component is able to approve certificates for machines
created by various APIs.

Deprecations:
--apigroup is deprecated in favor of --apigroupversion option

New options:
--api-group-version allows to specify both API group and
version. This option can be given multiple times.
@JoelSpeed
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2022
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

3 similar comments
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 24, 2022

@Fedosin: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-disruptive 6ad15dc link false /test e2e-aws-disruptive
ci/prow/e2e-azure-operator 6ad15dc link false /test e2e-azure-operator

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.

@openshift-merge-robot openshift-merge-robot merged commit 897738a into openshift:master Feb 24, 2022
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.

6 participants