You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- When using opm index|registry rm <pkg>, drop the "latest" related bundles
from the deprecated table. This makes "un-deprecating" a bundle
possible, which is useful if that bundle was deprecated by
accident
- Add a migration and logic on deprecatetruncate that drops
truncated bundles (i.e. w/o assoc. channel_entry rows) from the deprecated
table, clearing the "deprecation history" so that operations post package
removal don't assume a truncated bundle should be deprecated
See https://bugzilla.redhat.com/show_bug.cgi?id=1982781 for motivation
Signed-off-by: Nick Hale <[email protected]>
Upstream-repository: operator-registry
Upstream-commit: 29e90dea6a1c2ef12075ca866284cd8f267c2bba
// Clean up the deprecated table by dropping all truncated bundles
1470
+
// (see pkg/sqlite/migrations/013_rm_truncated_deprecations.go for more details)
1471
+
_, err=tx.Exec(`DELETE FROM deprecated WHERE deprecated.operatorbundle_name NOT IN (SELECT DISTINCT deprecated.operatorbundle_name FROM (deprecated INNER JOIN channel_entry ON deprecated.operatorbundle_name = channel_entry.operatorbundle_name))`)
1472
+
iferr!=nil {
1473
+
returnerr
1474
+
}
1475
+
1465
1476
returntx.Commit()
1466
1477
}
1467
1478
@@ -1536,3 +1547,46 @@ func (s *sqlLoader) deprecated(tx *sql.Tx, name string) (bool, error) {
1536
1547
// Ignore any deprecated bundles
1537
1548
returnerr==nil, err
1538
1549
}
1550
+
1551
+
// DeprecationAwareLoader understands how bundle deprecations are handled in SQLite and decorates
1552
+
// the sqlLoader with proxy methods that handle deprecation related table housekeeping.
1553
+
typeDeprecationAwareLoaderstruct {
1554
+
*sqlLoader
1555
+
}
1556
+
1557
+
// NewDeprecationAwareLoader returns a new DeprecationAwareLoader.
// The last deprecated bundles for a package will still have "tombstone" records in channel_entry (among other tables).
1577
+
// Use that info to relate the package to a set of rows in the deprecated table.
1578
+
_, err=tx.Exec(`DELETE FROM deprecated WHERE deprecated.operatorbundle_name IN (SELECT DISTINCT deprecated.operatorbundle_name FROM (deprecated INNER JOIN channel_entry ON deprecated.operatorbundle_name = channel_entry.operatorbundle_name) WHERE channel_entry.package_name = ?)`, pkg)
// Delete deprecation history for all bundles that no longer exist in the channel_entries table
20
+
// These bundles have been truncated by more recent deprecations and would only confuse future operations on an index;
21
+
// e.g. adding a previously truncated bundle to a package removed via `opm index|registry rm` would lead to that bundle
22
+
// being deprecated
23
+
_, err:=tx.ExecContext(ctx, `DELETE FROM deprecated WHERE deprecated.operatorbundle_name NOT IN (SELECT DISTINCT deprecated.operatorbundle_name FROM (deprecated INNER JOIN channel_entry ON deprecated.operatorbundle_name = channel_entry.operatorbundle_name))`)
0 commit comments