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

storage: add new backend HttpProxy #974

Merged
merged 1 commit into from
Feb 6, 2023
Merged

Conversation

loheagn
Copy link
Contributor

@loheagn loheagn commented Dec 23, 2022

This pr adds a new storage backend HttpProxy which can access blobs through a http proxy server.

The http proxy server can be local (using unix socket) or remote (using https:// or using http://).

HttpProxy uses two API endpoints to access the blobs:

  • HEAD /path/to/blobs to get the blob size
  • GET /path/to/blobs to read the blob

The http proxy server should respect the Range header to compute the offset and length of the blob.

The example config files for this new backend may be:

// for remote usage
{
  "backend": {
    "type": "http-proxy",
    "config": {
      "addr": "http://127.0.0.1:9977",
      "path": "/namespace/<repo>/blobs"
    }
  }
}

or

// for local unix socket
{
  "backend": {
    "type": "http-proxy",
    "config": {
      "addr": "/path/to/unix/socket/file"
    }
  }
}

There is also a test in http_proxy.rs to make sure HttpProxy works well, which setups a simple http server and generates a HttpProxy backend to get contents from the server.

Signed-off-by: Nan Li loheagn@icloud.com

@anolis-bot
Copy link
Collaborator

@loheagn , a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/40296

@anolis-bot
Copy link
Collaborator

@loheagn , The CI test is completed, please check result:

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus✅ SUCCESS
compile-ctr-remote✅ SUCCESS
compile-nydus-snapshotter✅ SUCCESS
start-nydus-snapshotter-config-containerd✅ SUCCESS
run-container-with-nydus-image✅ SUCCESS

Congratulations, your test job passed!

@imeoer
Copy link
Collaborator

imeoer commented Dec 23, 2022

Thanks @loheagn for the contribution, it can make nydus-image unpack faster!

My suggestion is that maybe we should implement the content store backend with HTTP over unix domain socket instead of TCP, which is simpler and requires only implementing two distribution APIs:

  • HEAD blob size;
  • GET blob data (HTTP range get);

It's very like contrib/nydus-backend-proxy server, it receives HTTP requests and proxy to a local blob directory, in our scenario, it needs proxy the requests to containerd content store.

@anolis-bot
Copy link
Collaborator

@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/43987

@anolis-bot
Copy link
Collaborator

@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/43988

@anolis-bot
Copy link
Collaborator

@loheagn , The CI test is completed, please check result:

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@anolis-bot
Copy link
Collaborator

@loheagn , The CI test is completed, please check result:

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@anolis-bot
Copy link
Collaborator

@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/43992

@anolis-bot
Copy link
Collaborator

@loheagn , The CI test is completed, please check result:

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@@ -427,6 +441,14 @@ pub struct S3Config {
pub mirrors: Vec<MirrorConfig>,
}

/// ContentProxyProxy configuration information to access blobs.
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct LocalHttpProxyConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about LocalUdsConfig?
We can define an APIs to retrieve blobs from Unix domain socket, no matter it's containerd content store or something else.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or ContainerdContentStoreProxy? @imeoer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But this backend driver only support http protocol now. I think LocalHttpProxy may be better.

Copy link
Collaborator

@imeoer imeoer Jan 17, 2023

Choose a reason for hiding this comment

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

It's ok for me if using HttpProxy, maybe we can merge the feature with nydus-backend-proxy (not in this PR)? So that we can use HttpProxy to request an HTTP server that can proxy to local blob directory/containerd content store.

@anolis-bot
Copy link
Collaborator

@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/44026

@loheagn loheagn changed the title content store proxy storage: add new backend LocalHttpProxy Jan 15, 2023
@anolis-bot
Copy link
Collaborator

@loheagn , the title has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/44027

@imeoer
Copy link
Collaborator

imeoer commented Feb 3, 2023

Hi @loheagn, Could also update the doc in here? Thanks!

@anolis-bot
Copy link
Collaborator

@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/47782

@loheagn
Copy link
Contributor Author

loheagn commented Feb 3, 2023

Hi @loheagn, Could also update the doc in here? Thanks!

No problem. The docs were updated.

@anolis-bot
Copy link
Collaborator

@loheagn , The CI test is completed, please check result:

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@anolis-bot
Copy link
Collaborator

@loheagn , The CI test is completed, please check result:

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus✅ SUCCESS
compile-ctr-remote✅ SUCCESS
compile-nydus-snapshotter✅ SUCCESS
start-nydus-snapshotter-config-containerd✅ SUCCESS
run-container-with-nydus-image❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@anolis-bot
Copy link
Collaborator

@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/47934

@anolis-bot
Copy link
Collaborator

@loheagn , The CI test is completed, please check result:

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus✅ SUCCESS
compile-ctr-remote✅ SUCCESS
compile-nydus-snapshotter✅ SUCCESS
start-nydus-snapshotter-config-containerd✅ SUCCESS
run-container-with-nydus-image❌ FAIL

Sorry, your test job failed. Please get the details in the link.

docs/nydusd.md Outdated
or

```
// for remote usage
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be for local usage here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed :)

This patch adds a new storage backend `HttpProxy` which can access blobs through a http proxy server.

The http proxy server can be local (using unix socket) or remote (using `https://` or using `http://`).

`HttpProxy` uses two API endpoints to access the blobs:
- `HEAD /path/to/blobs` to get the blob size
- `GET /path/to/blobs` to read the blob

The http proxy server should respect [the `Range` header](https://www.rfc-editor.org/rfc/rfc9110.html#name-range) to compute the offset and length of the blob.

The example config files for this new backend may be:

```jsonc
// for remote usage
{
  "backend": {
    "type": "http-proxy",
    "config": {
      "addr": "http://127.0.0.1:9977",
      "path": "/namespace/<repo>/blobs"
    }
  }
}
```

or

```jsonc
// for local unix socket
{
  "backend": {
    "type": "http-proxy",
    "config": {
      "addr": "/path/to/unix/socket/file"
    }
  }
}
```

There is also a test in `http_proxy.rs` to make sure `HttpProxy` works well, which setups a simple http server and generates a `HttpProxy` backend to get contents from the server.

Signed-off-by: Nan Li <loheagn@icloud.com>
@anolis-bot
Copy link
Collaborator

@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/48133

@anolis-bot
Copy link
Collaborator

@loheagn , The CI test is completed, please check result:

Test CaseTest Result
merge-target-branch✅ SUCCESS
build-docker-image✅ SUCCESS
compile-nydus✅ SUCCESS
compile-ctr-remote✅ SUCCESS
compile-nydus-snapshotter✅ SUCCESS
start-nydus-snapshotter-config-containerd✅ SUCCESS
run-container-with-nydus-image❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@changweige
Copy link
Contributor

need rebase to master since anolis test script is updated

@imeoer imeoer merged commit 9d268f7 into dragonflyoss:master Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants