-
Notifications
You must be signed in to change notification settings - Fork 261
retain single bundle default channel for overwrite #812
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
retain single bundle default channel for overwrite #812
Conversation
Signed-off-by: Ankita Thomas <ankithom@redhat.com>
f656b61 to
995885d
Compare
Codecov Report
@@ Coverage Diff @@
## master #812 +/- ##
=======================================
Coverage 51.04% 51.04%
=======================================
Files 103 103
Lines 9049 9050 +1
=======================================
+ Hits 4619 4620 +1
Misses 3553 3553
Partials 877 877
Continue to review full report at Codecov.
|
njhale
left a comment
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.
I tested this out locally against the 4.6 index and affected package with positive results:
$ opm index add --enable-alpha --generate --bundles registry-proxy.engineering.redhat.com/rh-osbs/distributed-tracing-jaeger-operator-bundle@sha256:bf951190f9c71d3bf7776145be28dff46782efefee65525da845d5474a8b8bab --from-index registry-proxy.engineering.redhat.com/rh-osbs/iib-pub-pending:v4.6 --overwrite-latest
...
INFO[0000] building the index bundles="[registry-proxy.engineering.redhat.com/rh-osbs/distributed-tracing-jaeger-operator-bundle@sha256:bf951190f9c71d3bf7776145be28dff46782efefee65525da845d5474a8b8bab]"
INFO[0000] Pulling previous image registry-proxy.engineering.redhat.com/rh-osbs/iib-pub-pending:v4.6 to get metadata bundles="[registry-proxy.engineering.redhat.com/rh-osbs/distributed-tracing-jaeger-operator-bundle@sha256:bf951190f9c71d3bf7776145be28dff46782efefee65525da845d5474a8b8bab]"
...
INFO[0037] writing dockerfile: index.Dockerfile bundles="[registry-proxy.engineering.redhat.com/rh-osbs/distributed-tracing-jaeger-operator-bundle@sha256:bf951190f9c71d3bf7776145be28dff46782efefee65525da845d5474a8b8bab]"
$ sqlite3 database/index.db 'SELECT * FROM channel_entry WHERE package_name="jaeger-product" # 'database/index.db' contains the catalog database post-add
15737|1.24-stable|jaeger-product|jaeger-operator.v1.24.1||0
15738|tech-preview|jaeger-product|jaeger-operator.v2.0.0-tp.1||0
15739|1.13-stable|jaeger-product|jaeger-operator.v1.13.2||0
15740|1.17-stable|jaeger-product|jaeger-operator.v1.17.10||0
15741|stable|jaeger-product|jaeger-operator.v1.26.0||0
15742|1.20-stable|jaeger-product|jaeger-operator.v1.20.5||0/approve
pkg/sqlite/load_test.go
Outdated
|
|
||
| getDefaultChannel := func(pkg string) sql.NullString { | ||
| // get defaultChannel before delete | ||
| rows, err := db.QueryContext(context.TODO(), `SELECT default_channel FROM package WHERE name = ?`, pkg) |
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: by convention context.Background() is used for tests.
pkg/sqlite/load.go
Outdated
| if _, err := tx.Exec(`UPDATE channel SET head_operatorbundle_name = NULL WHERE name = ? AND package_name = ? AND name IN (SELECT default_channel FROM package WHERE name = ?)`, channel, pkg, pkg); err != nil { | ||
| return err | ||
| } | ||
| if _, err := tx.Exec(`DELETE FROM channel WHERE name = ? AND package_name = ? AND head_operatorbundle_name = ?`, channel, pkg, bundle); err != nil { | ||
| return err |
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.
At this point we know we're going to wipe this out using the default channel selection heuristic anyway, so why not leave the channel and default_channel alone? i.e. don't update/delete it at all.
Is there some edge case I'm missing?
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.
I verified locally, it turns out we don't need to explicitly delete empty non-default channels, the heuristic handles that fine. We only need the head_operatorbundle_name nulling behavior around for the heuristic to pick a default channel when one isn't specified.
Signed-off-by: Ankita Thomas <ankithom@redhat.com>
njhale
left a comment
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.
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ankitathomas, njhale 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 |
--overwrite-latestremoves the head bundle being overwritten, setting channel head to either the previous bundle in replaces chain or dropping the channel entirely. However, when a single bundle default channel head is overwritten, this causes the package to lose its default channel, causing the package manifest to be unable to determine the default channel unless the overwritten bundle is both the highest semver in the package and either has one channel or has a default channel annotation.This PR retains a stub default channel entry to help determine a default channel after the overwrite