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

[Build] library_packager.py set_or_remove_rpath open: Operation not permitted #18260

Open
1 task done
radekg opened this issue Jul 16, 2023 · 0 comments
Open
1 task done
Assignees
Labels
area/docdb YugabyteDB core features kind/bug This issue is a bug priority/medium Medium priority issue

Comments

@radekg
Copy link
Contributor

radekg commented Jul 16, 2023

Jira Link: DB-7261

Description

Hey there, not sure if this issue is correctly categorized but there's no option to create an issue related to the build process.

Release command

I'm running the release creation like this:

./yb_release --build_archive --build=release --force --keep_tmp_dir

The problem

open: Operation not permitted
Traceback (most recent call last):
  File "/yb-source/python/yugabyte/yb_release_core_db.py", line 444, in <module>
    main()
  File "/yb-source/python/yugabyte/yb_release_core_db.py", line 397, in main
    library_packager.package_binaries()
  File "/yb-source/python/yugabyte/library_packager.py", line 549, in package_binaries
    self.install_dyn_linked_binary(dep.target, category_dest_dir)
  File "/yb-source/python/yugabyte/library_packager.py", line 301, in install_dyn_linked_binary
    LibraryPackager.set_or_remove_rpath(self.dest_dir, installed_binary_path)
  File "/yb-source/python/yugabyte/library_packager.py", line 286, in set_or_remove_rpath
    remove_rpath(file_path)
  File "/yb-source/python/yugabyte/rpath.py", line 104, in remove_rpath
    subprocess.check_call([patchelf_path, '--remove-rpath', file_path])
  File "/usr/lib64/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/yb-build/brew/linuxbrew-20181203T161736v9-3ba4c2ed9b0587040949a4a9a95b576f520bae/bin/patchelf', '--remove-rpath', '/yb-source/build/yb_tmp_5750f2fd-e186-4daf-9acf-4bbedc92da0d_6799234575154959/library_packager_output/linuxbrew/lib/libgcc_s.so.1']' returned non-zero exit status 1.

What do I see

After the build fails, I see the following:

[root@6be2b1d2c86d /]# ls -la /yb-source/build/yb_tmp_5750f2fd-e186-4daf-9acf-4bbedc92da0d_6799234575154959/library_packager_output/linuxbrew/lib/libgcc_s.so.1
-r-xr-xr-x 1 root root 93648 Jul 16 20:13 /yb-source/build/yb_tmp_5750f2fd-e186-4daf-9acf-4bbedc92da0d_6799234575154959/library_packager_output/linuxbrew/lib/libgcc_s.so.1

Offending code

https://github.com/yugabyte/yugabyte-db/blob/master/python/yugabyte/library_packager.py#L273-L291

    def set_or_remove_rpath(dest_root_dir: str, file_path: str) -> None:
        if not should_manipulate_rpath_of(file_path):
            return

        if not os.access(file_path, os.W_OK):
            # Make sure we can write to the file. This may be necessary for e.g. files copied from
            # Linuxbrew or third-party dependencies.
            subprocess.check_call(['chmod', 'u+w', file_path])

        if using_linuxbrew():
            # In Linuxbrew mode, we will set the rp
            remove_rpath(file_path)
            return

        file_abs_path = os.path.abspath(file_path)
        new_rpath = ':'.join(LibraryPackager.get_relative_rpath_items(
                    dest_root_dir, os.path.dirname(file_abs_path)))
        logging.info("Setting rpath on file %s to %s", file_path, new_rpath)
        set_rpath(file_path, new_rpath)

Possible explanation

The problem is that the offending code asserts that the file is writable while the permission changes between the os.access check and the actual remove_rpath operation. This can apparently happen: https://stackoverflow.com/a/3696146. Changing the code to:

    def set_or_remove_rpath(dest_root_dir: str, file_path: str) -> None:
        if not should_manipulate_rpath_of(file_path):
            return

        if using_linuxbrew():
            # In Linuxbrew mode, we will set the rp
           subprocess.check_call(['chmod', 'u+w', file_path])
            remove_rpath(file_path)
            return

        file_abs_path = os.path.abspath(file_path)
        new_rpath = ':'.join(LibraryPackager.get_relative_rpath_items(
                    dest_root_dir, os.path.dirname(file_abs_path)))
        logging.info("Setting rpath on file %s to %s", file_path, new_rpath)
        subprocess.check_call(['chmod', 'u+w', file_path])
        set_rpath(file_path, new_rpath)

solves this particular issue.

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@radekg radekg added area/ecosystem Label for all ecosystem related projects area/ybd yugabyted project related Github tickets. status/awaiting-triage Issue awaiting triage labels Jul 16, 2023
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Jul 16, 2023
radekg added a commit to radekg/yugabyte-db-build-infrastructure that referenced this issue Jul 16, 2023
radekg added a commit to radekg/yugabyte-db-build-infrastructure that referenced this issue Jul 20, 2023
* Update build infrastructure for latest YugabyteDB

* Install dependencies to build the yugabyted-ui

* Add shorthands for creating a distribution from clang and gcc builds

* Fix patchelf for yugabyted-ui build

* library_packager.py needs to be fixed: yugabyte/yugabyte-db#18260

* One unified build infra for clang and gcc, don't bake patches into the build infra image, fix checking for elf executables during distribution build, gcc distribution is working

* Rebuild extensions

* Fix M2 mac gcc build

* Fix Java installation - remove previously installed JRE 8

* Patch yugabyted-ui build.sh for distribution creation on M2 mac

* Document additional caveats

* Documentation

* Feature support

* YugabyteDB Docker image build

* Wrap up the first version for 2.19.0.0
@yugabyte-ci yugabyte-ci removed the area/ybd yugabyted project related Github tickets. label Oct 10, 2023
@yugabyte-ci yugabyte-ci changed the title [yugabyted] library_packager.py set_or_remove_rpath open: Operation not permitted [Build] library_packager.py set_or_remove_rpath open: Operation not permitted Oct 10, 2023
@yugabyte-ci yugabyte-ci added area/docdb YugabyteDB core features and removed area/ecosystem Label for all ecosystem related projects status/awaiting-triage Issue awaiting triage labels Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docdb YugabyteDB core features kind/bug This issue is a bug priority/medium Medium priority issue
Projects
None yet
Development

No branches or pull requests

4 participants