You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:24:55 UTC

[buildstream] 07/15: Allow the user to set a cache quota

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch jennis/136-clean-remote-cache
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit f990f8888e06fea64ae5fea9f491046550a00d3c
Author: James Ennis <ja...@codethink.com>
AuthorDate: Wed Apr 18 15:51:32 2018 +0100

    Allow the user to set a cache quota
---
 buildstream/_artifactcache/pushreceive.py | 11 ++++++++---
 doc/source/artifacts.rst                  |  4 +++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/buildstream/_artifactcache/pushreceive.py b/buildstream/_artifactcache/pushreceive.py
index 75a65e1..d276c71 100644
--- a/buildstream/_artifactcache/pushreceive.py
+++ b/buildstream/_artifactcache/pushreceive.py
@@ -570,9 +570,10 @@ class OSTreePusher(object):
 #     pull_url (str): Redirection for clients who want to pull, not push.
 #
 class OSTreeReceiver(object):
-    def __init__(self, repopath, pull_url):
+    def __init__(self, repopath, pull_url, cache_quota):
         self.repopath = repopath
         self.pull_url = pull_url
+        self.cache_quota = cache_quota
 
         if self.repopath is None:
             self.repo = OSTree.Repo.new_default()
@@ -799,8 +800,10 @@ def push(repo, remote, branches, output):
 @click.option('--debug', '-d', is_flag=True, default=False, help="Debug mode")
 @click.option('--pull-url', type=str, required=True,
               help="Clients who try to pull over SSH will be redirected here")
+@click.option('--cache-quota', type=int,
+              help="Implement a quota on the cache (in bytes) here")
 @click.argument('repo')
-def receive_main(verbose, debug, pull_url, repo):
+def receive_main(verbose, debug, pull_url, cache_quota, repo):
     """A BuildStream sister program for receiving artifacts send to a shared artifact cache
     """
     loglevel = logging.WARNING
@@ -811,5 +814,7 @@ def receive_main(verbose, debug, pull_url, repo):
     logging.basicConfig(format='%(module)s: %(levelname)s: %(message)s',
                         level=loglevel, stream=sys.stderr)
 
-    receiver = OSTreeReceiver(repo, pull_url)
+    # IDEA: have it so that cache_quota can allow human friendly input.
+
+    receiver = OSTreeReceiver(repo, pull_url, cache_quota)
     return receiver.run()
diff --git a/doc/source/artifacts.rst b/doc/source/artifacts.rst
index e0808e8..f181c67 100644
--- a/doc/source/artifacts.rst
+++ b/doc/source/artifacts.rst
@@ -160,7 +160,9 @@ For this you will want something like the following in your ``/etc/ssh/sshd_conf
 	# command must be specified here; 'artifacts' is
 	# the HOME relative path to the artifact cache.
 	# The exact pull URL must also be specified.
-        ForceCommand bst-artifact-receive --pull-url https://example.com/artifacts --verbose artifacts
+	# A cache-quota is optional and should be specified in bytes
+	## FIXME: The above should have a function which converts 20G -> bytes...
+        ForceCommand bst-artifact-receive --pull-url https://example.com/artifacts --cache-quota quota_in_bytes --verbose artifacts
 
 
 User configuration