You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
Accidentally or by any other means deleting the GitTrack resource would result in all deployed resources managed by Faros being deleted. As the default behaviour is --cascade=true, we consider this a high risk and would like to prevent this from happening (especially in production).
Proposal:
Config option (in GitTrack or cmd option) to prevent Faros from creating ownerReferences but use other means to identify the parent->child relationship between GitTrack and GitTrackObjects.
We have tested this with a faros.pusher.com/owner-reference annotation, which allows Faros to continue operating without the risk of using an ownerReference. Here is the code that I used to test this:
constownerReferenceAnnotation="faros.pusher.com/owner-reference"constownerReferenceAnnotationFormat="%s.%s.%s/%s"...func (r*ReconcileGitTrack) listObjectsByName(owner*farosv1alpha1.GitTrack) (map[string]farosv1alpha1.GitTrackObjectInterface, error) {
...for_, gto:=rangegtos.Items {
iffarosflags.CreateOwnerReference {
ifmetav1.IsControlledBy(>o, owner) {
result[gto.GetNamespacedName()] =gto.DeepCopy()
}
} else {
ifisOwnedBy(>o, owner) {
result[gto.GetNamespacedName()] =gto.DeepCopy()
}
}
}
...
}
// isOwnedBy checks if the GitTrackObject is owned by owner by checking its annotationsfuncisOwnedBy(obj*farosv1alpha1.GitTrackObject, owner*farosv1alpha1.GitTrack) bool {
annotations:=obj.GetAnnotations()
ifannotations!=nil {
compare:=fmt.Sprintf(ownerReferenceAnnotationFormat, owner.Name, owner.Kind, owner.TypeMeta.GroupVersionKind().Group, owner.GroupVersionKind().Version)
ifannotations[ownerReferenceAnnotation] ==compare {
returntrue
}
}
returnfalse
}
...func (r*ReconcileGitTrack) handleObject(u*unstructured.Unstructured, owner*farosv1alpha1.GitTrack) result {
...iffarosflags.CreateOwnerReference {
// Creating an owner reference, as before.iferr=controllerutil.SetControllerReference(owner, gto, r.scheme); err!=nil {
returnerrorResult(gto.GetNamespacedName(), err)
}
} else {
// Add an annotation to identify the Faros owner of this GitTrackObjectannotations:=gto.GetAnnotations()
ifannotations==nil {
annotations=make(map[string]string)
}
annotations[ownerReferenceAnnotation] =fmt.Sprintf(ownerReferenceAnnotationFormat, owner.Name, owner.Kind, owner.TypeMeta.GroupVersionKind().Group, owner.GroupVersionKind().Version)
gto.SetAnnotations(annotations)
}
...
}
The text was updated successfully, but these errors were encountered:
Accidentally or by any other means deleting the
GitTrack
resource would result in all deployed resources managed by Faros being deleted. As the default behaviour is--cascade=true
, we consider this a high risk and would like to prevent this from happening (especially in production).Proposal:
Config option (in
GitTrack
or cmd option) to prevent Faros from creatingownerReferences
but use other means to identify the parent->child relationship betweenGitTrack
andGitTrackObject
s.We have tested this with a
faros.pusher.com/owner-reference
annotation, which allows Faros to continue operating without the risk of using anownerReference
. Here is the code that I used to test this:The text was updated successfully, but these errors were encountered: