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

server/apiextensions: use indexes and fixes #1294

Merged
merged 3 commits into from
Jun 22, 2022

Conversation

sttts
Copy link
Member

@sttts sttts commented Jun 20, 2022

  • fix meta data lookup to only be for wildcard requests
  • fix cache mutation
  • use indexes.

@openshift-ci openshift-ci bot requested review from ncdc and stevekuznetsov June 20, 2022 06:48
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 20, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sttts

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 20, 2022
@sttts sttts force-pushed the sttts-apiextensions-index branch from fe70dcb to 2fb0837 Compare June 20, 2022 10:50
@sttts
Copy link
Member Author

sttts commented Jun 20, 2022

/assign @ncdc

@sttts sttts force-pushed the sttts-apiextensions-index branch from 2fb0837 to d8da562 Compare June 21, 2022 22:17
@@ -235,16 +227,12 @@ func (c *apiBindingAwareCRDLister) List(ctx context.Context, selector labels.Sel
seen.Insert(crdName(kcpSystemCRDs[i]))
}

apiBindings, err := c.apiBindingLister.List(labels.Everything())
objs, err := c.apiBindingIndexer.ByIndex(byWorkspace, clusterName.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

okay, so it replaces logicalcluster.From(apiBinding) != clusterName

@@ -257,7 +245,7 @@ func (c *apiBindingAwareCRDLister) List(ctx context.Context, selector labels.Sel
continue
}

if !matchesSelector(crd) {
if !selector.Matches(labels.Set(crd.Labels)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't have to check if the selector is empty anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

empty = match all

Copy link
Contributor

Choose a reason for hiding this comment

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

ic

for _, obj := range objs {
crd := obj.(*apiextensionsv1.CustomResourceDefinition)

if !selector.Matches(labels.Set(crd.Labels)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

okay, ic, the same labels needs to be applied here.


switch {
case identity != "":
if identity != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

this if, else statement looks okay to me

for _, v := range crd.Spec.Versions {
v.Schema = &apiextensionsv1.CustomResourceValidation{
old := crd.Spec.Versions
crd.Spec.Versions = make([]apiextensionsv1.CustomResourceDefinitionVersion, len(old))
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is a slice, I think it should be make([]apiextensionsv1.CustomResourceDefinitionVersion, 0, len(old))

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, nvm, you index down below

@@ -332,7 +321,7 @@ func (c *apiBindingAwareCRDLister) Refresh(crd *apiextensionsv1.CustomResourceDe
}

// Start with a shallow copy
refreshed := shallowCopyCRD(updatedCRD)
refreshed := shallowCopyCRDAndDeepCopyAnnotations(updatedCRD)
Copy link
Contributor

Choose a reason for hiding this comment

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

w00t? why are we modifying a live object? can we ensure no one else is actually using the obj?

Copy link
Contributor

Choose a reason for hiding this comment

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

ic, we acquire a lock

@p0lyn0mial
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2022
@openshift-ci openshift-ci bot merged commit 30c1a4b into kcp-dev:main Jun 22, 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.

3 participants