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

Ensure subp doesn't run during logs.py import #5268

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

TheRealFalcon
Copy link
Member

Proposed Commit Message

See individual commits

Additional Context

tests/unittests/cmd/devel/test_logs.py would fail if you ran the file on its own due to subp happening on import.

The 2nd commit is just some extra cleanup.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

@TheRealFalcon the PR looks good, but I think some of the changes meant for the fix PR ended up in the cleanup PR, and tests fail on the first commit:

FAILED tests/unittests/cmd/devel/test_logs.py::TestCollectInstallerLogs::test_include_installer_logs_when_present[no_files_include_userdata] - AttributeError: module 'cloudinit.cmd.devel.logs' has no attribute '_collect_installer_logs'. Did you mean: 'collect_installer_logs'?
FAILED tests/unittests/cmd/devel/test_logs.py::TestCollectInstallerLogs::test_include_installer_logs_when_present[no_files_exclude_userdata] - AttributeError: module 'cloudinit.cmd.devel.logs' has no attribute '_collect_installer_logs'. Did you mean: 'collect_installer_logs'?
FAILED tests/unittests/cmd/devel/test_logs.py::TestCollectInstallerLogs::test_include_installer_logs_when_present[files_and_dirs_include_userdata] - AttributeError: module 'cloudinit.cmd.devel.logs' has no attribute '_collect_installer_logs'. Did you mean: 'collect_installer_logs'?
FAILED tests/unittests/cmd/devel/test_logs.py::TestCollectInstallerLogs::test_include_installer_logs_when_present[files_and_dirs_exclude_userdata] - AttributeError: module 'cloudinit.cmd.devel.logs' has no attribute '_collect_installer_logs'. Did you mean: 'collect_installer_logs'?

instance_data_sensitive: str


def get_log_paths(init: Optional[Init] = None) -> LogPaths:
Copy link
Member

Choose a reason for hiding this comment

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

+1 nice

@@ -1050,7 +1050,7 @@ def main(sysv_args=None):
handle_collect_logs_args,
)

logs_parser(parser_collect_logs)
logs_parser(parser=parser_collect_logs)
Copy link
Member

Choose a reason for hiding this comment

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

was this intended to be in the cleanup commit?

@@ -293,7 +298,11 @@ def collect_logs(tarfile, include_userdata: bool, verbosity=0):

def handle_collect_logs_args(name, args):
"""Handle calls to 'cloud-init collect-logs' as a subcommand."""
return collect_logs(args.tarfile, args.userdata, args.verbosity)
return collect_logs(
Copy link
Member

Choose a reason for hiding this comment

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

was this intended to be in the cleanup commit?

@holmanb holmanb self-assigned this May 8, 2024
Copy link

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label May 23, 2024
@TheRealFalcon TheRealFalcon removed the stale-pr Pull request is stale; will be auto-closed soon label May 23, 2024
TheRealFalcon added a commit to TheRealFalcon/cloud-init that referenced this pull request May 23, 2024
TheRealFalcon added a commit to TheRealFalcon/cloud-init that referenced this pull request May 23, 2024
@TheRealFalcon
Copy link
Member Author

I had to rebase because local linting was acting weird, so the most recent changes might not be obvious. I'll explain them here.

For your two comments of was this intended to be in the cleanup commit?, the answer is no actually. The first commit had initially also moved arg parsing around, but I later noticed it broke some other code so I undid most of it, but the named arguments stuck around. But I agree that they make more sense in the other commit, so I moved them.

Beyond those two, the other change was the test_logs.py change of moving the logs.collect_installer_logs -> logs._collect_installer_logs to the later commit, allowing unit tests to pass cleanly on both commits.

I also amended the commit message of both commits to include the PR number here.

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

Nit: I would use fix rather than refactor for the first commit, since it makes functional changes which resolve undesirable behavior. Otherwise this looks good to me!

@TheRealFalcon TheRealFalcon merged commit 3d69851 into canonical:main Jun 3, 2024
20 of 22 checks passed
@TheRealFalcon TheRealFalcon deleted the subp-import branch June 3, 2024 13:20
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.

None yet

2 participants