-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: handles cleanup by using owner ref and cleanup hook #4
Conversation
It is a cluster-scoped resource for tracking objects created by Ossm plugin. Primarily used as owner reference for resources created across namespaces so that they can be garbage collected by Kubernetes when they are not needed anymore.
- adds cleanup hook for Delete phase of KfDef operator - moves k8s_utils code to ossm package to keep it in one place for future extraction of the logic
objectMeta.SetOwnerReferences([]metav1.OwnerReference{ | ||
{ | ||
APIVersion: o.tracker.APIVersion, | ||
Kind: o.tracker.Kind, | ||
Name: o.tracker.Name, | ||
UID: o.tracker.UID, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: we have it in multiple places - worth extracting
pkg/kfapp/ossm/k8s_resources.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated by purpose - we want to have our code self-contained and thus we should minimize coupling with other parts of the current operator as much as possible. Another benefit is that now we can refactor it to our liking, as I think we don't need all of the logic from the original k8s_utils.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice :) excited to have cleanup working.
} | ||
|
||
gvr := schema.GroupVersionResource{ | ||
Group: "ossm.plugins.kubeflow.org", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noting this Group as something to potentially change in future based on our call
* feat: introduces OssmResourceTracker resource It is a cluster-scoped resource for tracking objects created by Ossm plugin. Primarily used as owner reference for resources created across namespaces so that they can be garbage collected by Kubernetes when they are not needed anymore. * feat: uses OssmResourceTracker to cleanup owned resources - adds cleanup hook for Delete phase of KfDef operator - moves k8s_utils code to ossm package to keep it in one place for future extraction of the logic * chore: renames plugin to OssmInstaller * chore: moves cleanup logic to single file * feat: handles token volume removal in SMCP * chore: adds plugin name as extra key-value to logger * feat: removes extAuthzProvider on deletion * chore: minor naming fixes
* feat: introduces OssmResourceTracker resource It is a cluster-scoped resource for tracking objects created by Ossm plugin. Primarily used as owner reference for resources created across namespaces so that they can be garbage collected by Kubernetes when they are not needed anymore. * feat: uses OssmResourceTracker to cleanup owned resources - adds cleanup hook for Delete phase of KfDef operator - moves k8s_utils code to ossm package to keep it in one place for future extraction of the logic * chore: renames plugin to OssmInstaller * chore: moves cleanup logic to single file * feat: handles token volume removal in SMCP * chore: adds plugin name as extra key-value to logger * feat: removes extAuthzProvider on deletion * chore: minor naming fixes
OssmResourceTracker
A cluster-scoped resource for tracking objects created by OSSM installer. Primarily used as owner reference for resources created across namespaces so that they can be garbage collected by Kubernetes when they are not needed anymore.
Cleanup funcs
OSSM Installer keeps a chain of functions that will be invoked during the cleanup phase. Right now it includes:
OssmResourceTracker
so the owned resources will be garbage collected onKfDef
deletionConfigMap
s,EnvoyFilter
s and so on - essentially every ns-scoped resource created by the installerOwnerReferences
pointing to the tracker resource. OAuth client is also a cluster-scoped resource so it won't be garbage collected.With this in place, subsequent deployments of
KfDef
wouldn't result inOAuth flow failed
error which is caused by misaligned secrets between filter and client.Those cleanup functions are invoked by a hook in Delete phase of
KfDef
operator.Open points
OssmTrackerResource
(we might want to change its name btw ;)) to keep old values in a.spec
and use it to restore on deletion.