-
Notifications
You must be signed in to change notification settings - Fork 18
Children of objects handled in Response are pruned, although they aren't touched by the Router #91
Description
Context
I am using baaah to manage Tekton TaskRun objects.
When baaah creates those TaskRuns, they are automatically labeled with apply.acorn.io/hash, as expected.
Problem
Tekton propagates labels from the parent TaskRun to its children Pods, but baaah uses the aforementioned label to determine whether it should prune objects, and ends up pruning Pods which it doesn't manage.
Demonstration
Here is a debug session as an illustration, where the code snippets correspond to the breakpoints I set:
baaah/pkg/apply/desiredset_process.go
Lines 184 to 187 in 5d519d2
| existing, err := a.list(gvk, set, objs) | |
| if err != nil { | |
| return fmt.Errorf("failed to list %s for %s: %w", gvk, debugID, err) | |
| } |
(dlv) print set
k8s.io/apimachinery/pkg/labels.Selector(k8s.io/apimachinery/pkg/labels.internalSelector) [
{
key: "apply.acorn.io/hash",
operator: "=",
strValues: []string len: 1, cap: 1, [
"576cd23303466727e7fab759412925c6f2bf8934",
],},
](dlv) print existing
map[github.com/acorn-io/baaah/pkg/apply/objectset.ObjectKey]sigs.k8s.io/controller-runtime/pkg/client.Object [
{Name: "pod-managed-by-tekton", Namespace: "default"}: *k8s.io/api/core/v1.Pod {
TypeMeta: (*"k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta")(0xc000a3a000),
ObjectMeta: (*"k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta")(0xc000a3a020),
Spec: (*"k8s.io/api/core/v1.PodSpec")(0xc000a3a108),
Status: (*"k8s.io/api/core/v1.PodStatus")(0xc000a3a328),},
{Name: "pod-managed-by-baaah", Namespace: "default"}: *k8s.io/api/core/v1.Pod {
TypeMeta: (*"k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta")(0xc000a3a428),
ObjectMeta: (*"k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta")(0xc000a3a448),
Spec: (*"k8s.io/api/core/v1.PodSpec")(0xc000a3a530),
Status: (*"k8s.io/api/core/v1.PodStatus")(0xc000a3a750),},
]baaah/pkg/apply/desiredset_process.go
Lines 189 to 193 in 5d519d2
| var toReplace []objectset.ObjectKey | |
| toCreate, toDelete, toUpdate := compareSets(existing, objs) | |
| // check for resources in the objectset but under a different version of the same group/kind | |
| toDelete = a.filterCrossVersion(allObjs, gvk, toDelete) |
(dlv) print toDelete
[]github.com/acorn-io/baaah/pkg/apply/objectset.ObjectKey len: 1, cap: 1, [
{
Name: "pod-managed-by-tekton",
Namespace: "default",},
]As seen above, baaah matches on the Pod managed by Tekton, and ends up pruning that Pod, despite the Router's client never ever interacting with that particular Pod.