From 1e5b88a4900ae32fadb05ae1e41b9108ef1410f1 Mon Sep 17 00:00:00 2001 From: guacamole Date: Sun, 21 Nov 2021 22:05:50 +0530 Subject: [PATCH] Feat: offloading bandwidth to client side for Pull operations Signed-off-by: guacamole --- .github/workflows/conformance.yml | 2 +- registry/v2/registry.go | 3 ++- telemetry/fluent-bit/fluent_bit.go | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index 56f4e972..b9a870f6 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -26,7 +26,7 @@ jobs: sleep 5 curl -XPOST -d ${{ secrets.OPENREGISTRY_SIGNUP_PAYLOAD }} "http://${IP}:5000/auth/signup" - name: Run OCI Distribution Spec conformance tests - uses: opencontainers/distribution-spec@main + uses: opencontainers/distribution-spec@v1.0.1 env: OCI_ROOT_URL: ${{ env.OCI_ROOT_URL }} OCI_USERNAME: ${{ secrets.OPENREGISTRY_USERNAME }} diff --git a/registry/v2/registry.go b/registry/v2/registry.go index 30346602..5f37d3a5 100644 --- a/registry/v2/registry.go +++ b/registry/v2/registry.go @@ -550,10 +550,11 @@ func (r *registry) PullLayer(ctx echo.Context) error { } } - _, ok := r.skynet.Metadata(layerRef.Skylink) + size, ok := r.skynet.Metadata(layerRef.Skylink) if ok { url := fmt.Sprintf("https://siasky.net/%s", strings.Replace(layerRef.Skylink, "sia://", "", 1)) + ctx.Response().Header().Set("Content-Length", fmt.Sprintf("%d", size)) http.Redirect(ctx.Response(), ctx.Request(), url, http.StatusTemporaryRedirect) return nil } diff --git a/telemetry/fluent-bit/fluent_bit.go b/telemetry/fluent-bit/fluent_bit.go index 6edb36d5..f82ea164 100644 --- a/telemetry/fluent-bit/fluent_bit.go +++ b/telemetry/fluent-bit/fluent_bit.go @@ -46,7 +46,11 @@ func New(config *config.RegistryConfig) (FluentBit, error) { func (fb *fluentBit) Send(logBytes []byte) { // don't send logs to grafana from local instances of OpenRegistry - if fb.config.Environment == config.Dev || fb.config.Environment == config.Local { + dev := fb.config.Environment == config.Dev + local := fb.config.Environment == config.Local + ci := fb.config.Environment == config.CI + + if dev || local || ci { return }