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

Bug 1827723: Make default channel optional #318

Conversation

Bowenislandsong
Copy link
Member

This commit address the bug where a bundle was released before the current default channel was created, the inference fails.

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label May 4, 2020
@openshift-ci-robot
Copy link

@Bowenislandsong: This pull request references Bugzilla bug 1827723, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1827723: Make default channel optional

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label May 4, 2020
@Bowenislandsong Bowenislandsong force-pushed the bug/understandsingBundles1827723 branch from f28a26a to b7bc827 Compare May 4, 2020 15:45
@Bowenislandsong
Copy link
Member Author

@Bowenislandsong
Copy link
Member Author

/hold writing a test to prove bundles with blank default is not breaking registry.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 4, 2020
@Bowenislandsong
Copy link
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 4, 2020
@Bowenislandsong Bowenislandsong force-pushed the bug/understandsingBundles1827723 branch from 92f4097 to 167568c Compare May 5, 2020 12:42
@Bowenislandsong
Copy link
Member Author

the new annotation for prometheus 0.14.0 in the e2e test:

annotations:
  operators.operatorframework.io.bundle.channel.default.v1: ""
  operators.operatorframework.io.bundle.channels.v1: stable
  operators.operatorframework.io.bundle.manifests.v1: manifests/
  operators.operatorframework.io.bundle.mediatype.v1: registry+v1
  operators.operatorframework.io.bundle.metadata.v1: metadata/
  operators.operatorframework.io.bundle.package.v1: prometheus

@Bowenislandsong
Copy link
Member Author

switched channels and default channel situation for 0.15.0 case so that this bundle is added in the middle between 0.14.0 and 0.22.2

@Bowenislandsong Bowenislandsong force-pushed the bug/understandsingBundles1827723 branch from 167568c to 890caf6 Compare May 5, 2020 14:12
@Bowenislandsong
Copy link
Member Author

/retest

@Bowenislandsong Bowenislandsong force-pushed the bug/understandsingBundles1827723 branch from 890caf6 to 95f23b2 Compare May 5, 2020 21:01
@Bowenislandsong
Copy link
Member Author

/retest

@@ -7,7 +7,7 @@ metadata:
annotations:
alm-examples: '[{"apiVersion":"monitoring.coreos.com/v1","kind":"Prometheus","metadata":{"name":"example","labels":{"prometheus":"k8s"}},"spec":{"replicas":2,"version":"v2.3.2","serviceAccountName":"prometheus-k8s","securityContext": {}, "serviceMonitorSelector":{"matchExpressions":[{"key":"k8s-app","operator":"Exists"}]},"ruleSelector":{"matchLabels":{"role":"prometheus-rulefiles","prometheus":"k8s"}},"alerting":{"alertmanagers":[{"namespace":"monitoring","name":"alertmanager-main","port":"web"}]}}},{"apiVersion":"monitoring.coreos.com/v1","kind":"ServiceMonitor","metadata":{"name":"example","labels":{"k8s-app":"prometheus"}},"spec":{"selector":{"matchLabels":{"k8s-app":"prometheus"}},"endpoints":[{"port":"web","interval":"30s"}]}},{"apiVersion":"monitoring.coreos.com/v1","kind":"Alertmanager","metadata":{"name":"alertmanager-main"},"spec":{"replicas":3, "securityContext": {}}}]'
spec:
replaces: prometheusoperator.0.15.0
replaces: prometheusoperator.0.14.0
Copy link
Member

Choose a reason for hiding this comment

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

Why are we reordering these? I would prefer that, if we need manifests for a specific test, that we make a copy of them and place them in a separate test folder rather than modify our default examples.

@@ -12,6 +12,7 @@ import (
"gopkg.in/yaml.v2"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
k8syaml "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/kubectl/pkg/util/slice"
Copy link
Member

Choose a reason for hiding this comment

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

Is this external dependency really necessary? In general, I think that utils like this which are not included in the standard library and are trivial to write should just be implemented directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, i see your point, just loved that library. getting rid of it.

@@ -298,6 +302,10 @@ func ValidateChannelDefault(channels, channelDefault string) (string, error) {
var chanErr error
channelList := strings.Split(channels, ",")

if len(channelList) == 0 || slice.ContainsString(channelList, "", nil) {
return chanDefault, fmt.Errorf("invalid channels is provied: %s", channels)
Copy link
Member

Choose a reason for hiding this comment

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

This error message seems confusing. Could we be more descriptive of what is actually going wrong here? It seems like we are actually checking two things that should have separate error messages:

  1. That no channels were specified
  2. That the list of channels included an empty string in the list I think?

Also spelling/grammar nit: use are instead of is for plurals, and provided instead of provied

Copy link
Member Author

Choose a reason for hiding this comment

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

ha, I copied that misspell and didn't even see it. Is it weird that I found this to be amusing?

return chanDefault, fmt.Errorf("Invalid channels is provied: %s", channels)

Copy link
Member Author

Choose a reason for hiding this comment

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

https://play.golang.org/p/uemuPhlTisX found out that this split will always output an array with at least 1 length. My bad.

pkg/lib/bundle/generate_test.go Show resolved Hide resolved
@@ -75,7 +73,7 @@ func buildBundlesWith(containerTool string) error {
bundleTag3: bundlePath3,
} {
if err := inTemporaryBuildContext(func() error {
return bundle.BuildFunc(path, "", bundleImage+":"+tag, containerTool, packageName, channels, defaultChannel, false)
return bundle.BuildFunc(path, "", bundleImage+":"+tag, containerTool, "", "", "", false)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here. Can we have a separate test for this rather than modifying an existing one?

@Bowenislandsong Bowenislandsong force-pushed the bug/understandsingBundles1827723 branch 2 times, most recently from b7f3034 to 50dbba0 Compare May 6, 2020 23:35
@dinhxuanvu
Copy link
Member

Looking good.
/approve
Just a quick question. Why do we need the aqua bundle for this fix?

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 7, 2020
@Bowenislandsong
Copy link
Member Author

Bowenislandsong commented May 7, 2020

Looking good.
/approve
Just a quick question. Why do we need the aqua bundle for this fix?

Thanks, Kevin suggested adding a separate thing for e2e test that I am interested in and not changing the existing package for my testing purpose.

@@ -0,0 +1,34 @@
apiVersion: apiextensions.k8s.io/v1beta1
Copy link
Member

Choose a reason for hiding this comment

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

Rather than add something to the root of the manifests/ folder, can we just add these to a test_data folder for a separate test?

Copy link
Member Author

Choose a reason for hiding this comment

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

awww, I changed all those unit tests for it. Shouda thought about it... making the change now

bowenislandsong added 2 commits May 7, 2020 09:25
This commit address the bug where a bundle was released before the current default channel was created, the inference fails. The fix checks if the default channel is included in channels.
This commit leaves default channel blank if not specified or is not contained in channels. This affects the `annotations.yaml` and make it "" for default channels. This will not affect index.db as the code to choose a channel to be the default still lives there. It should remain there since OLM uses that value.
@Bowenislandsong Bowenislandsong force-pushed the bug/understandsingBundles1827723 branch from 50dbba0 to 689410c Compare May 7, 2020 13:27
@kevinrizza
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 7, 2020
Copy link
Member

@dinhxuanvu dinhxuanvu 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-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Bowenislandsong, dinhxuanvu

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-merge-robot openshift-merge-robot merged commit 57fa577 into operator-framework:master May 7, 2020
@openshift-ci-robot
Copy link

@Bowenislandsong: All pull requests linked via external trackers have merged: operator-framework/operator-registry#318. Bugzilla bug 1827723 has been moved to the MODIFIED state.

In response to this:

Bug 1827723: Make default channel optional

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.

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. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. 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

5 participants