Skip to content

Conversation

@perdasilva
Copy link
Contributor

This PR adds the Global Constraints variable source. It groups all BundleVariables by their underlying entity's package and provided gvks and emits GlobalConstraintsVariables that constrain the solution to only have one bundle for any given package and one bundle for any given provided gvk.

@perdasilva perdasilva changed the title [resolution Pt4] global constraints variable source [resolution pt.4] - global constraints variable source Jan 24, 2023
@perdasilva perdasilva changed the title [resolution pt.4] - global constraints variable source [resolution pt.4] global constraints variable source Jan 24, 2023
@perdasilva perdasilva force-pushed the resolution_pt4_global_constraints branch from 35a3f8f to afe1b58 Compare January 25, 2023 14:44
// get bundleID package and update map
packageName, err := bundleEntity.PackageName()
if err != nil {
return nil, fmt.Errorf("error creating global constraints: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

wrap err via %w, here and below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done a project search and hopefully addressed all of them (I'll check the next branches too)

Copy link
Contributor

Choose a reason for hiding this comment

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

Odd... this is still showing up as %s?

Copy link
Contributor

Choose a reason for hiding this comment

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

Other than this, looks fine.

Copy link
Member

Choose a reason for hiding this comment

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

I see this too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmmm - maybe I screwed something up - hold on (sorry for this!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@perdasilva perdasilva force-pushed the resolution_pt4_global_constraints branch from afe1b58 to 859ac6e Compare January 26, 2023 12:58
Copy link
Member

@awgreene awgreene left a comment

Choose a reason for hiding this comment

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

Great work @perdasilva, I had one question regarding the returned variables, but this looks good otherwise.

Comment on lines 19 to 23
func NewGlobalConstraintsVariable(id deppy.Identifier, atMostIDs ...deppy.Identifier) *GlobalConstraintsVariable {
return &GlobalConstraintsVariable{
SimpleVariable: input.NewSimpleVariable(id, constraint.AtMost(1, atMostIDs...)),
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that I would infer that theNewGlobalConstraintsVariable function name implies that a single entity will be selected. Could you explain why it can be infered or add a comment or change the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's fair. Let me see if I can find a better name. I think I've been using global constraints for so long I just assumed it was a thing =P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried to refactor to a different name - hopefully it will be more descriptive

ctx = context.Background()

// the entity is not used in this variable source
entitySource = &PanicEntitySource{}
Copy link
Member

@awgreene awgreene Jan 26, 2023

Choose a reason for hiding this comment

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

For sake of clarification, the NewGlobalConstraintsVariableSource shouldn't reach out to the entity source because it's used to enforce GVK and Package uniqueness, which is effectively hardcoded in OLM, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup - that's right - but it still needs to pass it to its inputVariableSource (and that one could use it)

Copy link
Member

Choose a reason for hiding this comment

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

Right, makes sense.

property.TypeGVKRequired: `[{"group":"foo.io","kind":"Foo","version":"v1"}]`,
property.TypeGVK: `[{"group":"bit.io","kind":"Bit","version":"v1"}]`,
}),
"bundle-2": input.NewEntity("bundle-2", map[string]string{
Copy link
Member

Choose a reason for hiding this comment

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

Oddly enough we jumped over "bundle-3".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah - fixed it =D

}
variables, err := globalConstraintVariableSource.GetVariables(ctx, entitySource)
Expect(err).ToNot(HaveOccurred())
Expect(len(variables)).To(Equal(26))
Copy link
Member

Choose a reason for hiding this comment

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

How do we land on 26 variables? I counted 16 bundles defined in the bundleSet and I see that we have 11 globalConstraintVariables below, which adds up to 27.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I keep getting a different count‽‽

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh oh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah ok - so, it receives 15 variables upstream from it and produces another 11. It seems to be correct.
Basically, you have the required package variables, the bundle variables, and it spits out the uniqueness variables.

@perdasilva perdasilva force-pushed the resolution_pt4_global_constraints branch from 859ac6e to 9ab3a4c Compare January 26, 2023 16:45
Signed-off-by: perdasilva <perdasilva@redhat.com>
@perdasilva perdasilva force-pushed the resolution_pt4_global_constraints branch from 9ab3a4c to 25465b9 Compare January 26, 2023 16:45
@perdasilva perdasilva changed the title [resolution pt.4] global constraints variable source [resolution pt.4] crd uniquenss constraints variable source Jan 26, 2023
@perdasilva perdasilva changed the title [resolution pt.4] crd uniquenss constraints variable source [resolution pt.4] crd uniqueness constraints variable source Jan 26, 2023
@perdasilva
Copy link
Contributor Author

@awgreene @tmshort Another avenue here might be to break this into two variable sources: CRDUniquenessVariableSource and PackageUniquenessVariableSource - wdyt?

@awgreene
Copy link
Member

@perdasilva I'm happy with the existing changes.
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 26, 2023
@perdasilva perdasilva added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 26, 2023
@perdasilva perdasilva merged commit 768d838 into operator-framework:main Jan 26, 2023
LalatenduMohanty pushed a commit to LalatenduMohanty/operator-controller that referenced this pull request Dec 19, 2024
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
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