PR comment fixes

- Add comment to explain sql driver update behaviour when it comes to updating custom labels
- Apply custom labels in memory driver

Signed-off-by: Evans Mungai <mbuevans@gmail.com>
pull/32667/head
Evans Mungai 2 weeks ago
parent fb450520a6
commit 9f323b5230
No known key found for this signature in database
GPG Key ID: BBEB812143DD14E1

@ -114,6 +114,10 @@ func newRecord(key string, rls *rspb.Release) *record {
var lbs labels
lbs.init()
// apply custom labels
lbs.fromMap(rls.Labels)
lbs.set("name", rls.Name)
lbs.set("owner", "helm")
lbs.set("status", rls.Info.Status.String())

@ -576,6 +576,20 @@ func (s *SQL) Create(key string, rel release.Releaser) error {
}
// Update updates a release.
//
// Custom labels on an existing revision are meant to be preserved. A release's
// labels are set by Create, and a revision keeps the labels it was created with
// once it is superseded, rather than picking up the labels of the upgrade that
// superseded it. TestUpgradeRelease_Labels in pkg/action is what asserts this.
//
// The drivers arrive at that from opposite directions. Here labels live in a
// separate table written only by Create, so an update leaves them untouched. The
// configmaps, memory and secrets drivers instead store labels on the record
// itself and replace the record wholesale on update, so they have to re-apply
// the labels every time or the update would discard all of them. A side effect
// is that those drivers persist a label change where this driver silently would
// not. No caller changes labels between Create and Update, so the two agree in
// practice.
func (s *SQL) Update(key string, rel release.Releaser) error {
rls, err := releaserToV1Release(rel)
if err != nil {

@ -114,6 +114,10 @@ func newRecord(key string, rls *rspb.Release) *record {
var lbs labels
lbs.init()
// apply custom labels
lbs.fromMap(rls.Labels)
lbs.set("name", rls.Name)
lbs.set("owner", "helm")
lbs.set("status", rls.Info.Status.String())

@ -576,6 +576,20 @@ func (s *SQL) Create(key string, rel release.Releaser) error {
}
// Update updates a release.
//
// Custom labels on an existing revision are meant to be preserved. A release's
// labels are set by Create, and a revision keeps the labels it was created with
// once it is superseded, rather than picking up the labels of the upgrade that
// superseded it. TestUpgradeRelease_Labels in pkg/action is what asserts this.
//
// The drivers arrive at that from opposite directions. Here labels live in a
// separate table written only by Create, so an update leaves them untouched. The
// configmaps, memory and secrets drivers instead store labels on the record
// itself and replace the record wholesale on update, so they have to re-apply
// the labels every time or the update would discard all of them. A side effect
// is that those drivers persist a label change where this driver silently would
// not. No caller changes labels between Create and Update, so the two agree in
// practice.
func (s *SQL) Update(key string, rel release.Releaser) error {
rls, err := releaserToV1Release(rel)
if err != nil {

Loading…
Cancel
Save