Skip to content

Conversation

@chenbxun
Copy link

What this PR does / why we need it:
This PR introduces an HTTP service for creating snapshots.
The service listens on 0.0.0.0 and handles snapshot creation requests. Upon receiving a request, it locates the corresponding image file by the given device ID and calls the image's create_snapshot() interface.

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:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

src/config.h Outdated
APPCFG_CLASS
APPCFG_PARA(enable, bool, false);
APPCFG_PARA(domainSocket, std::string, "");
APPCFG_PARA(address, std::string, "http://0.0.0.0:12345/snapshot");
Copy link
Member

Choose a reason for hiding this comment

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

http://0.0.0.0:12345 is ok.
It should be used as an HTTP address for multiple functions

Copy link
Member

Choose a reason for hiding this comment

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

use '127.0.0.1' as default for security reason

return ret;
}

int SnapshotHandler::handle_request(photon::net::http::Request& req,
Copy link
Member

Choose a reason for hiding this comment

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

move it to an individual file, such as 'api_server.cpp'

prefetch.cpp
tools/sha256file.cpp
tools/comm_func.cpp
snapshot_server.cpp
Copy link
Member

Choose a reason for hiding this comment

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

‘api_server.cpp’ is more suitable
also, snapshot_server.h --> api_server.h

limitations under the License.
*/

#include "snapshot_server.h"
Copy link
Member

Choose a reason for hiding this comment

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

move it after #include "image_file.h"

"serviceConfig": {
"enable": false,
"domainSocket": "/var/run/overlaybd.sock"
"address": "http://127.0.0.1:12345"
Copy link
Member

Choose a reason for hiding this comment

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

127.0.0.1:9862,
because the port of exporter is 9863 😂

src/config.h Outdated
APPCFG_CLASS
APPCFG_PARA(enable, bool, false);
APPCFG_PARA(domainSocket, std::string, "");
APPCFG_PARA(address, std::string, "http://127.0.0.1:12345");
Copy link
Member

Choose a reason for hiding this comment

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

12345-->9862

};

struct ImageFile;
class SnapshotHandler;
Copy link
Member

Choose a reason for hiding this comment

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

class ApiHandler

Signed-off-by: Xun Chen <xunchen@hust.edu.cn>
@BigVan
Copy link
Member

BigVan commented Dec 23, 2025

LGTM

@BigVan BigVan merged commit 1471eff into containerd:dev/snapshot Dec 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants