Skip to content

Conversation

gerrod3
Copy link
Contributor

@gerrod3 gerrod3 commented Aug 21, 2024

fixes: #5087

Also added tests for pulp_label_select replications since I couldn't find any (maybe they are there and I'm bad at grep).

@gerrod3 gerrod3 force-pushed the upstream-label-select branch from 67f661a to a9ea8c1 Compare August 21, 2024 21:56
Copy link
Member

@mdellweg mdellweg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall if we decided to replace the label select filter, but since the new one provides a superset of the functionality, i'd rather vote for it.

@gerrod3 gerrod3 force-pushed the upstream-label-select branch 2 times, most recently from bb86823 to f3eac16 Compare August 26, 2024 14:49
"""Ensure we have a valid q_select expression."""
from pulpcore.app.viewsets import DistributionFilter

DistributionFilter().filters["q"].field.clean(value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like much better targeted.
👍

@gerrod3 gerrod3 force-pushed the upstream-label-select branch 2 times, most recently from 5d4fdf2 to c0178b2 Compare August 30, 2024 17:38
@gerrod3
Copy link
Contributor Author

gerrod3 commented Aug 30, 2024

Ok, I've "removed" pulp_label_select by migrating it to q_select and removing the field from the serializer. This should make it ZDU safe, and I left a little note that we can properly remove the field from the model in the next breaking change release.

@gerrod3 gerrod3 requested a review from mdellweg August 30, 2024 17:41
@gerrod3 gerrod3 force-pushed the upstream-label-select branch 2 times, most recently from 35158df to 6a833aa Compare August 30, 2024 22:15
Copy link
Member

@mdellweg mdellweg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the ZDU:
There's a case we may not be able to cover, I think. During the update, it is possible to configure an UpstreamPulp object using the new filter with a new api worker. Then, calling replicate on an old api worker, which will not realize there is an issue and trigger a task claiming to be compatible with the old worker code. Now if an old worker will pick up the task, it will not be able to apply the q_filter that may not even be translatable into label_select anymore. This could lead to an unfiltered replicate of every thing.

Can we make old workers fail when reading the label_select_filter, to limit the damage?

@gerrod3
Copy link
Contributor Author

gerrod3 commented Sep 3, 2024

Can we make old workers fail when reading the label_select_filter, to limit the damage?

No, I don't think I can. Worst case the user can rerun replication if this happens after the upgrade is complete.

@mdellweg
Copy link
Member

mdellweg commented Sep 4, 2024

No, I don't think I can. Worst case the user can rerun replication if this happens after the upgrade is complete.

Yes, I agree. The thing I'm worried about is that accidentally replicating without the filter can bust all the resource limits of the replica. And it can expose unwanted content in a certain Geo. But as you say, there is no good way to solve that, we should probably just leave a warning somewhere.

@gerrod3 gerrod3 force-pushed the upstream-label-select branch from 22cfaca to 3569223 Compare September 4, 2024 07:28
@gerrod3
Copy link
Contributor Author

gerrod3 commented Sep 4, 2024

But as you say, there is no good way to solve that, we should probably just leave a warning somewhere.

I added a warning in the changelog.

@gerrod3 gerrod3 force-pushed the upstream-label-select branch from 3569223 to 32b45d8 Compare September 5, 2024 07:53
batch = []
for upstream in UpstreamPulp.objects.filter(pulp_label_select__isnull=False).iterator():
if upstream.pulp_label_select:
upstream.q_select = f"pulp_label_select='{upstream.pulp_label_select}'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, we may need to think about proper quotation here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think f"pulp_label_select={upstream.pulp_label_select!r}" should be sufficient, correct?

pulp_settings,
gen_object_with_cleanup,
):
"""Test complex q_select replication."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test where we need to quote the value inside of the quoted pulp_label_select filter string?

Copy link
Contributor Author

@gerrod3 gerrod3 Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example of what one mine look like? I'm just wondering what users would be quoting in their labels.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing i learned is, that users are creative...
Consider:
pulp file repository label set --repository test1 --key "asdf" --value "'asdf/+*&\""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah maybe we shouldn't allow quotes in labels. The ambiguity of it is very annoying and what value does a user gain by being able to use them?

I've been struggling with trying to get your example to work with the q=pulp_label_select filter and I'm not sure it is possible with how query expressions work. If you can get it to work then I'll add a test for it, else I'll just leave this as an edge case that hopefully users will be smart enough to avoid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you are saying we cannot even select for these values today?
Can you add some sanitation for the label values to make sure we will never get there?
Maybe it's a separate PR, and I'm happy to have a migration fail in case a user has done that already.

@gerrod3 gerrod3 force-pushed the upstream-label-select branch from 32b45d8 to 4da3b4b Compare September 17, 2024 20:09
@ggainey ggainey merged commit 0fd444d into pulp:main Sep 18, 2024
12 checks passed
@gerrod3 gerrod3 deleted the upstream-label-select branch September 18, 2024 13:37
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

Successfully merging this pull request may close these issues.

An upstream_pulp's pulp_label_select should allow processing as an OR instead of AND

3 participants