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

Consider identifiers when retriggering #2658

Merged

Conversation

majamassarini
Copy link
Member

Related to #1886

@majamassarini majamassarini requested review from mfocko and a team as code owners November 26, 2024 12:41
Copy link
Contributor

Copy link
Member

@lbarcziova lbarcziova left a comment

Choose a reason for hiding this comment

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

looks good!

@@ -2102,6 +2104,8 @@ class CoprBuildTargetModel(GroupAndTargetModelConnector, Base):

scan = relationship("OSHScanModel", back_populates="copr_build_target")

identifier = Column(String, default="")
Copy link
Member

Choose a reason for hiding this comment

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

do we need the default? Just checking for TF targets we don't define this, so I would try to stay consistent

Copy link
Member Author

@majamassarini majamassarini Nov 27, 2024

Choose a reason for hiding this comment

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

Ok is not a big issue not having the default here, I am always creating a new entry with the empty string as a default. You can read below why I think a comparison with an empty string more safe than a comparison with None

return self.is_comment_event() and self.comment_arguments.packit_command == "test"
return self.is_comment_event() and self.comment_arguments.packit_command in (
"test",
"retest-failed",
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines +83 to +84
build_targets_override: Optional[set[tuple[str, str]]] = None,
tests_targets_override: Optional[set[tuple[str, str]]] = None,
Copy link
Member

Choose a reason for hiding this comment

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

I have a feeling you're changing the meaning of this attribute, so the name no longer holds very well, but… I guess that's a different rabbit hole to go down…

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 would say they are still targets override but a bit more specific. They are targets for a specific identifier.

The most efficient structure here is probably a dictionary and not a set anymore, however I would start with this simpler enhancement.

self.build_target2test_targets_for_test_job(target, test_job_config),
)
for target, identifier in self.build_targets_override:
if identifier == (test_job_config.identifier if test_job_config.identifier else ""):
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need the ternary there? 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

job_config.identifier could be None, so yes I think we need it. A non specified identifier is the default identifier "".
We can also say that the default identifier is always None but in this case I am a bit afraid of the serialization, if we go through a serialization/deserialization process of a None string value I think we will end up with an empty str ""?
So I feel this comparison more safe.

@majamassarini majamassarini force-pushed the fix/packit-service/1886 branch from 4686a82 to 097a3fc Compare November 27, 2024 09:07
Copy link
Contributor

@majamassarini majamassarini force-pushed the fix/packit-service/1886 branch from 80e805e to 019e2fe Compare November 27, 2024 09:24
@majamassarini majamassarini force-pushed the fix/packit-service/1886 branch from 019e2fe to 999a064 Compare November 27, 2024 09:25
Copy link
Contributor

Copy link
Member

@lbarcziova lbarcziova left a comment

Choose a reason for hiding this comment

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

thanks!

build_targets_override = (
{(target, identifier_) for [target, identifier_] in event.get("build_targets_override")}
if event.get("build_targets_override")
else set()
Copy link
Member

Choose a reason for hiding this comment

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

just to be sure, I also remember some discussions about the empty set vs None for *targets_override, is it ok to have empty set here instead of None?

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 it is, however I want to test this a bit deeper in the staging instance.

packit_service/worker/helpers/build/build_helper.py Outdated Show resolved Hide resolved
majamassarini and others added 2 commits November 27, 2024 11:30
Co-authored-by: Laura Barcziová <[email protected]>
Use duck typing check instead of isinstance.
Inside the test I can't instantiate a proper type object with
all the needed mocked properties.
@majamassarini majamassarini force-pushed the fix/packit-service/1886 branch from a9dfaec to 474b649 Compare November 27, 2024 10:30
Copy link
Contributor

@majamassarini majamassarini added the mergeit When set, zuul wil gate and merge the PR. label Nov 27, 2024
Copy link
Contributor

Build succeeded (gate pipeline).
https://softwarefactory-project.io/zuul/t/packit-service/buildset/0476157f8c3b43f883def38e51587eef

✔️ pre-commit SUCCESS in 2m 06s

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit fc33a6f into packit:main Nov 27, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mergeit When set, zuul wil gate and merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants