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

Improve debian reposync logging (bsc#1227859) #9705

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

meaksh
Copy link
Member

@meaksh meaksh commented Jan 30, 2025

What does this PR change?

This PR refactors and enhances logging around debian reposync executions.

GUI diff

No difference.

  • DONE

Documentation

  • No documentation needed: only internal and user invisible changes

  • DONE

Test coverage

  • No tests: no tests around reposync logging

  • DONE

Links

Issue(s): https://github.com/SUSE/spacewalk/issues/24816

  • DONE

Changelogs

Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository

If you don't need a changelog check, please mark this checkbox:

  • No changelog needed

If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test (see below)

Re-run a test

If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:

  • Re-run test "changelog_test"
  • Re-run test "backend_unittests_pgsql"
  • Re-run test "java_pgsql_tests"
  • Re-run test "schema_migration_test_pgsql"
  • Re-run test "susemanager_unittests"
  • Re-run test "javascript_lint"
  • Re-run test "spacecmd_unittests"

Before you merge

Check How to branch and merge properly!

@meaksh meaksh requested a review from a team as a code owner January 30, 2025 11:45
@meaksh meaksh requested review from agraul and removed request for a team January 30, 2025 11:45
@meaksh meaksh force-pushed the master-bsc1227859 branch from efa3ad8 to 52f4ad7 Compare January 30, 2025 11:48
agraul
agraul previously requested changes Feb 10, 2025
Comment on lines +259 to +262
# Apparently we need to call initCFG and have CFG available
# to prevent some errors accessing CFG later on during package
# import.
initCFG("server.satellite")
Copy link
Member

Choose a reason for hiding this comment

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

Can we please fix this as well? I'm okay with doing it in another PR, as we already have the patch we shouldn't leave it lying around until it does not apply anymore.

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'd vote for doing a separated PR.

In our initial attempt, we noticed that other python files that are part of the reposync execution stack were relying on CFG being preinitializated to server.satellite, and that causes some issues in certain corner cases. Instead of going forwad with the refactor, in the context of the bug fix, we just isolated the actual logging improvement from the refactor to use context manager (that was causing some issues). I agree we can just fix them, but we didn't by then.

I would say we can prepare another PR with the refactor, plus any extra fixes required to use context managers, just after this one.

Copy link
Member

Choose a reason for hiding this comment

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

You're adding a lot of pylint disable comments. What's the plan for those?

Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently this spacewalk-repo-sync file is been excluded from our Python linting checks, as not ending with .py extension, so it never got a linting execution. I'm adding a commit to this PR to enable linting on more files.

I just did it and got a couple of issues (as baseline was never set for this file). I agree we should tackle those at some point, as per other files, but I just didn't include it as part of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Changing our lint.sh is only part of the story, the GH Action uses a .py filter. Having these executable scripts commit to the repository does not follow current best practices (where entry points are defined in project metadata and generated during package installation), but that's a different topic.

I think we should think about the filtering we do in GH Actions. The whitelist approach is getting a bit cumbersome lately where we miss out on linting (but still get a green checkmark!).

@meaksh meaksh force-pushed the master-bsc1227859 branch 2 times, most recently from 76bfcdc to 1b2cb83 Compare February 13, 2025 16:15
Comment on lines 479 to 452
logger.error(
"%s: %s. Raising GeneralRepoException.",
DpkgRepo.GPG_VERIFICATION_FAILED,
release_file,
Copy link
Member

Choose a reason for hiding this comment

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

There are other instances of this as well. I'll fix it and force push with a clean history

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

@agraul agraul force-pushed the master-bsc1227859 branch 3 times, most recently from 4edf47d to 61defe6 Compare February 14, 2025 13:27
@agraul agraul dismissed their stale review February 14, 2025 13:37

Addressed open points

@agraul agraul requested a review from m-czernek February 14, 2025 13:37
agraul and others added 4 commits February 14, 2025 15:47
Since all loggers in the logging library inherit the config from
their parents up to the root logger, we can use the root logger
similarly to rhnLog's LOG object. The root logger singleton is changed
to direct the log messages to the same log file with a similar log level
as LOG.
m-czernek
m-czernek previously approved these changes Feb 14, 2025
Copy link
Contributor

@m-czernek m-czernek left a comment

Choose a reason for hiding this comment

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

+1, LGTM with some minor nit comments as usual 👍

function main() {
ensure_latest_container_image
if [[ "${CHECK_ALL_FILES}" == "true" ]]; then
files="$(get_all_py_files)"
files="$(get_all_py_files)$(get_all_files_with_python_shebang)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a space here just to make sure the last get_all_py_files and the first get_all_files_with_python_shebang don't merge?

Also, I suspect that both methods might return the same files, so one file might be listed twice. This didn't cause issues (although a bit annoying perhaps in logs), right?

Suggested change
files="$(get_all_py_files)$(get_all_files_with_python_shebang)"
files="$(get_all_py_files) $(get_all_files_with_python_shebang)"

Copy link
Member

Choose a reason for hiding this comment

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

I guess it makes sense to split these, thanks!

I'm sure if we want to include this commit at all, on PR we're not checking those files and I'd like to keep the number of commits that reformat down (so that we can add them to .git-blame-ignore-revs easily). It's something we should revisit shortly either way.

@agraul
Copy link
Member

agraul commented Feb 25, 2025

@m-czernek I think I addressed all your open points now. Please take another look when you have time.

BTW, the checkstyle now failed for the test (I updated it -> it get's checked) because black is reformatting parts I didn't touch. I think I saw this before when we updated the black version in the container, I just hope this doesn't happen all the time

Copy link
Contributor

@m-czernek m-czernek left a comment

Choose a reason for hiding this comment

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

Perfect, +1 from my side :) (though we need to squash fixups, right?)

Regarding the checkstyle, I've seen that before, but IMO this is unlikely to have been caused by a new Black version - trailing comma was a formatting style even when I first formatted our Python parts. I can't explain how this has been missed, honestly.

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.

3 participants