Skip to content

Conversation

@TheRealFalcon
Copy link
Contributor

Proposed Commit Message

Fix some non-Linux test failures

At least partially fixes GH-5336

Additional Context

With these changes (and changes to the default TMPDIR), tests pass for me on a Mac. This PR contains multiple commits and each commit should be independently reviewable. I'll leave it up to whoever merges to decide if they want to squash or not.

Test Steps

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>)

@TheRealFalcon
Copy link
Contributor Author

Bwahaha...CLA bites me too. I'll get that taken care of

@TheRealFalcon
Copy link
Contributor Author

Update: we're looking into doing the company-wide CLA, so it may be a while

@holmanb
Copy link
Member

holmanb commented Sep 18, 2025

Update: we're looking into doing the company-wide CLA, so it may be a while

Thanks for the update. Keep us posted!

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Oct 3, 2025
@holmanb holmanb removed the stale-pr Pull request is stale; will be auto-closed soon label Oct 3, 2025
@TheRealFalcon
Copy link
Contributor Author

Update: still waiting on CLA. Mostly just commenting to stop the stale checker from flagging this again 😄

@canonical canonical deleted a comment from github-actions bot Oct 28, 2025
@TheRealFalcon
Copy link
Contributor Author

CLA has been signed on our end, so now just waiting for whatever magic needs to happen on the Canonical side for the CLA checker to be updated.

@blackboxsw
Copy link
Collaborator

CLA has been signed on our end, so now just waiting for whatever magic needs to happen on the Canonical side for the CLA checker to be updated.

Woo hoo! Welcome back!

@blackboxsw
Copy link
Collaborator

@TheRealFalcon in prepartion for landing, a couple of hacktoberfest commits landed dropping tests/helpers.py::TestCase which resulted in a merge conflict. I'll make sure I touch base with Canonical CLA folks to ensure the CLA signing is permitted now for your company so we can clear the CI workflow.

@TheRealFalcon
Copy link
Contributor Author

Noted, I'll do the rebase once the CLA checker says I'm good. I've just been manually curling it to see.

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Nov 14, 2025
@holmanb holmanb removed the stale-pr Pull request is stale; will be auto-closed soon label Nov 14, 2025
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.

The code changes look good to me. There is a merge conflict, and the CLA job hasn't passed yet, but once those are resolved I'd say that this is ready for a rebase merge.

Thanks @TheRealFalcon!

from cloudinit import user_data as ud
from cloudinit import util
from cloudinit import (
util,
Copy link
Member

Choose a reason for hiding this comment

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

nit: I assume this change wasn't intended? if this is what black wants now, maybe we could just move this up with the import list above this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hrm, isort insists on it. It's because the as ud line has to be called out separately but is ordered before util. Seems like a stupid isort quirk, but I'd rather just leave it rather than try to work around it.

cmd = [
SH,
"-c",
'echo -n "$@"',
Copy link
Member

Choose a reason for hiding this comment

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

interesting - I didn't realize that this isn't defined in posix

Copy link

Choose a reason for hiding this comment

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

Maybe this fix should be separated in a PR of its own to avoid being buried in 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.

I wouldn't bother with that. Since this is test code this shouldn't affect the end user in any way or be worth treating differently than this OS compatibility PR.

@TheRealFalcon
Copy link
Contributor Author

Thanks!

the CLA job hasn't passed yet

Still waiting on this unfortunately. I believe we submitted it a few weeks ago. Is there something stuck on the Canonical side?

@blackboxsw
Copy link
Collaborator

Thanks!

the CLA job hasn't passed yet

Still waiting on this unfortunately. I believe we submitted it a few weeks ago. Is there something stuck on the Canonical side?

I've copied internal folks here saying we're blocked with "external" contributors having signed the CLA. My visibility here is that legal has been asked about this directly and they CLA-folks are awaiting a response. I'll bump this topic again so we can unblock.

@TheRealFalcon
Copy link
Contributor Author

sigh looks like there's still more to sort on our end. Commenting again to keep the auto-closer quiet

@canonical canonical deleted a comment from github-actions bot Dec 9, 2025
@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Dec 23, 2025
@canonical canonical deleted a comment from github-actions bot Dec 24, 2025
@blackboxsw blackboxsw removed the stale-pr Pull request is stale; will be auto-closed soon label Dec 24, 2025
@holmanb holmanb self-assigned this Jan 5, 2026
The "has_gnu_date" function checks "date --help" output, but some
versions of "date" don't include a "--help" flag.
`time.strftime()` has platform-specific behavior when dealing with
a `gmtime()` struct.
It was removed in canonical#6356, but is still needed in some tests that
interact with `/tmp`.
@TheRealFalcon
Copy link
Contributor Author

Happy new year! CLA check finally passes!

I rebased and applied the one comment. I'll clean up the other test failure/linter stuff so we can hopefully finally get this through.

Many socket attributes are OS-specific, so ensure we
have attributes that work for the tests that need them.
Also, mock socket calls where needed.
'echo -n' isn't universal
Note that this test wasn't always Linux-specific, but when the pid
stuff moved under Distro, the test was changed to test the base
class (i.e., Linux) functionality only.
Implementation differences cause different results.
@TheRealFalcon
Copy link
Contributor Author

This should be ready for review again

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 thanks for this! One minor nitpick and then I'm happy to merge it.

from cloudinit import user_data as ud
from cloudinit import util
from cloudinit import (
util,
Copy link
Member

Choose a reason for hiding this comment

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

nit: an import list one item long seems messy. We should be able to include this in the multi-line list starting on line 10

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if you saw my response on the earlier comment, but

isort insists on it. It's because the as ud line has to be called out separately but is ordered before util. Seems like a stupid isort quirk, but I'd rather just leave it rather than try to work around it.

If I move this one to the other list, the lint fails. Would you rather I leave it or try to silence isort?

Copy link
Member

@holmanb holmanb Jan 6, 2026

Choose a reason for hiding this comment

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

Oops, thanks for restating that. It is fine as-is. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Oops, thanks for restating that.

That's silly, but it doesn't need to change. I'm fine with it as-is.

Copy link
Member

Choose a reason for hiding this comment

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

Oops, thanks for restating that.

That's silly, but it doesn't need to change. I'm fine with it as-is.

def cfg(tmp_path, mocker):
mocker.patch("cloudinit.util.os.chown")
# root group doesn't exist everywhere
mocker.patch("cloudinit.util.chownbyname")
Copy link
Member

Choose a reason for hiding this comment

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

+1, we shouldn't have been depending on that anyways

cmd = [
SH,
"-c",
'echo -n "$@"',
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't bother with that. Since this is test code this shouldn't affect the end user in any way or be worth treating differently than this OS compatibility PR.

TMPDIR = os.getenv("TMPDIR", "/tmp")
Path(tmpdir, TMPDIR[1:]).mkdir(exist_ok=True)
Path(tmpdir, TMPDIR[1:]).mkdir(parents=True, exist_ok=True)
Path(tmpdir, "tmp").mkdir(exist_ok=True)
Copy link
Member

Choose a reason for hiding this comment

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

I see that setting TMPDIR causes tests to fail before this change. Tests also fail when TMPDIR includes a trailing slash, but fixing that isn't a very high priority in my opinion.

@holmanb holmanb merged commit b5080b9 into canonical:main Jan 6, 2026
20 checks passed
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.

4 participants