Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-04-08 09:06:49 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-04-13 04:14:16 +0300
commit34e1518038a8164c090ccfbfc30ebc7850e62cf0 (patch)
tree7cc8b5eb8c9b1c18eb106d7bd274f50a99d51f01 /internal/vfs
parentbda06683de6d93aeaff8d3c7357983ed7f0ccfc7 (diff)
Allow serving zip from disk in chroot
This is a temporary workaround for https://gitlab.com/gitlab-org/gitlab/-/issues/326117#note_546346101 where daemon-inplace-chroot=true fails to serve zip archives when pages_serve_with_zip_file_protocol is enabled To be removed after we roll-out zip architecture completely https://gitlab.com/gitlab-org/gitlab-pages/-/issues/561 Changelog: fixed
Diffstat (limited to 'internal/vfs')
-rw-r--r--internal/vfs/zip/vfs.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go
index b69522f9..fc83fca2 100644
--- a/internal/vfs/zip/vfs.go
+++ b/internal/vfs/zip/vfs.go
@@ -5,6 +5,7 @@ import (
"errors"
"net/http"
"net/url"
+ "strings"
"sync"
"time"
@@ -50,6 +51,11 @@ type zipVFS struct {
archiveCount int64
httpClient *http.Client
+
+ // TODO: this is a temporary workaround for https://gitlab.com/gitlab-org/gitlab/-/issues/326117#note_546346101
+ // where daemon-inplace-chroot=true fails to serve zip archives when pages_serve_with_zip_file_protocol is enabled
+ // To be removed after we roll-out zip architecture completely https://gitlab.com/gitlab-org/gitlab-pages/-/issues/561
+ chrootPath string
}
// New creates a zipVFS instance that can be used by a serving request
@@ -93,6 +99,7 @@ func (fs *zipVFS) Reconfigure(cfg *config.Config) error {
fs.cacheExpirationInterval = cfg.Zip.ExpirationInterval
fs.cacheRefreshInterval = cfg.Zip.RefreshInterval
fs.cacheCleanupInterval = cfg.Zip.CleanupInterval
+ fs.chrootPath = cfg.Zip.ChrootPath
if err := fs.reconfigureTransport(cfg); err != nil {
return err
@@ -239,10 +246,21 @@ func (fs *zipVFS) findOrOpenArchive(ctx context.Context, key, path string) (*zip
return nil, err
}
- err = zipArchive.openArchive(ctx, path)
+ err = zipArchive.openArchive(ctx, fs.removeChrootPath(path))
if err != nil {
return nil, err
}
return zipArchive, nil
}
+
+// TODO: this is a temporary workaround for https://gitlab.com/gitlab-org/gitlab/-/issues/326117#note_546346101
+// where daemon-inplace-chroot=true fails to serve zip archives when pages_serve_with_zip_file_protocol is enabled
+// To be removed after we roll-out zip architecture completely https://gitlab.com/gitlab-org/gitlab-pages/-/issues/561
+func (fs *zipVFS) removeChrootPath(path string) string {
+ if fs.chrootPath == "" || strings.HasPrefix(path, "http") {
+ return path
+ }
+
+ return strings.ReplaceAll(path, fs.chrootPath, "")
+}