-
Notifications
You must be signed in to change notification settings - Fork 544
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
Enable OLM to update CRD when there is only one owner of that CRD #878
Enable OLM to update CRD when there is only one owner of that CRD #878
Conversation
/retest |
b8951c6
to
014856a
Compare
/retest |
d6590c3
to
dbe3059
Compare
dbe3059
to
944a940
Compare
Ready for final review and approval for merging :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good! Have a few comments that are mostly non-blocking.
func ProvidedAPIsIndexFunc(obj interface{}) ([]string, error) { | ||
indicies := []string{} | ||
|
||
csv, ok := obj.(*v1alpha1.ClusterServiceVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: this is probably a good place to use OLM's internal versions. If #881 merges first, that could look like:
import (
// ...
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators"
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/install"
// ...
)
// ...
var scheme = runtime.NewScheme()
func init() {
// Register internal types and conversion funcs
install.Install(scheme)
}
// ...
func ProvidedAPIsIndexFunc(obj interface{}) ([]string, error) {
var indices []string
csv := &operators.ClusterServiceVersion{}
if err := scheme.Convert(obj, csv, nil); err != nil {
return indices, fmt.Errorf("cannot generate indices for object of type %T", obj)
}
// ...
}
// ...
@@ -0,0 +1,66 @@ | |||
package indexer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not-blocking: we should probably move all of the OLM specific stuff out of lib.
pkg/lib/index/api.go
Outdated
if len(parts) < 2 { | ||
return indicies, fmt.Errorf("couldn't parse plural.group from crd name: %s", crd.Name) | ||
} | ||
indicies = append(indicies, fmt.Sprintf("provided=%s/%s/%s", parts[1], crd.Version, crd.Kind)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think "provided=" is necessary.
pkg/lib/index/api.go
Outdated
} | ||
|
||
// APIsIndexValues returns the names of CSVs that own the given CRD | ||
func APIsIndexValues(indexers map[string]cache.Indexer, crd v1beta1ext.CustomResourceDefinition) (map[string]struct{}, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: CRDProviderNames(...)
?
expectedCRDVersions[key] = struct{}{} | ||
} | ||
|
||
mainCSV := newCSV(mainPackageStable, testNamespace, "", semver.MustParse("0.1.0"), []apiextensions.CustomResourceDefinition{mainCRD}, nil, mainNamedStrategy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to build a catalog with both CRDs and have the new CSV replace the original instead of deleting/recreating the subscription?
@@ -641,6 +642,176 @@ func TestCreateInstallPlanWithPreExistingCRDOwners(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestUpdateInstallPlan(t *testing.T) { | |||
defer cleaner.NotifyTestComplete(t, true) | |||
t.Run("UpdateSingleExistingCRDOwner", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I think we also want a negative test-case; i.e. CRD upgrade is blocked from a pre-existing owner.
8d37369
to
dad2344
Compare
fetchedCRD, err := c.ApiextensionsV1beta1Interface().ApiextensionsV1beta1().CustomResourceDefinitions().Get(crdName, metav1.GetOptions{}) | ||
require.NoError(t, err) | ||
|
||
for _, version := range fetchedCRD.Spec.Versions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks that every version in fectchedCRD
is in expectedCRDVersions
, but it doesn't check that every version in expectedCRDVersions
is in fechedCRD
.
(in particulur, both mainCRD
and updatedCRD
will pass this check since they both contain v1alpha1
)
I think you could probably just do require.Equal(t, updatedCRD.Spec.Versions, fetchedCRD.Spec.Versions)
to ensure the lists are equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.EqualElements
ignores ordering if that's needed.
dad2344
to
56d199f
Compare
56d199f
to
2c43d2e
Compare
595e920
to
61f9566
Compare
/retest |
/retest |
1 similar comment
/retest |
Signed-off-by: Vu Dinh <vdinh@redhat.com>
Signed-off-by: Vu Dinh <vdinh@redhat.com>
Signed-off-by: Vu Dinh <vdinh@redhat.com>
18703fc
to
fededd3
Compare
Signed-off-by: Vu Dinh <vdinh@redhat.com>
fededd3
to
930163c
Compare
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dinhxuanvu, jpeeler 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 |
Which release did this fix initially make it into? |
Signed-off-by: Vu Dinh vdinh@redhat.com