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(windows-agent): No empty agent.yaml #881

Merged
merged 19 commits into from
Aug 28, 2024

Conversation

CarlosNihelton
Copy link
Contributor

@CarlosNihelton CarlosNihelton commented Aug 23, 2024

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

CarlosNihelton and others added 9 commits August 20, 2024 13:32
Using Flutter built-in facilities
instead of handcrafting code to trim spaces when the field changes.
As before, it's enabled by default in debug mode.
In production model.isSaaSSupported returns false and the option is hidden from the radio group.
Per guidance in UDENG-3818.
This hides the Landscape config option (instead of disabling it). No
changes in behaviour nor in how we decide to hide it.
Some strings were changed also per guidance provided in #861. 
Finally I added a little bit more spacing in the top now that the
subtitle is one line only.

Here's how it looks like when compiled in release mode.


![image](https://github.com/user-attachments/assets/f9bb98aa-b544-44a2-82d2-6d5da2b186e0)

Closes #861 

---

I'm purposefully basing this PR on top of #873 so I can stress CI to
exercise the changes therein introduced. There is no dependency between
the two tasks.

---
UDENG-3818
Sometimes copy-pasting a pro token comes with trailing spaces. Neither
leading, trailing or even middle spaces are alloweable in a token. This
PR leverages Flutter builtin mechanisms to filter input supplied to the
token text field such that any kind of whitespaces (not only the ASCII
ones) are discarded before any further processing.

Closes #857 

---

I'm purposefully basing this PR on top of #873 so I can stress CI to
exercise the changes therein introduced. There is no dependency between
the two tasks.

---
UDENG-3810
Bumps [file_picker](https://github.com/miguelpruivo/flutter_file_picker) from 8.1.1 to 8.1.2.
- [Release notes](https://github.com/miguelpruivo/flutter_file_picker/releases)
- [Changelog](https://github.com/miguelpruivo/flutter_file_picker/blob/master/CHANGELOG.md)
- [Commits](https://github.com/miguelpruivo/flutter_file_picker/commits)

---
updated-dependencies:
- dependency-name: file_picker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (fix-agent-flakyness@6dfc292). Learn more about missing BASE report.

Files Patch % Lines
windows-agent/internal/cloudinit/cloudinit.go 86.36% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##             fix-agent-flakyness     #881   +/-   ##
======================================================
  Coverage                       ?   88.71%           
======================================================
  Files                          ?      105           
  Lines                          ?     6866           
  Branches                       ?        0           
======================================================
  Hits                           ?     6091           
  Misses                         ?      601           
  Partials                       ?      174           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@CarlosNihelton CarlosNihelton marked this pull request as ready for review August 26, 2024 13:27
@CarlosNihelton CarlosNihelton requested a review from a team as a code owner August 26, 2024 13:27
@CarlosNihelton CarlosNihelton marked this pull request as draft August 26, 2024 19:45
@CarlosNihelton CarlosNihelton marked this pull request as ready for review August 26, 2024 20:48
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.

Some small fixes to do and some questions!

windows-agent/internal/cloudinit/cloudinit.go Outdated Show resolved Hide resolved
@@ -47,6 +55,10 @@ func TestNew(t *testing.T) {

// We don't assert on specifics, as they are tested in WriteAgentData tests.
path := filepath.Join(publicDir, ".cloud-init", "agent.yaml")
if tc.emptyConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would make that an explicit Want to separate the predicate (we do have an empty config) to "I want no config file"

@@ -172,6 +191,17 @@ hostagent_uid = landscapeUID1234
return
}

if tc.breakRemovingFile {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto here and below on what we want to be separated from the initial state. That way, we have a clear story on the side effect and what is expected.

windows-agent/internal/proservices/proservices_test.go Outdated Show resolved Hide resolved
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.
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.

All good from my standpoint now!

@CarlosNihelton CarlosNihelton merged commit 68e6564 into fix-agent-flakyness Aug 28, 2024
35 checks passed
@CarlosNihelton CarlosNihelton deleted the no-empty-cloudinit branch August 28, 2024 13:24
@CarlosNihelton CarlosNihelton restored the no-empty-cloudinit branch August 28, 2024 13:25
CarlosNihelton added a commit that referenced this pull request Aug 28, 2024
Reverts #881

Merged on the wrong branch :(
@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