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

Adding method from cvo for capabilities #1333

Conversation

LalatenduMohanty
Copy link
Member

@LalatenduMohanty LalatenduMohanty commented Mar 16, 2022

Moving include() method from CVO

as the code will be reused in OC CLI and CVO. The include() method currently exists in https://github.com/openshift/cluster-version-operator/blob/master/pkg/payload/payload.go#L221 and will be replaced by the code from library-go in future.

@openshift-ci openshift-ci bot requested review from soltysh and sttts March 16, 2022 03:12
@LalatenduMohanty LalatenduMohanty changed the title Adding method from cvo for capabilities [[WIP] Adding method from cvo for capabilities Mar 16, 2022
@LalatenduMohanty LalatenduMohanty changed the title [[WIP] Adding method from cvo for capabilities [WIP] Adding method from cvo for capabilities Mar 16, 2022
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 16, 2022
@LalatenduMohanty LalatenduMohanty force-pushed the adding_method_from_CVO_for_capabilities branch from 6faa0f8 to 3fee090 Compare March 17, 2022 20:30
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 17, 2022
@LalatenduMohanty LalatenduMohanty force-pushed the adding_method_from_CVO_for_capabilities branch 3 times, most recently from df4125f to b0b95fc Compare March 19, 2022 01:22
@LalatenduMohanty
Copy link
Member Author

/test unit

@LalatenduMohanty LalatenduMohanty changed the title [WIP] Adding method from cvo for capabilities Adding method from cvo for capabilities Mar 19, 2022
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 19, 2022
@LalatenduMohanty LalatenduMohanty force-pushed the adding_method_from_CVO_for_capabilities branch from b0b95fc to 62d9b86 Compare March 19, 2022 02:17
@jottofar
Copy link
Contributor

jottofar commented Mar 21, 2022

With the proposed change to not filter on capabilities at load time but rather at apply time I changed include to return the capabilities from a given manifest or an error if an unknown capability is found. That then also replaces method CheckResourceEnablement with GetResourceCapabilities. Like so:

func include(excludeIdentifier string, includeTechPreview bool, profile string, capabilities capability.ClusterCapabilities, manifest *manifest.Manifest) (error, []configv1.ClusterVersionCapability) { ... return capability.GetResourceCapabilities(annotations, capabilities) }

`func GetResourceCapabilities(annotations map[string]string, capabilities ClusterCapabilities) (error, []configv1.ClusterVersionCapability) {
val, ok := annotations[CapabilityAnnotation]
if !ok {
return nil, nil
}
caps := strings.Split(val, "+")
numCaps := len(caps)
unknownCaps := make([]string, 0, numCaps)
allCaps := make([]configv1.ClusterVersionCapability, 0, numCaps)

    for _, c := range caps {
            if _, ok = capabilities.KnownCapabilities[configv1.ClusterVersionCapability(c)]; !ok {
                    unknownCaps = append(unknownCaps, c)
            } else {
                    allCaps = append(allCaps, configv1.ClusterVersionCapability(c))
            }
    }
    if len(unknownCaps) > 0 {
            return fmt.Errorf("unrecognized capability names: %s", strings.Join(unknownCaps, ", ")), nil
    }
    return nil, allCaps

}`

@LalatenduMohanty
Copy link
Member Author

With the proposed change to not filter on capabilities at load time but rather at apply time I changed include to return the capabilities from a given manifest or an error if an unknown capability is found. That then also replaces method CheckResourceEnablement with GetResourceCapabilities

I checked openshift/cluster-version-operator#754 and we should move ahead with this PR merge and once openshift/cluster-version-operator#754 is merged we can move the changes to this repo or even doing the changes directly in this repo. It depends on on the timing of merge of this PR. I am optimistic that we can get this PR merged asap.

pkg/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/manifest/manifest.go Outdated Show resolved Hide resolved
@LalatenduMohanty LalatenduMohanty force-pushed the adding_method_from_CVO_for_capabilities branch 2 times, most recently from d2d9b0c to e35ac89 Compare March 23, 2022 15:38
@LalatenduMohanty
Copy link
Member Author

/retest

pkg/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/manifest/manifest.go Outdated Show resolved Hide resolved
@LalatenduMohanty LalatenduMohanty force-pushed the adding_method_from_CVO_for_capabilities branch 2 times, most recently from f529590 to a6f9855 Compare March 25, 2022 15:18
@LalatenduMohanty LalatenduMohanty force-pushed the adding_method_from_CVO_for_capabilities branch from a6f9855 to 9669aa3 Compare March 25, 2022 15:20
pkg/manifest/manifest.go Outdated Show resolved Hide resolved
Moving from the include() method from CVO code
https://github.com/openshift/cluster-version-operator/blob/master/pkg/payload/payload.go#L221 as the code will be reused in OC CLI

Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>

temp

Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
@LalatenduMohanty LalatenduMohanty force-pushed the adding_method_from_CVO_for_capabilities branch from 9669aa3 to 096d671 Compare March 25, 2022 16:51
Copy link
Member

@wking wking left a comment

Choose a reason for hiding this comment

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

/lgtm

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

openshift-ci bot commented Mar 25, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LalatenduMohanty, wking

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@jottofar
Copy link
Contributor

/hold
This is not the include interface my CVO PR needs. Why not use what I have defined in my PR for include and checkResourceEnablement that returns the resource's validated capabilities?

@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 Mar 25, 2022
@LalatenduMohanty
Copy link
Member Author

/test unit

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 25, 2022

@LalatenduMohanty: all tests passed!

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.

@wking
Copy link
Member

wking commented Mar 28, 2022

Talked with @LalatenduMohanty and @jottofar , and we think this is ok as it stands. And we can always come back and tweak if we're missing something now.

/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 Mar 28, 2022
@openshift-merge-robot openshift-merge-robot merged commit 80342de into openshift:master Mar 28, 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.

None yet

4 participants