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

fix(agent): No empty cloudinit #886

Merged
merged 10 commits into from
Aug 28, 2024
Merged

fix(agent): No empty cloudinit #886

merged 10 commits into from
Aug 28, 2024

Conversation

CarlosNihelton
Copy link
Contributor

When the config is empty, the yaml serialization outputs {}. We still added some commentary in the agent.yaml, resulting in a bunch of nothing that confused cloud-init, because it's enablement is based on the existence of the files, their contents are only checked later. That wouldn't be a problem per se, as the WSL datasource would recognize there's nothing to do and bail out, but that would have costed unnecesary CPU cicles, and worse than that, the current implementation of cloud-init makes it log as an error the fact that there is nothing to do at this point, which results in more noise if the user see the output of cloud-init status --long.

The fix is rather simple: do not write an empty object into agent.yaml. If the config is empty we delete that file. This way, if there is nothing from the user nor the agent's perspective, cloud-init will remain trully disabled.

I updated some tests that relied on the fact that cloud-init would create the agent.yaml file unconditionally, which is no longer the case.

UDENG-4169

File mode 0600 was not intended for this specific case,
as the setup step expects to be able to list and write into the
directory.
It was not noticed because the directory was previously created by
cloudinit.New.
Not that cloudinit won't create the directory if there is nothing to
write into, the bug was revealed.
If marshalConfig returns `nil, nil` there is no error but also nothing
for cloud-init to do. Thus, there should be no agent.yaml in disk.

So, we check for that condition and attempt to remove agent.yaml
from the cloudinit dataDir, if it exists. Missing file is not an error.
We previously didn't bother with the contents of agent.yaml
But now that it will only exist after the registry notifications reach
the cloudinit component, we need to wait for that file to appear before
proceeding with any assertion.
And now we no longer expect to find an empty file, but a file that
matches what was set via the registry.
Using the existence of goldens as the way to signal the test cases that
agent.yaml should exist or not.
@CarlosNihelton CarlosNihelton changed the title fix(agent); No empty cloudinit fix(agent): No empty cloudinit Aug 28, 2024
@CarlosNihelton
Copy link
Contributor Author

This is the same as #881 , but to merge on main. I merged that PR on the wrong base branch by mistake 😅

@CarlosNihelton CarlosNihelton marked this pull request as ready for review August 28, 2024 13:29
@CarlosNihelton CarlosNihelton requested a review from a team as a code owner August 28, 2024 13:29
Copy link
Collaborator

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Just looked quickly at the diff, and it seems that you did carry what was needed.

@CarlosNihelton
Copy link
Contributor Author

Indeed, I just restored the branch no-empty-cloudinit which had been rebased on main and opened a new PR with that.

@CarlosNihelton CarlosNihelton self-assigned this Aug 28, 2024
@CarlosNihelton CarlosNihelton merged commit f8f4a45 into main Aug 28, 2024
65 of 66 checks passed
@CarlosNihelton CarlosNihelton deleted the no-empty-cloudinit branch August 28, 2024 13:38
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.

2 participants