-
Notifications
You must be signed in to change notification settings - Fork 67
[develop] add create_snapshot() interface #387
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
base: main
Are you sure you want to change the base?
Conversation
This commit introduces a live snapshot feature for overlaybd with the following key capabilities: - Add HTTP API server (/snapshot endpoint) for creating snapshots on demand - Implement create_snapshot() to dynamically restack RW layers - Add device ID tracking system for image file management - Support config_path;dev_id format in configuration strings - Extend LSMT layer management with restack(), index manipulation, and file operations - Add comprehensive tests for restacking, device registration, and snapshot creation Co-authored-by: Xun Chen <[email protected]> Co-authored-by: Yifan Yuan <[email protected]> Signed-off-by: Yifan Yuan <[email protected]>
Add documentation for the live snapshot feature including: - serviceConfig configuration options - Device ID format and usage - HTTP API endpoint (/snapshot) - New config format requirements - Usage examples and notes Signed-off-by: Yifan Yuan <[email protected]>
|
@WaberZhuang @liulanzheng PTAL |
| photon::net::http::Response& resp, | ||
| std::string_view) override; | ||
| void parse_params(std::string_view query); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not necessary to expose ApiHandler in the header file. It's okay to just pass ImageService* to ApiServer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting that I should define ApiHandler in the cpp file instead of the header, and then instantiate it inside the ApiServer constructor?
| auto pos = target.find('?'); | ||
| if (pos != std::string_view::npos) { | ||
| query = target.substr(pos + 1); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use req.query() instead.
| } | ||
|
|
||
| auto upper = new_cfg.upper(); | ||
| auto lowers = new_cfg.lowers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lowers is unused
| ((LSMT::IFileRO *)m_lower_file)->index(combo_index->backing_index()); | ||
| // set m_file->m_index->m_index0 = upper_file->m_index | ||
| auto upper_file_index = (LSMT::IMemoryIndex0 *)((LSMT::IFileRW *)upper_file)->index(); // upper_file->m_index | ||
| combo_index->front_index(upper_file_index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we overwrite the config file in use at this time? Otherwise, the old files will be used again after the process restarts.
| virtual int front_index(const IMemoryIndex0 *fi) override { | ||
| if (!fi) { | ||
| errno = EINVAL; | ||
| LOG_ERROR("Invalid index!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG_ERROR_RETURN
| } | ||
| if (m_ownership && m_index0 != nullptr) { // !!! | ||
| delete m_index0; | ||
| m_index0 = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safe_delete
What this PR does / why we need it:
Add online snapshot functionality to overlaybd.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Please check the following list: