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

Get parent class as one row to avoid warnings #5822

Closed

Conversation

kalikiana
Copy link
Member

There should only ever be one match.

See: https://progress.opensuse.org/issues/154735

@@ -68,4 +68,14 @@ sub query_for_settings ($self, $args) {
return $self->search({-and => \@conds});
}

sub parent_worker_class ($self, $parent_job_id, $worker_class) {
my $result = $self->search({parent_job_id => $job_id, key => 'WORKER_CLASS'})->next;
Copy link
Contributor

Choose a reason for hiding this comment

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

if we only want one row, it's better to tell that the database

Suggested change
my $result = $self->search({parent_job_id => $job_id, key => 'WORKER_CLASS'})->next;
my $result = $self->search({parent_job_id => $job_id, key => 'WORKER_CLASS'}, {rows => 1})->single;

since there can be multiple WORKER_CLASS entries, we're still relying on the internal order of postgres here I guess.

die
"Worker class $worker_class does not match the worker class of its directly chained parent ($parent_worker_class)"
unless $worker_class eq $parent_worker_class;
die "Ambiguous job settings for dependent jobs" if $result->next;
Copy link
Contributor

@perlpunk perlpunk Aug 5, 2024

Choose a reason for hiding this comment

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

There can be multiple entries, that's valid

@perlpunk
Copy link
Contributor

perlpunk commented Aug 5, 2024

Maybe we even want to copy all WORKER_CLASS entries instead of just the first?

@perlpunk
Copy link
Contributor

perlpunk commented Aug 5, 2024

OTOH I'm wondering why we don't see this warning more often.

edit: it seems it doesn' t happen that often that a job has dependency type DIRECTLY_CHAINED (found the most recent one on osd at 2024-07-31) plus more than one WORKER_CLASS.

Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

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

die
"Worker class $worker_class does not match the worker class of its directly chained parent ($parent_worker_class)"
unless $worker_class eq $parent_worker_class;
die "Ambiguous job settings for dependent jobs" if $result->next;
Copy link
Contributor

Choose a reason for hiding this comment

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

We may have multiple WORKER_CLASS settings per job and that's perfectly fine. This code should actually get all of them and then compare whether the full set of worker classes is identical to the full set of worker classes of the parent job (the order doesn't matter).

Note that this means that already the line $job->settings->find({key => 'WORKER_CLASS'}); is problematic. Also in this case we need to handle that there can be multiple worker classes (and then compare it to the multiple worker classes the call you're trying to fix might return).

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, like I wrote. And in the case of ResultSet::Jobs::create_from_settings we probably want to copy every WORKER_CLASS to the child

Copy link
Contributor

mergify bot commented Sep 23, 2024

This pull request is now in conflicts. Could you fix it? 🙏

@kalikiana
Copy link
Member Author

Closing in favor of #5936

@kalikiana kalikiana closed this Sep 23, 2024
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.

4 participants