Project

Profile

Help

Story #8067

Story #7127: Add object labels

As a user, I can filter resources by labels

Added by daviddavis 11 months ago. Updated 10 months ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

100%

Estimated time:
Platform Release:
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:

Associated revisions

Revision 348c6545 View on GitHub
Added by daviddavis 10 months ago

Add pulp_label_filter for filtering by pulp_labels

fixes #8067

History

#1 Updated by daviddavis 11 months ago

We're supporting k8s style label selectors. To give an example of a possible label search: ?labelSelector=environment%3Dproduction,tier%3Dfrontend (which represents environment=production,tier=frontend)

k8s limits labels to alphanumeric characters but our stakeholders have asked to be able to use any char. The one problem I foresee is that there are special characters (e.g. ,) that will be a problem for the label selector if the label contains these characters.

We're already using urlencoding to unescape the search selector string so we can't use that the escape/unescape characters. The two options I see:

  • Add docs informing users if they want to search by a label, they should stick to labels with alphanumeric chars (easy)
  • Escape these characters some other way?

#2 Updated by daviddavis 11 months ago

During open floor today, we agreed to forbid characters that would cause problems with the label filter. I think this would specifically mean , and ).

#3 Updated by daviddavis 11 months ago

I looked at some alternative methods for filtering. It looks like there was a discussion in the django-filter project about having dynamic filters for json fields. The problem is that any such solution be openapi compatible or work with our bindings.

#4 Updated by bmbouter 11 months ago

daviddavis so for the current separate table and GenericForeignKey implementation how do users add a key/value, change, and remove a key/value?

Also for the current separate table with GenericForeignKey implementation, does built-in filtering provide any functionality?

#5 Updated by daviddavis 10 months ago

bmbouter wrote:

daviddavis so for the current separate table and GenericForeignKey implementation how do users add a key/value, change, and remove a key/value?

It's just a DictField. The code is pretty basic. There are example API calls in the epic/parent task of this issue. And here's the PR with some tests: https://github.com/pulp/pulpcore/pull/1070

Also for the current separate table with GenericForeignKey implementation, does built-in filtering provide any functionality?

So you get pulp_labels__key and pulp_labels__value along with the other filters like pulp_labels__key__contains, etc.

#6 Updated by daviddavis 10 months ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to daviddavis

#7 Updated by daviddavis 10 months ago

  • Sprint/Milestone set to 3.10.0

#8 Updated by pulpbot 10 months ago

  • Status changed from ASSIGNED to POST

#9 Updated by daviddavis 10 months ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100

#10 Updated by pulpbot 10 months ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Please register to edit this issue

Also available in: Atom PDF