Skip to content

feat(coderd/database): support exact tags match in AcquireProvisionerJob query #12244

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

Closed
wants to merge 3 commits into from

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Feb 21, 2024

Part of #6442

Updates AcquireProvisionerJob query with parameter ExactTagMatch which toggles between existing behaviour (subset matches) or new behaviour (all match).
Adds unit tests for new behaviour.
A separate PR will wire this up to a configuration knob in coderd and provisionerd.

@johnstcn johnstcn force-pushed the cj/provisionerd_tag_policy branch from 9b77b42 to 3796e17 Compare February 21, 2024 13:41
@johnstcn johnstcn changed the title feat(coderd/database): update AcquireProvisionerJob query to allow sp… feat(coderd/database): support exact tags match in AcquireProvisionerJob query Feb 21, 2024
@johnstcn johnstcn force-pushed the cj/provisionerd_tag_policy branch from 3796e17 to 6c18525 Compare February 21, 2024 14:23
@johnstcn johnstcn marked this pull request as ready for review February 21, 2024 14:35
@johnstcn johnstcn requested review from mafredri and mtojek February 21, 2024 14:35
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

It's a nice and concise PR! Left 2 nit-picks.

AND nested.tags <@ @tags :: jsonb
-- Ensure the caller satisfies all job tags if requested,
AND CASE
WHEN @exact_tag_match :: boolean THEN nested.tags = @tags :: jsonb
Copy link
Member

Choose a reason for hiding this comment

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

Are both guaranteed to be sorted arrays? Might be a good idea to allow unsorted equality.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think they're map[string]string so we want to completely ignore order in comparisons.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, then a jsonb to jsonb comparison should be fine 👍🏻

@johnstcn
Copy link
Member Author

Putting the scope of the change here has the unfortunate side-effect of enforcing a global tag policy. I'm going to make additional modifications to modify the scope of acquirer.AcquireJob and have the parameter be passed in from provisionerdserver. This should allow individual behaviour per provisioner daemon as we start a provisionerdserver for each provisioner daemon.

@johnstcn
Copy link
Member Author

Alternative solution: #12269

I'm leaning in favour of this approach as it doesn't require another configuration knob.
However, we may want to revisit this approach in future once we know the exact scenarios in which folks are currently using provisioner tags.

@johnstcn johnstcn closed this Feb 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 22, 2024
@github-actions github-actions bot deleted the cj/provisionerd_tag_policy branch August 22, 2024 00:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants