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

gc-tag should use label, not annotation #205

Open
anguslees opened this issue Mar 21, 2018 · 3 comments
Open

gc-tag should use label, not annotation #205

anguslees opened this issue Mar 21, 2018 · 3 comments

Comments

@anguslees
Copy link
Contributor

Garbage collection works by listing everything with the gc-tag. In a busy cluster, we really want that filter to happen server-side and ideally using an index of some sort.

That means we should use a Kubernetes label, not an annotation.

I think this will require a two-step migration plan (write both but continue to read annotation; release; drop support for annotation; release).

anguslees added a commit to anguslees/kubecfg-1 that referenced this issue May 4, 2018
We want to find all objects using the garbage-collect tag.  This means
we *should* have used a label for this, so we get indexing,
server-side filtering, etc.

Migration plan annotation->label:
- phase1 (this change): write annotation+label; continue to read annotation
- release v.A
- phase2 (future change): read/write label only; remove annotation code
- release v.B

This means writers have to run v.A at least once before moving to v.B,
and can't go back from v.B.

Plan B (if that nice v.A->v.B track doesn't work out for a user) is to
run `update` with some version off one set of configs, and
then (without removing objects from configs) run `update --skip-gc`
with v.B once. Then regular `update` with v.B will work with the new
label.

Partially-fixes vmware-archive#205
anguslees added a commit to anguslees/kubecfg-1 that referenced this issue May 4, 2018
We want to find all objects using the garbage-collect tag.  This means
we *should* have used a label for this, so we get indexing,
server-side filtering, etc.

Migration plan annotation->label:
- phase1 (this change): write annotation+label; continue to read annotation
- release v.A
- phase2 (future change): read/write label only; remove annotation code
- release v.B

This means writers have to run v.A at least once before moving to v.B,
and can't go back from v.B.

Plan B (if that nice v.A->v.B track doesn't work out for a user) is to
run `update` with some version off one set of configs, and
then (without removing objects from configs) run `update --skip-gc`
with v.B once. Then regular `update` with v.B will work with the new
label.

Partially-fix for vmware-archive#205
anguslees added a commit to anguslees/kubecfg-1 that referenced this issue Jun 1, 2018
We want to find all objects using the garbage-collect tag.  This means
we *should* have used a label for this, so we get indexing,
server-side filtering, etc.

Migration plan annotation->label:
- phase1 (this change): write annotation+label; continue to read annotation
- release v.A
- phase2 (future change): read/write label only; remove annotation code
- release v.B

This means writers have to run v.A at least once before moving to v.B,
and can't go back from v.B.

Plan B (if that nice v.A->v.B track doesn't work out for a user) is to
run `update` with some version off one set of configs, and
then (without removing objects from configs) run `update --skip-gc`
with v.B once. Then regular `update` with v.B will work with the new
label.

Partial-fix for vmware-archive#205
@anguslees
Copy link
Contributor Author

@gotwarlost points out in qbec's version of garbage collection that the Service->Endpoints controller copies labels across, but not annotations.

We will need to ensure that we don't garbage collect Endpoints unnecessarily (deserves an explicit integration test case). The fix probably involves recording "kubecfg created this object as <group/kind>" annotation, and then double-checking the resource is both marked and the original kind before deleting. Note this also means Deployments will only be deleted via the original apigroup (currently kubecfg's uid logic makes this safe).

@gotwarlost
Copy link

nice trick with the annotation check. I'll incorporate some version of this in qbec soon. Arguably I already have this info in the last-applied annotation that stores the pristine object.

@kgtw
Copy link

kgtw commented Aug 17, 2021

Hi @anguslees

Any update on the progress of phase 2 for this, having kubecfg retrieve every resource for each resource type is extremely inefficient when the cluster has even a few hundred unique resources.

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

No branches or pull requests

3 participants