Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Make garbage-collection labelling resource-specific #1798

Merged

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Mar 6, 2019

This prevents unintended delitions from happening if/when cluster object labels
are copied around.

I also changed some names and tweaked comments a bit.

Fixes #1787

Disclaimer: I haven't tested it (yet)

@2opremio 2opremio requested a review from squaremo March 6, 2019 17:36
@2opremio 2opremio force-pushed the make-gc-labelling-resource-specific branch 5 times, most recently from c7303e4 to a2ca569 Compare March 6, 2019 17:46
This prevents unintended delitions from happening if/when cluster object labels
are copied around.

I also, changed some names and tweaked comments a bit.
@2opremio 2opremio force-pushed the make-gc-labelling-resource-specific branch from a2ca569 to a085d5b Compare March 6, 2019 17:49
Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

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

Looks correct to me. Can we have a test that resources with duplicated labels don't get collected?

@2opremio
Copy link
Contributor Author

2opremio commented Mar 6, 2019 via email

@2opremio 2opremio merged commit c9cda8a into fluxcd:master Mar 7, 2019
@2opremio 2opremio deleted the make-gc-labelling-resource-specific branch March 7, 2019 16:22
// To prevent deleting objects with copied labels
// an object-specific mark is created (by including its identifier).
hasher.Write([]byte(resourceID))
return "sha256:" + base64.RawURLEncoding.EncodeToString(hasher.Sum(nil))
Copy link
Contributor

Choose a reason for hiding this comment

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

the colon : is not allowed in the k8s version we have running:

ts=2019-03-07T20:07:59.874086773Z caller=sync.go:482 component=cluster method=Sync cmd="kubectl apply -f -" took=1.260555818s err="running kubectl: The Secret \"my-secret\" is invalid: metadata.labels: Invalid value: \"sha256:XmUQTWgJCpTt_vgSxwB113djqIlbulw_bNcdVL9zNmk\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')" output=

will create an issue with more information

Copy link
Contributor

Choose a reason for hiding this comment

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

@rndstr so were you debuggin this for the last hour too? #1805

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

garbage collection deleting children resources
4 participants