Skip to content

Conversation

@michalpristas
Copy link
Contributor

@michalpristas michalpristas commented Jun 5, 2025

This PR refactor the way how we do User change during unprivileged and privileged actions.

Pre-PR we removed and reinstalled service again with new user setup.

Post-PR we rewrite service file directly (linux and darwin) or use syscall to change config (windows). Then we restart service.

This reduces window for interrupt.
While pre-PR could leave us without a service, in this case we haven't won entirely. We can end up with broken service when service manager decides config/user is not valid/enabled. This at least leaves a trace in system logs.

Tests covering switch between privilege modes are already present

Closes: #8268

@michalpristas michalpristas self-assigned this Jun 5, 2025
@michalpristas michalpristas requested a review from a team as a code owner June 5, 2025 10:34
@michalpristas michalpristas added the enhancement New feature or request label Jun 5, 2025
@michalpristas michalpristas requested review from kaanyalti and pchila June 5, 2025 10:34
@michalpristas michalpristas added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches labels Jun 5, 2025
@elasticmachine
Copy link
Collaborator

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

@michalpristas michalpristas requested a review from blakerouse June 6, 2025 08:50
@michalpristas
Copy link
Contributor Author

michalpristas commented Jun 9, 2025

need to figure out some Server vs Home behavior differences

@mergify
Copy link
Contributor

mergify bot commented Jun 18, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b feat/replace-svc upstream/feat/replace-svc
git merge upstream/main
git push upstream feat/replace-svc

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for working through the code review.

@elastic-sonarqube
Copy link

Quality Gate failed Quality Gate failed

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

See analysis details on SonarQube

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @michalpristas

@michalpristas michalpristas merged commit f942cf9 into elastic:main Jul 4, 2025
18 of 19 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2025

@Mergifyio backport 9.0 9.1

@mergify
Copy link
Contributor

mergify bot commented Jul 4, 2025

backport 9.0 9.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jul 4, 2025
(cherry picked from commit f942cf9)

# Conflicts:
#	NOTICE-fips.txt
#	go.mod
mergify bot pushed a commit that referenced this pull request Jul 4, 2025
v1v added a commit that referenced this pull request Jul 6, 2025
* upstream: (39 commits)
  Fix otel extension status reporting (#8696)
  Refactor user change on service (#8347)
  [AutoOps] Add `autoops-es.yml` to Packages (#8728)
  EDOT collector: include the forward connector. (#8753)
  Revert "ci: pin elastic-agent version (#8736)" (#8754)
  bk: retry Start ESS stack for integration tests (#8553)
  Re-enable TestStandaloneUpgradeRollbackOnRestarts on windows (#8718)
  removed reviewers from dependabot.yml (#8709)
  Pass `--header` enrollment option to fleet-server (#8071)
  Add ability for local output configuration to add to policy configuration (#8766)
  Bump up github.com/go-viper/mapstructure/v2 dependency (#8764)
  [Synthetics] Upgrade node to latest lts v20 (#8712)
  [CI] BK Vault plugin for EC access (#8377)
  feat: singleTest mage target for each integration test package (#8691)
  ci: always include 8.19 LTS release branch in snapshots of test versions (#8761)
  build(deps): bump github.com/elastic/mito from 1.19.0 to 1.20.0 (#8755)
  chore: fix elastic-agent helm chart examples (#8765)
  feat: support onboarding-id for kubernetes (#8692)
  [main][Automation] Bump VM Image version to 1751072471 (#8734)
  ci: revert deployment_csp_configuration.yaml to create_deployment_csp_configuration.yaml (#8746)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches enhancement New feature or request skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use config replace logic instead of reinstalling service in switch

4 participants