Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[enroll] Windows can return err, even when operation is successful #6917

Open
leehinman opened this issue Feb 18, 2025 · 3 comments
Open

[enroll] Windows can return err, even when operation is successful #6917

leehinman opened this issue Feb 18, 2025 · 3 comments
Labels
bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Comments

@leehinman
Copy link
Contributor

From CI we have at least one instance of:

[=== ] Waiting For Enroll...  [4s] {"log.level":"info","@timestamp":"2025-02-17T22:04:43.470Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":524},"message":"Starting enrollment to URL: https://079ff92028de13e7d02afc20ee027b5f.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        Error: failed to fix permissions: The operation completed successfully.

That error is coming from

return errors.New(err, "failed to fix permissions")

So apparently on Windows perms.FixPermissions can return an "Error" of "The operation completed successfully". So we need to handle this.

@leehinman leehinman added the bug Something isn't working label Feb 18, 2025
@pkoutsovasilis
Copy link
Contributor

@michel-laterman since you are the author of this PR could the root reason behind this issue be the fact that we don't check for Errno(0) here https://github.com/elastic/elastic-agent/blob/main/internal/pkg/agent/perms/windows.go#L103?

Related CI failures are here and they are regarding sudo and windows, thus, I expect the the if isAdmin branch to be executed

@michel-laterman
Copy link
Contributor

Yes, this is likely a case that we forgot to test for errors.Is(err, syscall.Errno(0)) for the error that can be returned from

if userSID != nil && groupSID != nil {
err = takeOwnership(name, userSID, groupSID)
}

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Feb 19, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

No branches or pull requests

5 participants