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

[8.16](backport #6085) Fix audit/unenroll calls when agent runs fleet-server #6363

Open
wants to merge 6 commits into
base: 8.16
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Dec 17, 2024

What does this PR do?

Call audit/unenroll (during uninstall) before components are stopped if the elastic-agent is running a fleet-server instance.

Why is it important?

Agents running fleet-server instances would always get an error because fleet-server would be stopped by the time the notify call is attempted.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

How to test this PR locally

Enroll an agent in a policy with the fleet-server integration and uninstall the agent

Related issues

* Fix audit/unenroll calls when agent runs fleet-server

* Fix integration test

* Increase output for failed test

* move notification attempt

* move notification attempt

* audit/uninstall will call localhost with certonly tls

* Fix linter

* remove tls setting

* Add PR link to changelog

* stop checking if we need to notify in an error is encountered

* Shorten non-fatal error messages to prevent output issues in terminals

* Don't load agentinfo, use ID value from config instead

* Add unprivilged tests to audit unenroll integration tests

* Add comments for setting hosts

(cherry picked from commit f321d8a)

# Conflicts:
#	internal/pkg/agent/install/uninstall.go
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Dec 17, 2024
@mergify mergify bot requested a review from a team as a code owner December 17, 2024 20:59
@mergify mergify bot requested review from kaanyalti and andrzej-stencel and removed request for a team December 17, 2024 20:59
Copy link
Contributor Author

mergify bot commented Dec 17, 2024

Cherry-pick of f321d8a has failed:

On branch mergify/bp/8.16/pr-6085
Your branch is up to date with 'origin/8.16'.

You are currently cherry-picking commit f321d8a72.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   changelog/fragments/1732043830-Fix-audit-unenroll-call-when-running-fleet-server.yaml
	modified:   internal/pkg/agent/install/uninstall_test.go
	modified:   internal/pkg/fleetapi/ack_cmd.go
	modified:   internal/pkg/fleetapi/audit_unenroll_cmd.go
	modified:   internal/pkg/fleetapi/checkin_cmd.go
	modified:   testing/integration/fleetserver_test.go
	modified:   testing/integration/install_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   internal/pkg/agent/install/uninstall.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@michel-laterman michel-laterman enabled auto-merge (squash) December 18, 2024 22:33
Copy link
Contributor Author

mergify bot commented Dec 23, 2024

This pull request has not been merged yet. Could you please review and merge it @michel-laterman? 🙏

Copy link

Quality Gate failed Quality Gate failed

Failed conditions
3.1% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport conflicts There is a conflict in the backported pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants