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

DLPX-88975 update-package failed with a merge conflict in the drgn branch #58

Merged

Conversation

manoj-joseph
Copy link

@manoj-joseph manoj-joseph commented Nov 30, 2023

Problem

mjoseph@manojjosephsmbp drgn % git merge --no-edit --no-stat upstreams
CONFLICT (modify/delete): .pre-commit-config.yaml deleted in HEAD and modified in upstreams.  Version upstreams of .pre-commit-config.yaml left in tree.
Automatic merge failed; fix conflicts and then commit the result.
mjoseph@manojjosephsmbp drgn % 

Solution

Fixed the conflict by deleting .pre-commit-config.yaml

brenns10 and others added 11 commits November 29, 2023 08:56
Vermin 1.6.0 was recently released, which contains a fix for
netromdk/vermin#230. This was a rather odd corner case, in which Vermin
would fail when code was compatible with 2.x and 3.x, yet the command
line only required compatibility with 3.x. Since pre-commit runs against
only files that changed, this was possible, for example with small test
files. I'm not sure if I encountered it in drgn (I know I did with
drgn-tools), but it's good to have the fix.

I used pre-commit autoupdate, so we have the latest version of each hook
now. In particular, this commit surpasses mypy 0.971, which is the last
version to support Python 3.6 at runtime. Mypy still supports targeting
Python 3.6[1].

[1]: https://mypy-lang.blogspot.com/2022/07/mypy-0971-released.html

Two new errors were surfaced with the new hooks:

1. Mypy complained about the pattern "os.exit(exception)". I've replaced
   these so they explicitly use str: "os.exit(str(exception))".

drgn/cli.py:283: error: Argument 1 to "exit" has incompatible type "OSError"; expected "str | int | None"  [arg-type]

2. Vermin complained that "int.is_integer()" was introduced 3.12. I
   surmised that it was unable to infer that its usage was guaranteed to
   be against a float, and the reason was due to the division operation
   against an integer. I changed the integer literal to a float literal,
   which resolved the issue.

!2, 3.12     drgn/helpers/common/format.py
  'int.is_integer' member requires !2, 3.12

Signed-off-by: Stephen Brennan <[email protected]>
Since updating pre-commit hooks, Python 3.6 and 3.7 will no longer pass
pre-commit runs. Skip installing and running pre-commit/mypy on the
unsupported versions of Python. To do this, we (ab)use Bash's regex to
detect supported versions, and set an environment variable when
pre-commit should be used. Then, we (ab)use parameter expansion syntax
and Github Actions if-conditionals to decide whether to skip/run.

Signed-off-by: Stephen Brennan <[email protected]>
Since updating pre-commit and the hooks, development on EOL Python
versions is no longer supported, and will fail. Update the contributing
guide to explain that Python 3.6 is supported for build, runtime, and
tests, but development workflow scripts require a supported Python
version. Repeat this warning in the pre-commit section, where it is most
relevant.

Signed-off-by: Stephen Brennan <[email protected]>
To allow logging in the function, let it take prog as a parameter. OTOH
the file descriptor then need not be passed separately.

Signed-off-by: Petr Tesarik <[email protected]>
Reduce the error to a warning. Support for the flattened KDUMP format was
added in libkdumpfile-0.5.3, so a sufficiently recent libkdumpfile can open
flattened files directly.

However, the flattened file format requires scanning the whole file first
to build a map of flattened file segments, so opening a large file may be
too slow. Issue a warning, so users know they have the option to reassemble
the vmcore.

Signed-off-by: Petr Tesarik <[email protected]>
Return DRGN_ERROR_INVALID_ARGUMENT with a reasonable error message if
libkdumpfile cannot open a file.

The error output currently looks something like:

Traceback (most recent call last):
  File "/research/bin/drgn", line 33, in <module>
    sys.exit(load_entry_point('drgn', 'console_scripts', 'drgn')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/research/src/drgn/drgn/cli.py", line 264, in _main
    prog.set_core_dump(args.core)
Exception: kdump_set_number_attr(KDUMP_ATTR_FILE_FD): File #0: Unknown file format

Replace it with this:

error: file #0: Unknown file format

This is similar to the error message when trying to open a file that is
neither KDUMP nor ELF:

error: not an ELF core file

Signed-off-by: Petr Tesarik <[email protected]>
…ernel tasks

Sometimes I need to enumerate all tasks in the system and print their
command lines, among other information. This fails for kernel tasks
(i.e. tasks without mm):

Traceback (most recent call last):
  File "<console>", line 2, in <module>
  File "[...]/drgn/helpers/linux/mm.py", line 1276, in cmdline
    arg_start = mm.arg_start.value_()
                ^^^^^^^^^^^^^^^^^^^^^
_drgn.FaultError: address is not mapped: 0x140

It seems reasonable for this not to cause an exception but rather
to return a value that the caller can conveniently recover from
(consider also the behavior of `cat /proc/2/cmdline`). Therefore,
change cmdline() to return None for kernel tasks. Do the same for
environ() for consistency.

Signed-off-by: Peter Collingbourne <[email protected]>
It needed the linux_helper_task_iterator update and a fix for
/proc/kcore upstream (fe2c34bab6d4 ("iov_iter: fix
copy_page_to_iter_nofault()")).

Signed-off-by: Omar Sandoval <[email protected]>
@manoj-joseph manoj-joseph force-pushed the dlpx/pr/manoj-joseph/c88f8ddf-7659-4b0e-aea7-4e496eacfb1a branch from 72733fc to a7ed5be Compare November 30, 2023 17:47
@manoj-joseph manoj-joseph marked this pull request as ready for review November 30, 2023 17:50
@manoj-joseph manoj-joseph force-pushed the dlpx/pr/manoj-joseph/c88f8ddf-7659-4b0e-aea7-4e496eacfb1a branch 2 times, most recently from 4ecc4fd to a758939 Compare November 30, 2023 18:17
@manoj-joseph manoj-joseph changed the title Merge branch upstreams into develop DLPX-88975 update-package failed with a merge conflict in the drgn branch Nov 30, 2023
@manoj-joseph manoj-joseph force-pushed the dlpx/pr/manoj-joseph/c88f8ddf-7659-4b0e-aea7-4e496eacfb1a branch from a758939 to 1cc659e Compare November 30, 2023 18:23
@manoj-joseph manoj-joseph merged commit 13de00c into develop Dec 1, 2023
4 of 7 checks passed
@manoj-joseph manoj-joseph deleted the dlpx/pr/manoj-joseph/c88f8ddf-7659-4b0e-aea7-4e496eacfb1a branch December 1, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants