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

The component run directory must be copied on upgrade #2136

Closed
cmacknz opened this issue Jan 18, 2023 · 2 comments · Fixed by #2207
Closed

The component run directory must be copied on upgrade #2136

cmacknz opened this issue Jan 18, 2023 · 2 comments · Fixed by #2207
Assignees
Labels
bug Something isn't working Team:Elastic-Agent Label for the Agent team

Comments

@cmacknz
Copy link
Member

cmacknz commented Jan 18, 2023

This is a follow up from #2050 where we discovered that the agent never properly migrated component state (like the Filebeat registry) on upgrade. This results in unnecessary log duplication on upgrade.

To properly fix this in the new V2 directory structure the contents of the component run directory must be copied from data/elastic-agent-$old_version_hash to data/ealstic-agent-$new_version_hash.

For example here the run directory structure for a Filebeat component started to run the log input type in 8.6.0:

/Library/Elastic/Agent/data/elastic-agent-123730/run/log-default/
├── meta.json
└── registry
    └── filebeat
        ├── log.json
        └── meta.json

The entire contents of /run/log-default need to be copied to the data directory of the new version on upgrade. Copying the contents ensures that the previous version can resume from the point prior to the upgrade if a downgrade is necessary without backwards compatibility issues.

Acceptance Criteria:

@cmacknz cmacknz added bug Something isn't working Team:Elastic-Agent Label for the Agent team labels Jan 18, 2023
@michalpristas michalpristas linked a pull request Jan 30, 2023 that will close this issue
6 tasks
@lucabelluccini
Copy link

Hello @cmacknz

How one would perform a downgrade if the upgrade is successful?
I've noticed the old path is not wiped if the upgrade is successful, but we do not document until when it's kept and how one would perform a downgrade properly.
Also, already indexed duplicated documents would be tough to identify.

@cmacknz
Copy link
Member Author

cmacknz commented Apr 18, 2023

How one would perform a downgrade if the upgrade is successful?

A downgrade is just an upgrade to a lower version if that makes sense to you. The agent is just changing a symlink to an active elastic-agent-$hash directory where $hash is the Git SHA of the target agent version. Fleet doesn't support downgrades however, only upgrades.

I've noticed the old path is not wiped if the upgrade is successful, but we do not document until when it's kept and how one would perform a downgrade properly.

The old version is removed when the upgrade succeeds, which is sometime after the new version has been running without issue. This is considered an implementation detail so it isn't something we document.

Also, already indexed duplicated documents would be tough to identify.

Yes, I suspect this is why we don't have many active reports of this problem. The agent never properly copied the Filebeat registry in any previous version.

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

Successfully merging a pull request may close this issue.

3 participants