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

Refactor Copr build to focus on chroot #356

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

ehelms
Copy link
Member

@ehelms ehelms commented Jul 25, 2023

The Copr build functionality was on partially considering the chroot when looking at if a build exists. Further, there was a lot of copied code between release and scratch that is slimmed down here to allow the by chroot method to properly work.

By and large, I needed to lean more into doing everything by chroot and this includes existence. So I've removed the dedicated check for existence and instead turned copr_build into a more idempotent module that checks existence and acts based upon this.

@ehelms ehelms force-pushed the refactor-copr-build branch 10 times, most recently from 6c436b8 to 6d12f17 Compare July 26, 2023 16:52
@ehelms
Copy link
Member Author

ehelms commented Jul 26, 2023

@evgeni I am needing som ehelp if you have any thoughts on why this is happening. First look at this output:

  TASK [build_package : Run build] ***********************************************
  failed: [hello] (item=epel-7-x86_64) => changed=false 
    ansible_loop_var: chroot
    chroot: epel-7-x86_64
    command: rpm --query --queryformat %{name} /tmp/SRPMs/hello-2.10-1.src.rpm --undefine dist
    msg: hello / None
    output: hello

That msg: is stdout / stderr. For some reason this is performing the right call, and returning the right information, but it's throwing a 1 exit code with no other obvious actual error. And I do not encounter this error locally.

@ehelms
Copy link
Member Author

ehelms commented Jul 27, 2023

@evgeni Thanks for the fix! Now can I ask for a review too? :)

for (macro, value) in macros.items():
command += ['--define', '"%s %s"' % (macro, value)]

return subprocess.check_output(' '.join(command), universal_newlines=True, shell=True)
Copy link
Member

Choose a reason for hiding this comment

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

I know this is copied code, but I wonder if shell=True is really needed here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Without that we get:

      File "/tmp/ansible_copr_build_payload_5hf5no4a/ansible_copr_build_payload.zip/ansible/module_utils/obal.py", line 27, in macro_lookup
      File "/usr/lib64/python3.10/subprocess.py", line 421, in check_output
        return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
      File "/usr/lib64/python3.10/subprocess.py", line 503, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/usr/lib64/python3.10/subprocess.py", line 971, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib64/python3.10/subprocess.py", line 1847, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'rpmquery --queryformat %{name} --package /tmp/SRPMs/hello-2.10-1.src.rpm --undefine dist'

Copy link
Member

Choose a reason for hiding this comment

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

Haha. Yeah. Drop that join and pass a list, then it should work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Lets see what the tests say...

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 need to drop the quotes (when constructing the define) now, as there is no shell anymore and thus no quoting is needed

Copy link
Member Author

Choose a reason for hiding this comment

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

That seems to have done it.

@evgeni
Copy link
Member

evgeni commented Jul 28, 2023

Does this change mean that for a package that has multiple chroots defined, we now execute multiple copr_builds in sequence, while before it would happen in one go (as copr build … --chroot a --chroot b would just instruct Copr to "do the right thing")?

Not blocking per se, but something that can come bite us at some point when we add EL9

(We already have this "issue" today with the non-tito koji builds, so it's strictly speaking not a regression [anymore])

@ehelms
Copy link
Member Author

ehelms commented Jul 28, 2023

Does this change mean that for a package that has multiple chroots defined, we now execute multiple copr_builds in sequence, while before it would happen in one go (as copr build … --chroot a --chroot b would just instruct Copr to "do the right thing")?

We do execute multiple copr_build in sequence. This was done as it's easier to think about each chroot independently when doing reporting to something like Jenkins. What is your concern of how this would bite us when we add EL9?

@evgeni
Copy link
Member

evgeni commented Jul 28, 2023

It doubles the build time when it builds el8 and then 9

@ehelms
Copy link
Member Author

ehelms commented Jul 28, 2023

It doubles the build time when it builds el8 and then 9

I attempt to reduce this by not waiting for the builds to finish and instead watching the tasks, that is it goes:

  1. Kickoff build for chroot A
  2. Kickoff build for chroot B
  3. Wait for A and B to finish

https://github.com/theforeman/obal/pull/356/files#diff-8cc989782b3675c416f8801bcec650370b3c19ea858850bf8a76f6ad048f4cb7R60-R71

@evgeni
Copy link
Member

evgeni commented Jul 28, 2023

Oh right right!

@ehelms
Copy link
Member Author

ehelms commented Jul 28, 2023

Updated with comments

@ehelms ehelms force-pushed the refactor-copr-build branch 2 times, most recently from 6502630 to 422105e Compare July 28, 2023 14:09
The Copr build functionality was on partially considering the chroot
when looking at if a build exists. Further, there was a lot of copied
code between release and scratch that is slimmed down here to allow
the by chroot method to properly work.
@ehelms ehelms merged commit b7d8f1a into theforeman:master Jul 31, 2023
9 of 10 checks passed
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.

2 participants