Skip to content
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

Precedence between NS labels/annotations propagation should be documented #94

Open
4 tasks
erikgb opened this issue Oct 14, 2023 · 0 comments
Open
4 tasks

Comments

@erikgb
Copy link
Contributor

erikgb commented Oct 14, 2023

What

We are performing a POC of Accurate, and one of our goals is to allow end-users to set selected NS labels/annotations. This seems to work very well, but I could not find the precedence between labelKeys/subNamespaceLabelKeys and annotationKeys/subNamespaceAnnotationKeys documented anywhere. Looking at the code this looks as expected and I have also verified this in our cluster:

for k, v := range parent.Labels {
if ok := r.matchLabelKey(k); ok {
ns.Labels[k] = v
}
}
for k, v := range parent.Annotations {
if ok := r.matchAnnotationKey(k); ok {
if ns.Annotations == nil {
ns.Annotations = make(map[string]string)
}
ns.Annotations[k] = v
}
}
if _, ok := ns.Labels[constants.LabelParent]; ok {
subNS := &accuratev1.SubNamespace{}
err := r.Get(ctx, types.NamespacedName{Name: ns.Name, Namespace: parent.Name}, subNS)
if err != nil {
if !apierrors.IsNotFound(err) {
return fmt.Errorf("failed to get sub namespace %s/%s: %w", ns.Name, parent.Name, err)
}
} else {
for k, v := range subNS.Spec.Labels {
if ok := r.matchSubNamespaceLabelKey(k); ok {
ns.Labels[k] = v
}
}
for k, v := range subNS.Spec.Annotations {
if ok := r.matchSubNamespaceAnnotationKey(k); ok {
if ns.Annotations == nil {
ns.Annotations = make(map[string]string)
}
ns.Annotations[k] = v
}
}
}
}

But I still think the precedence should be clearly documented (and tested) as a commitment to the current behavior.

How

  • Document that SubNamespace annotations/labels will take precedence over any labels/annotations propagated from parent-NS to sub-NS.
  • Add tests for this behavior (if not already exists)

Checklist

  • Finish implementation of the issue
  • Test all functions
  • Have enough logs to trace activities
  • Notify developers of necessary actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant