Bug 2105393 - mock cleans when I tell it not to
Summary: mock cleans when I tell it not to
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: 36
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2106437 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-07-08 16:55 UTC by Jerry James
Modified: 2022-07-13 07:14 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)

Description Jerry James 2022-07-08 16:55:23 UTC
Description of problem:
I frequently examine mock buildroots after a build, even on success.  Recently mock started deleting the buildroot after successful builds.  This is not the behavior I want.  I added this to /etc/mock/site-defaults.cfg:

config_opts['cleanup_on_success'] = False

That made no difference.  Mock still deleted the buildroot after a successful build.  I added this next:

config_opts['clean'] = False

That made no difference either.  I don't see anything else in /usr/share/doc/mock/site-defaults.cfg that might be relevant.  How do I get mock to go back to the old behavior of not deleting the buildroot after a successful build?

Version-Release number of selected component (if applicable):
mock-3.0-1.fc36.noarch
mock-core-configs-37.4-1.fc36.noarch

How reproducible:
Always

Steps to Reproduce:
1. mock -r fedora-rawhide-x86_64 --rebuild <srpm-that-builds-successfully>

Actual results:
The buildroot is deleted after the build, even when options are set telling mock not to do so.  I also tried building with --no-clean, but that didn't change the behavior either.

Expected results:
If I tell mock not to delete the buildroot, I want it to not delete the buildroot.  I want it to instead delete the buildroot prior to the next build or when I explicitly invoke it with one of the cleaning or scrubbing options, which is what it used to do.

Additional info:

Comment 1 Miroslav Suchý 2022-07-08 19:57:09 UTC
1) It is better to put any customization to ~/.config/mock.cfg 

2) Can you post the output of the command:
 mock -r fedora-rawhide-x86_64  --debug-config 
?

3) There is no change that can trigger this. I can only imagine this can happen if you start using tmpfs plugin. Then the buildroot is destroyed even with --no-clean because it disappears when unmounted.

Comment 2 Jerry James 2022-07-08 20:17:54 UTC
Thank you for the quick reply.

(In reply to Miroslav Suchý from comment #1)
> 1) It is better to put any customization to ~/.config/mock.cfg 

Good to know, thank you.  Right now I have no such file.

> 2) Can you post the output of the command:
>  mock -r fedora-rawhide-x86_64  --debug-config 
> ?

I erased the contents of /etc/mock/site-defaults.cfg before running the command.  Output:

config_opts['additional_packages'] = []
config_opts['bootstrap_image'] = 'registry.fedoraproject.org/fedora:rawhide'
config_opts['build_log_fmt_str'] = '%(message)s'
config_opts['cache_alterations'] = False
config_opts['chroot_name'] = 'fedora-rawhide-x86_64'
config_opts['chroot_setup_cmd'] = 'install @{% if mirrored %}buildsys-{% endif %}build'
config_opts['cleanup_on_failure'] = False
config_opts['cleanup_on_success'] = False
config_opts['config_file'] = '/etc/mock/fedora-rawhide-x86_64.cfg'
config_opts['config_path'] = '/etc/mock'
config_opts['config_paths'] = ['/etc/mock/site-defaults.cfg',
 '/etc/mock/chroot-aliases.cfg',
 '/etc/mock/fedora-rawhide-x86_64.cfg',
 '/etc/mock/templates/fedora-rawhide.tpl']
config_opts['description'] = 'Fedora Rawhide'
config_opts['dist'] = 'rawhide'
config_opts['dnf.conf'] = ('\n'
 '[main]\n'
 'keepcache=1\n'
 'debuglevel=2\n'
 'reposdir=/dev/null\n'
 'logfile=/var/log/yum.log\n'
 'retries=20\n'
 'obsoletes=1\n'
 'gpgcheck=0\n'
 'assumeyes=1\n'
 'syslog_ident=mock\n'
 'syslog_device=\n'
 'install_weak_deps=0\n'
 'metadata_expire=0\n'
 'best=1\n'
 'module_platform_id=platform:f{{ releasever }}\n'
 'protected_packages=\n'
 'user_agent={{ user_agent }}\n'
 '\n'
 '{%- macro rawhide_gpg_keys() -%}\n'
 'file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-$releasever-primary\n'
 '{%- for version in [releasever|int, releasever|int - 1]\n'
 '%} file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-{{ '
 'version }}-primary\n'
 '{%- endfor %}\n'
 '{%- endmacro %}\n'
 '\n'
 '# repos\n'
 '\n'
 '[local]\n'
 'name=local\n'
 'baseurl=https://kojipkgs.fedoraproject.org/repos/rawhide/latest/$basearch/\n'
 'cost=2000\n'
 'enabled={{ not mirrored }}\n'
 'skip_if_unavailable=False\n'
 '\n'
 '[local-source]\n'
 'name=local-source\n'
 'baseurl=https://kojipkgs.fedoraproject.org/repos/rawhide/latest/src/\n'
 'cost=2000\n'
 'enabled=0\n'
 'skip_if_unavailable=False\n'
 '\n'
 '{% if mirrored %}\n'
 '[fedora]\n'
 'name=fedora\n'
 'metalink=https://mirrors.fedoraproject.org/metalink?repo=rawhide&arch=$basearch\n'
 'gpgkey={{ rawhide_gpg_keys() }}\n'
 'gpgcheck=1\n'
 'skip_if_unavailable=False\n'
 '\n'
 '[fedora-debuginfo]\n'
 'name=Fedora Rawhide - Debug\n'
 'metalink=https://mirrors.fedoraproject.org/metalink?repo=rawhide-debug&arch=$basearch\n'
 'enabled=0\n'
 'gpgkey={{ rawhide_gpg_keys() }}\n'
 'gpgcheck=1\n'
 'skip_if_unavailable=False\n'
 '\n'
 '[fedora-source]\n'
 'name=fedora-source\n'
 'metalink=https://mirrors.fedoraproject.org/metalink?repo=rawhide-source&arch=$basearch\n'
 'gpgkey={{ rawhide_gpg_keys() }}\n'
 'gpgcheck=1\n'
 'enabled=0\n'
 'skip_if_unavailable=False\n'
 '\n'
 '# modular\n'
 '\n'
 '[rawhide-modular]\n'
 'name=Fedora - Modular Rawhide - Developmental packages for the next Fedora '
 'release\n'
 'metalink=https://mirrors.fedoraproject.org/metalink?repo=rawhide-modular&arch=$basearch\n'
 '# if you want to enable it, you should set best=0\n'
 '# see https://bugzilla.redhat.com/show_bug.cgi?id=1673851\n'
 'enabled=0\n'
 'gpgcheck=1\n'
 'gpgkey={{ rawhide_gpg_keys() }}\n'
 'skip_if_unavailable=False\n'
 '\n'
 '[rawhide-modular-debuginfo]\n'
 'name=Fedora - Modular Rawhide - Debug\n'
 'metalink=https://mirrors.fedoraproject.org/metalink?repo=rawhide-modular-debug&arch=$basearch\n'
 'enabled=0\n'
 'gpgcheck=1\n'
 'gpgkey={{ rawhide_gpg_keys() }}\n'
 'skip_if_unavailable=False\n'
 '\n'
 '[rawhide-modular-source]\n'
 'name=Fedora - Modular Rawhide - Source\n'
 'metalink=https://mirrors.fedoraproject.org/metalink?repo=rawhide-modular-source&arch=$basearch\n'
 'enabled=0\n'
 'gpgcheck=1\n'
 'gpgkey={{ rawhide_gpg_keys() }}\n'
 'skip_if_unavailable=False\n'
 '{% endif %}\n')
config_opts['enable_disable_repos'] = []
config_opts['extra_chroot_dirs'] = ['/run/lock']
config_opts['files'] = {'etc/hosts': '127.0.0.1 localhost localhost.localdomain\n'
              '::1       localhost localhost.localdomain localhost6 '
              'localhost6.localdomain6\n'}
config_opts['legal_host_arches'] = ('x86_64',)
config_opts['macros'] = {'%_buildhost': 'fedora',
 '%_platform_multiplier': 1,
 '%_rpmfilename': '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm',
 '%_topdir': '/builddir/build'}
config_opts['mirrored'] = True
config_opts['no-config'] = {'epel-8': {'alternatives': {'alma+epel-8': {'description': ['Builds against '
                                                             'AlmaLinux 8 '
                                                             'repositories, '
                                                             'together with '
                                                             'the official '
                                                             'EPEL '
                                                             'repositories.',
                                                             'Project page: '
                                                             'https://almalinux.org/']},
                             'centos-stream+epel-8': {'description': ['Builds '
                                                                      'against '
                                                                      'CentOS '
                                                                      'Stream '
                                                                      '8 '
                                                                      'repositories '
                                                                      '(some '
                                                                      'packages '
                                                                      'may be '
                                                                      'a bit '
                                                                      'ahead '
                                                                      'the Red '
                                                                      'Hat '
                                                                      'Enterprise '
                                                                      'Linux '
                                                                      '8) '
                                                                      'together '
                                                                      'with '
                                                                      'the '
                                                                      'official '
                                                                      'EPEL 8 '
                                                                      'repositories.',
                                                                      'Project '
                                                                      'page: '
                                                                      'https://www.centos.org/centos-stream/']},
                             'rhel+epel-8': {'description': ['Builds against '
                                                             'Red Hat '
                                                             'Enterprise Linux '
                                                             '8 repositories, '
                                                             'together with '
                                                             'the official '
                                                             'EPEL '
                                                             'repositories.',
                                                             'This mimics what '
                                                             'is done in the '
                                                             'official EPEL '
                                                             'build system, '
                                                             'but you need a '
                                                             'Red Hat '
                                                             'subscription:',
                                                             'https://rpm-software-management.github.io/mock/Feature-rhelchroots']},
                             'rocky+epel-8': {'description': ['Builds against '
                                                              'Rocky Linux 8 '
                                                              'repositories, '
                                                              'together with '
                                                              'the official '
                                                              'EPEL '
                                                              'repositories.',
                                                              'Project page: '
                                                              'https://rockylinux.org/']}}},
 'epel-9': {'alternatives': {'alma+epel-9': {'description': ['Builds against '
                                                             'AlmaLinux 9 '
                                                             'repositories, '
                                                             'together with '
                                                             'the official '
                                                             'EPEL '
                                                             'repositories.',
                                                             'Project page: '
                                                             'https://almalinux.org/']},
                             'centos-stream+epel-9': {'description': ['Builds '
                                                                      'against '
                                                                      'CentOS '
                                                                      'Stream '
                                                                      '9 '
                                                                      'repositories '
                                                                      '(some '
                                                                      'packages '
                                                                      'may be '
                                                                      'a bit '
                                                                      'ahead '
                                                                      'the Red '
                                                                      'Hat '
                                                                      'Enterprise '
                                                                      'Linux '
                                                                      '9) '
                                                                      'together '
                                                                      'with '
                                                                      'the '
                                                                      'official '
                                                                      'EPEL '
                                                                      'repositories.',
                                                                      'Project '
                                                                      'page: '
                                                                      'https://www.centos.org/centos-stream/']},
                             'rhel+epel-9': {'description': ['Builds against '
                                                             'Red Hat '
                                                             'Enterprise Linux '
                                                             '9 repositories, '
                                                             'together with '
                                                             'the official '
                                                             'EPEL '
                                                             'repositories.',
                                                             'This mimics what '
                                                             'is done in the '
                                                             'official EPEL '
                                                             'build system, '
                                                             'but you need a '
                                                             'Red Hat '
                                                             'subscription:',
                                                             'https://rpm-software-management.github.io/mock/Feature-rhelchroots']}}}}
config_opts['nspawn_args'] = ['--capability=cap_ipc_lock',
 '--bind=/tmp/mock-resolv.k8pdip3_:/etc/resolv.conf',
 '--bind=/dev/btrfs-control',
 '--bind=/dev/loop-control',
 '--bind=/dev/loop0',
 '--bind=/dev/loop1',
 '--bind=/dev/loop2',
 '--bind=/dev/loop3',
 '--bind=/dev/loop4',
 '--bind=/dev/loop5',
 '--bind=/dev/loop6',
 '--bind=/dev/loop7',
 '--bind=/dev/loop8',
 '--bind=/dev/loop9',
 '--bind=/dev/loop10',
 '--bind=/dev/loop11']
config_opts['plugin_conf'] = {'bind_mount_enable': True,
 'bind_mount_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                     'cache_topdir': '/var/cache/mock',
                     'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                     'create_dirs': False,
                     'dirs': [],
                     'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                     'root': 'fedora-rawhide-x86_64'},
 'ccache_enable': False,
 'ccache_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                 'cache_topdir': '/var/cache/mock',
                 'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                 'compress': None,
                 'dir': '/var/cache/mock/fedora-rawhide-x86_64/ccache/u1000/',
                 'max_cache_size': '4G',
                 'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                 'root': 'fedora-rawhide-x86_64'},
 'chroot_scan_enable': False,
 'chroot_scan_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                      'cache_topdir': '/var/cache/mock',
                      'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                      'only_failed': True,
                      'regexes': ['^[^k]?core(\\.\\d+)?$', '\\.log$'],
                      'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                      'root': 'fedora-rawhide-x86_64'},
 'compress_logs_enable': False,
 'compress_logs_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                        'cache_topdir': '/var/cache/mock',
                        'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                        'command': 'gzip',
                        'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                        'root': 'fedora-rawhide-x86_64'},
 'hw_info_enable': True,
 'hw_info_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                  'cache_topdir': '/var/cache/mock',
                  'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                  'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                  'root': 'fedora-rawhide-x86_64'},
 'lvm_root_enable': False,
 'lvm_root_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                   'cache_topdir': '/var/cache/mock',
                   'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                   'pool_name': 'mockbuild',
                   'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                   'root': 'fedora-rawhide-x86_64'},
 'mount_enable': True,
 'mount_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                'cache_topdir': '/var/cache/mock',
                'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                'dirs': [],
                'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                'root': 'fedora-rawhide-x86_64'},
 'overlayfs_enable': False,
 'overlayfs_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                    'cache_topdir': '/var/cache/mock',
                    'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                    'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                    'root': 'fedora-rawhide-x86_64'},
 'package_state_enable': True,
 'package_state_opts': {'available_pkgs': False,
                        'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                        'cache_topdir': '/var/cache/mock',
                        'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                        'installed_pkgs': True,
                        'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                        'root': 'fedora-rawhide-x86_64'},
 'pm_request_enable': False,
 'pm_request_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                     'cache_topdir': '/var/cache/mock',
                     'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                     'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                     'root': 'fedora-rawhide-x86_64'},
 'procenv_enable': False,
 'procenv_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                  'cache_topdir': '/var/cache/mock',
                  'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                  'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                  'root': 'fedora-rawhide-x86_64'},
 'root_cache_enable': True,
 'root_cache_opts': {'age_check': True,
                     'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                     'cache_topdir': '/var/cache/mock',
                     'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                     'compress_program': 'pigz',
                     'decompress_program': None,
                     'dir': '/var/cache/mock/fedora-rawhide-x86_64/root_cache/',
                     'exclude_dirs': ['./proc',
                                      './sys',
                                      './dev',
                                      './tmp/ccache',
                                      './var/cache/yum',
                                      './var/cache/dnf',
                                      './var/log'],
                     'extension': '.gz',
                     'max_age_days': 15,
                     'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                     'root': 'fedora-rawhide-x86_64',
                     'tar': 'gnutar'},
 'rpkg_preprocessor_enable': False,
 'rpkg_preprocessor_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                            'cache_topdir': '/var/cache/mock',
                            'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                            'cmd': '/usr/bin/preproc-rpmspec %(source_spec)s '
                                   '--output %(target_spec)s',
                            'requires': ['preproc-rpmspec'],
                            'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                            'root': 'fedora-rawhide-x86_64'},
 'selinux_enable': True,
 'selinux_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                  'cache_topdir': '/var/cache/mock',
                  'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                  'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                  'root': 'fedora-rawhide-x86_64'},
 'showrc_enable': False,
 'showrc_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                 'cache_topdir': '/var/cache/mock',
                 'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                 'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                 'root': 'fedora-rawhide-x86_64'},
 'sign_enable': False,
 'sign_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
               'cache_topdir': '/var/cache/mock',
               'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
               'cmd': 'rpmsign',
               'opts': '--addsign %(rpms)s',
               'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
               'root': 'fedora-rawhide-x86_64'},
 'tmpfs_enable': False,
 'tmpfs_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                'cache_topdir': '/var/cache/mock',
                'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                'keep_mounted': False,
                'max_fs_size': None,
                'mode': '0755',
                'required_ram_mb': 900,
                'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                'root': 'fedora-rawhide-x86_64'},
 'yum_cache_enable': True,
 'yum_cache_opts': {'basedir': '/var/lib/mock/fedora-rawhide-x86_64',
                    'cache_topdir': '/var/cache/mock',
                    'cachedir': '/var/cache/mock/fedora-rawhide-x86_64',
                    'max_age_days': 30,
                    'max_metadata_age_days': 30,
                    'online': True,
                    'resultdir': '/var/lib/mock/fedora-rawhide-x86_64/result',
                    'root': 'fedora-rawhide-x86_64'}}
config_opts['print_main_output'] = True
config_opts['releasever'] = '37'
config_opts['root'] = 'fedora-rawhide-{{ target_arch }}'
config_opts['root_log_fmt_str'] = '%(levelname)s %(filename)s:%(lineno)d:  %(message)s'
config_opts['rpmbuild_arch'] = 'x86_64'
config_opts['state_log_fmt_str'] = '%(asctime)s - %(message)s'
config_opts['target_arch'] = 'x86_64'
config_opts['verbose'] = 1

> 3) There is no change that can trigger this. I can only imagine this can
> happen if you start using tmpfs plugin. Then the buildroot is destroyed even
> with --no-clean because it disappears when unmounted.

As far as I know, I have made no changes to the mock setup on my machine.  This just started happening a few days ago.  I did not make a note of it the first time it happened, thinking it must have been some kind of fluke.  Still, I'm pretty sure it was early this week.

I also ran "rpm -V mock" and "rpm -V mock-core-configs", which only shows a changed timestamp on /etc/mock/site-defaults.cfg.

Comment 3 Pavel Raiskup 2022-07-09 08:37:57 UTC
Thank you for the report.  This is probably the reason: https://github.com/rpm-software-management/rpm/pull/2080

So as long as cleanup_on_success == False, we should use rpmbuild --noclean.
This option is not available on EL6.

Comment 4 Miroslav Suchý 2022-07-09 16:54:49 UTC
> This option is not available on EL6.

EL6 is EOL. Let's pass --noclean to rpmbuild.

Comment 6 Pavel Raiskup 2022-07-13 07:14:58 UTC
*** Bug 2106437 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.