[ARVADOS] created: 872b95a8158fd05a73325c15f81918a3b798535f

Git user git at public.curoverse.com
Thu Oct 13 12:57:46 EDT 2016


        at  872b95a8158fd05a73325c15f81918a3b798535f (commit)


commit 872b95a8158fd05a73325c15f81918a3b798535f
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Oct 13 12:31:02 2016 -0400

    10234: Update arvados-git-httpd docs to use systemd + config file.

diff --git a/doc/install/install-arv-git-httpd.html.textile.liquid b/doc/install/install-arv-git-httpd.html.textile.liquid
index 3ec2382..b28674d 100644
--- a/doc/install/install-arv-git-httpd.html.textile.liquid
+++ b/doc/install/install-arv-git-httpd.html.textile.liquid
@@ -232,6 +232,7 @@ On Red Hat-based systems:
 
 <notextile>
 <pre><code>~$ <span class="userinput">sudo yum install git arvados-git-httpd</span>
+~$ <span class="userinput">sudo systemctl enable arvados-git-httpd</span>
 </code></pre>
 </notextile>
 
@@ -254,43 +255,29 @@ fatal: No REQUEST_METHOD from server
 
 h3. Enable arvados-git-httpd
 
-Install runit to supervise the arvados-git-httpd daemon.  {% include 'install_runit' %}
+{% include 'notebox_begin' %}
+
+The arvados-git-httpd package includes configuration files for systemd.  If you're using a different init system, you'll need to configure a service to start and stop an @arvados-git-httpd@ process as desired.
+
+{% include 'notebox_end' %}
 
-Configure runit to run arvados-git-httpd, making sure to update the API host to match your site:
+Create the configuration file @/etc/arvados/git-httpd/git-httpd.yml at . Run @arvados-git-httpd -h@ to learn more about configuration entries.
 
 <notextile>
-<pre><code>~$ <span class="userinput">sudo mkdir -p /etc/sv</span>
-~$ <span class="userinput">cd /etc/sv</span>
-/etc/sv$ <span class="userinput">sudo mkdir arvados-git-httpd; cd arvados-git-httpd</span>
-/etc/sv/arvados-git-httpd$ <span class="userinput">sudo mkdir log</span>
-/etc/sv/arvados-git-httpd$ <span class="userinput">sudo sh -c 'cat >log/run' <<'EOF'
-#!/bin/sh
-mkdir -p main
-chown git:git main
-exec chpst -u git:git svlogd -tt main
-EOF</span>
-/etc/sv/arvados-git-httpd$ <span class="userinput">sudo sh -c 'cat >run' <<'EOF'
-#!/bin/sh
-export ARVADOS_API_HOST=<b>uuid_prefix.your.domain</b>
-export GITOLITE_HTTP_HOME=/var/lib/arvados/git
-export GL_BYPASS_ACCESS_CHECKS=1
-export PATH="$PATH:/var/lib/arvados/git/bin"
-exec chpst -u git:git arvados-git-httpd -address=:9001 -git-command=/var/lib/arvados/git/gitolite/src/gitolite-shell -repo-root=<b>/var/lib/arvados/git</b>/repositories 2>&1
-EOF</span>
-/etc/sv/arvados-git-httpd$ <span class="userinput">sudo chmod +x run log/run</span>
-/etc/sv/arvados-git-httpd$ <span class="userinput">sudo ln -s "$(pwd)" /etc/service/</span>
+<pre><code>Client:
+  APIHost: <b>uuid_prefix.your.domain</b>
+  Insecure: false
+GitCommand: /var/lib/arvados/git/gitolite/src/gitolite-shell
+GitoliteHome: /var/lib/arvados/git
+Listen: :9001
+RepoRoot: /var/lib/arvados/git/repositories
 </code></pre>
 </notextile>
 
-If you are using a different daemon supervisor, or if you want to test the daemon in a terminal window, an equivalent shell command to run arvados-git-httpd is:
+Restart the systemd service to ensure the new configuration is used.
 
 <notextile>
-<pre><code>sudo -u git \
-  ARVADOS_API_HOST=<span class="userinput">uuid_prefix.your.domain</span> \
-  GITOLITE_HTTP_HOME=/var/lib/arvados/git \
-  GL_BYPASS_ACCESS_CHECKS=1 \
-  PATH="$PATH:/var/lib/arvados/git/bin" \
-  arvados-git-httpd -address=:9001 -git-command=/var/lib/arvados/git/gitolite/src/gitolite-shell -repo-root=/var/lib/arvados/git/repositories 2>&1
+<pre><code>~$ <span class="userinput">sudo systemctl restart arvados-git-httpd</span>
 </code></pre>
 </notextile>
 

commit 4c77384f1e639ee44c6c4011d8b07c711716d4d6
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Oct 13 11:02:18 2016 -0400

    10234: 10243: Use a GitoliteHome configuration entry instead of passing through gitolite env vars from the caller.

diff --git a/services/arv-git-httpd/git_handler.go b/services/arv-git-httpd/git_handler.go
index f0b98fa..f8e38e9 100644
--- a/services/arv-git-httpd/git_handler.go
+++ b/services/arv-git-httpd/git_handler.go
@@ -5,6 +5,7 @@ import (
 	"net"
 	"net/http"
 	"net/http/cgi"
+	"os"
 )
 
 // gitHandler is an http.Handler that invokes git-http-backend (or
@@ -16,21 +17,24 @@ type gitHandler struct {
 }
 
 func newGitHandler() http.Handler {
+	var env []string
+	path := os.Getenv("PATH")
+	if theConfig.GitoliteHome != "" {
+		env = append(env,
+			"GITOLITE_HTTP_HOME="+theConfig.GitoliteHome,
+			"GL_BYPASS_ACCESS_CHECKS=1")
+		path = path + ":" + theConfig.GitoliteHome + "/bin"
+	}
+	env = append(env,
+		"GIT_PROJECT_ROOT="+theConfig.RepoRoot,
+		"GIT_HTTP_EXPORT_ALL=",
+		"SERVER_ADDR="+theConfig.Listen,
+		"PATH="+path)
 	return &gitHandler{
 		Handler: cgi.Handler{
 			Path: theConfig.GitCommand,
 			Dir:  theConfig.RepoRoot,
-			Env: []string{
-				"GIT_PROJECT_ROOT=" + theConfig.RepoRoot,
-				"GIT_HTTP_EXPORT_ALL=",
-				"SERVER_ADDR=" + theConfig.Listen,
-			},
-			InheritEnv: []string{
-				"PATH",
-				// Needed if GitCommand is gitolite-shell:
-				"GITOLITE_HTTP_HOME",
-				"GL_BYPASS_ACCESS_CHECKS",
-			},
+			Env:  env,
 			Args: []string{"http-backend"},
 		},
 	}
diff --git a/services/arv-git-httpd/git_handler_test.go b/services/arv-git-httpd/git_handler_test.go
index 964810d..6b08eee 100644
--- a/services/arv-git-httpd/git_handler_test.go
+++ b/services/arv-git-httpd/git_handler_test.go
@@ -4,7 +4,6 @@ import (
 	"net/http"
 	"net/http/httptest"
 	"net/url"
-	"os"
 	"regexp"
 
 	check "gopkg.in/check.v1"
@@ -17,6 +16,7 @@ type GitHandlerSuite struct{}
 func (s *GitHandlerSuite) TestEnvVars(c *check.C) {
 	theConfig = defaultConfig()
 	theConfig.RepoRoot = "/"
+	theConfig.GitoliteHome = "/test/ghh"
 
 	u, err := url.Parse("git.zzzzz.arvadosapi.com/test")
 	c.Check(err, check.Equals, nil)
@@ -29,15 +29,14 @@ func (s *GitHandlerSuite) TestEnvVars(c *check.C) {
 	h := newGitHandler()
 	h.(*gitHandler).Path = "/bin/sh"
 	h.(*gitHandler).Args = []string{"-c", "printf 'Content-Type: text/plain\r\n\r\n'; env"}
-	os.Setenv("GITOLITE_HTTP_HOME", "/test/ghh")
-	os.Setenv("GL_BYPASS_ACCESS_CHECKS", "yesplease")
 
 	h.ServeHTTP(resp, req)
 
 	c.Check(resp.Code, check.Equals, http.StatusOK)
 	body := resp.Body.String()
+	c.Check(body, check.Matches, `(?ms).*^PATH=.*:/test/ghh/bin$.*`)
 	c.Check(body, check.Matches, `(?ms).*^GITOLITE_HTTP_HOME=/test/ghh$.*`)
-	c.Check(body, check.Matches, `(?ms).*^GL_BYPASS_ACCESS_CHECKS=yesplease$.*`)
+	c.Check(body, check.Matches, `(?ms).*^GL_BYPASS_ACCESS_CHECKS=1$.*`)
 	c.Check(body, check.Matches, `(?ms).*^REMOTE_HOST=::1$.*`)
 	c.Check(body, check.Matches, `(?ms).*^REMOTE_PORT=12345$.*`)
 	c.Check(body, check.Matches, `(?ms).*^SERVER_ADDR=`+regexp.QuoteMeta(theConfig.Listen)+`$.*`)
diff --git a/services/arv-git-httpd/gitolite_test.go b/services/arv-git-httpd/gitolite_test.go
index 74c2b8c..38ff230 100644
--- a/services/arv-git-httpd/gitolite_test.go
+++ b/services/arv-git-httpd/gitolite_test.go
@@ -48,9 +48,10 @@ func (s *GitoliteSuite) SetUpTest(c *check.C) {
 			APIHost:  arvadostest.APIHost(),
 			Insecure: true,
 		},
-		Listen:     ":0",
-		GitCommand: "/usr/share/gitolite3/gitolite-shell",
-		RepoRoot:   s.tmpRepoRoot,
+		Listen:       ":0",
+		GitCommand:   "/usr/share/gitolite3/gitolite-shell",
+		GitoliteHome: s.gitoliteHome,
+		RepoRoot:     s.tmpRepoRoot,
 	}
 	s.IntegrationSuite.SetUpTest(c)
 
@@ -58,9 +59,6 @@ func (s *GitoliteSuite) SetUpTest(c *check.C) {
 	// (*IntegrationTest)SetUpTest() -- see 2.2.4 at
 	// http://gitolite.com/gitolite/gitolite.html
 	runGitolite("gitolite", "setup")
-
-	os.Setenv("GITOLITE_HTTP_HOME", s.gitoliteHome)
-	os.Setenv("GL_BYPASS_ACCESS_CHECKS", "1")
 }
 
 func (s *GitoliteSuite) TearDownTest(c *check.C) {
diff --git a/services/arv-git-httpd/integration_test.go b/services/arv-git-httpd/integration_test.go
index 5e55eca..1d25259 100644
--- a/services/arv-git-httpd/integration_test.go
+++ b/services/arv-git-httpd/integration_test.go
@@ -112,6 +112,8 @@ func (s *IntegrationSuite) TearDownTest(c *check.C) {
 	s.tmpWorkdir = ""
 
 	s.Config = nil
+
+	theConfig = defaultConfig()
 }
 
 func (s *IntegrationSuite) RunGit(c *check.C, token, gitCmd, repo string, args ...string) error {
diff --git a/services/arv-git-httpd/main.go b/services/arv-git-httpd/main.go
index dacfec5..3bd7b3a 100644
--- a/services/arv-git-httpd/main.go
+++ b/services/arv-git-httpd/main.go
@@ -14,10 +14,11 @@ import (
 
 // Server configuration
 type Config struct {
-	Client     arvados.Client
-	Listen     string
-	GitCommand string
-	RepoRoot   string
+	Client       arvados.Client
+	Listen       string
+	GitCommand   string
+	RepoRoot     string
+	GitoliteHome string
 }
 
 var theConfig = defaultConfig()
@@ -39,6 +40,8 @@ func main() {
 		"Path to git or gitolite-shell executable. Each authenticated request will execute this program with a single argument, \"http-backend\"."+deprecated)
 	flag.StringVar(&theConfig.RepoRoot, "repo-root", theConfig.RepoRoot,
 		"Path to git repositories."+deprecated)
+	flag.StringVar(&theConfig.GitoliteHome, "gitolite-home", theConfig.GitoliteHome,
+		"Value for GITOLITE_HTTP_HOME environment variable. If not empty, GL_BYPASS_ACCESS_CHECKS=1 will also be set."+deprecated)
 
 	cfgPath := flag.String("config", defaultCfgPath, "Configuration file `path`.")
 	flag.Usage = usage
diff --git a/services/arv-git-httpd/usage.go b/services/arv-git-httpd/usage.go
index e355936..4eba36a 100644
--- a/services/arv-git-httpd/usage.go
+++ b/services/arv-git-httpd/usage.go
@@ -51,6 +51,14 @@ GitCommand:
     request will execute this program with the single argument
     "http-backend".
 
+GitoliteHome:
+
+    Path to Gitolite's home directory. If a non-empty path is given,
+    the CGI environment will be set up to support the use of
+    gitolite-shell as a GitCommand: for example, if GitoliteHome is
+    "/gh", then the CGI environment will have GITOLITE_HTTP_HOME=/gh,
+    PATH=$PATH:/gh/bin, and GL_BYPASS_ACCESS_CHECKS=1.
+
 Listen:
 
     Local port to listen on. Can be "address:port" or ":port", where
diff --git a/tools/arvbox/lib/arvbox/docker/service/arv-git-httpd/run-service b/tools/arvbox/lib/arvbox/docker/service/arv-git-httpd/run-service
index 518fe33..b6caa14 100755
--- a/tools/arvbox/lib/arvbox/docker/service/arv-git-httpd/run-service
+++ b/tools/arvbox/lib/arvbox/docker/service/arv-git-httpd/run-service
@@ -20,12 +20,11 @@ fi
 
 export ARVADOS_API_HOST=$localip:${services[api]}
 export ARVADOS_API_HOST_INSECURE=1
-export GITOLITE_HTTP_HOME=/var/lib/arvados/git
-export GL_BYPASS_ACCESS_CHECKS=1
 export PATH="$PATH:/var/lib/arvados/git/bin"
 cd ~git
 
 exec /usr/local/bin/arv-git-httpd \
-     -address=:${services[arv-git-httpd]} \
-     -git-command=/usr/share/gitolite3/gitolite-shell \
-     -repo-root=/var/lib/arvados/git/repositories
+    -address=:${services[arv-git-httpd]} \
+    -git-command=/usr/share/gitolite3/gitolite-shell \
+    -gitolite-home=/var/lib/arvados/git \
+    -repo-root=/var/lib/arvados/git/repositories

commit 59acf0718d442c05c64ba012b4f48478a4087b7b
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Oct 13 01:52:43 2016 -0400

    10234: Avoid trying to read real config file in test suite.

diff --git a/services/arv-git-httpd/git_handler_test.go b/services/arv-git-httpd/git_handler_test.go
index d87162d..964810d 100644
--- a/services/arv-git-httpd/git_handler_test.go
+++ b/services/arv-git-httpd/git_handler_test.go
@@ -15,6 +15,9 @@ var _ = check.Suite(&GitHandlerSuite{})
 type GitHandlerSuite struct{}
 
 func (s *GitHandlerSuite) TestEnvVars(c *check.C) {
+	theConfig = defaultConfig()
+	theConfig.RepoRoot = "/"
+
 	u, err := url.Parse("git.zzzzz.arvadosapi.com/test")
 	c.Check(err, check.Equals, nil)
 	resp := httptest.NewRecorder()
diff --git a/services/arv-git-httpd/main.go b/services/arv-git-httpd/main.go
index 4d6d8f6..dacfec5 100644
--- a/services/arv-git-httpd/main.go
+++ b/services/arv-git-httpd/main.go
@@ -30,7 +30,7 @@ func defaultConfig() *Config {
 	}
 }
 
-func init() {
+func main() {
 	const defaultCfgPath = "/etc/arvados/git-httpd/git-httpd.yml"
 	const deprecated = " (DEPRECATED -- use config file instead)"
 	flag.StringVar(&theConfig.Listen, "address", theConfig.Listen,
@@ -59,9 +59,7 @@ func init() {
 			log.Print("Current configuration:\n", string(j))
 		}
 	}
-}
 
-func main() {
 	srv := &server{}
 	if err := srv.Start(); err != nil {
 		log.Fatal(err)

commit 8baaf20400a376977b277ac7675ebfd0c4afe917
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Oct 13 01:52:09 2016 -0400

    10234: Use YAML for example config file.

diff --git a/services/arv-git-httpd/usage.go b/services/arv-git-httpd/usage.go
index dd0ae92..e355936 100644
--- a/services/arv-git-httpd/usage.go
+++ b/services/arv-git-httpd/usage.go
@@ -1,16 +1,17 @@
 package main
 
 import (
-	"encoding/json"
 	"flag"
 	"fmt"
 	"os"
+
+	"github.com/ghodss/yaml"
 )
 
 func usage() {
 	c := defaultConfig()
 	c.Client.APIHost = "zzzzz.arvadosapi.com:443"
-	exampleConfigFile, err := json.MarshalIndent(c, "    ", "  ")
+	exampleConfigFile, err := yaml.Marshal(c)
 	if err != nil {
 		panic(err)
 	}
@@ -28,7 +29,8 @@ Options:
 	flag.PrintDefaults()
 	fmt.Fprintf(os.Stderr, `
 Example config file:
-    %s
+
+%s
 
 Client.APIHost:
 
@@ -43,18 +45,18 @@ Client.Insecure:
     True if your Arvados API endpoint uses an unverifiable SSL/TLS
     certificate.
 
-Listen:
-
-    Local port to listen on. Can be "address:port" or ":port", where
-    "address" is a host IP address or name and "port" is a port number
-    or name.
-
 GitCommand:
 
     Path to git or gitolite-shell executable. Each authenticated
     request will execute this program with the single argument
     "http-backend".
 
+Listen:
+
+    Local port to listen on. Can be "address:port" or ":port", where
+    "address" is a host IP address or name and "port" is a port number
+    or name.
+
 RepoRoot:
 
     Path to git repositories.

commit c978ad2d773b1ffc1ec6608123e27b89e65c428e
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Oct 12 19:02:48 2016 -0400

    10234: Clean up program name (arvados-git-httpd) and config paths.

diff --git a/doc/install/install-arv-git-httpd.html.textile.liquid b/doc/install/install-arv-git-httpd.html.textile.liquid
index 5e373c3..3ec2382 100644
--- a/doc/install/install-arv-git-httpd.html.textile.liquid
+++ b/doc/install/install-arv-git-httpd.html.textile.liquid
@@ -239,10 +239,9 @@ Verify that @arvados-git-httpd@ and @git-http-backend@ can be run:
 
 <notextile>
 <pre><code>~$ <span class="userinput">arvados-git-httpd -h</span>
-Usage of arvados-git-httpd:
-  -address="0.0.0.0:80": Address to listen on, "host:port".
-  -git-command="/usr/bin/git": Path to git executable. Each authenticated request will execute this program with a single argument, "http-backend".
-  -repo-root="/path/to/cwd": Path to git repositories.
+[...]
+Usage: arvados-git-httpd [-config path/to/arvados/git-httpd.yml]
+[...]
 ~$ <span class="userinput">git http-backend</span>
 Status: 500 Internal Server Error
 Expires: Fri, 01 Jan 1980 00:00:00 GMT
diff --git a/services/arv-git-httpd/arvados-git-httpd.service b/services/arv-git-httpd/arvados-git-httpd.service
index f71c2ff..c41a5f3 100644
--- a/services/arv-git-httpd/arvados-git-httpd.service
+++ b/services/arv-git-httpd/arvados-git-httpd.service
@@ -2,7 +2,7 @@
 Description=Arvados git server
 Documentation=https://doc.arvados.org/
 After=network.target
-AssertPathExists=/etc/arvados/arvados-git-httpd/arvados-git-httpd.yml
+AssertPathExists=/etc/arvados/git-httpd/git-httpd.yml
 
 [Service]
 Type=notify
diff --git a/services/arv-git-httpd/usage.go b/services/arv-git-httpd/usage.go
index 11b3b9e..dd0ae92 100644
--- a/services/arv-git-httpd/usage.go
+++ b/services/arv-git-httpd/usage.go
@@ -16,11 +16,12 @@ func usage() {
 	}
 	fmt.Fprintf(os.Stderr, `
 
-arv-git-httpd provides authenticated access to Arvados-hosted git repositories.
+arvados-git-httpd provides authenticated access to Arvados-hosted git
+repositories.
 
 See http://doc.arvados.org/install/install-arv-git-httpd.html.
 
-Usage: arv-git-httpd [-config path/to/arv-git-httpd.yml]
+Usage: arvados-git-httpd [-config path/to/arvados/git-httpd.yml]
 
 Options:
 `)

commit 195b3f3cd0870195c546fec3e05522c0d1c89b72
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Oct 12 19:00:51 2016 -0400

    10234: Change default repo root from CWD to recommended path.

diff --git a/services/arv-git-httpd/main.go b/services/arv-git-httpd/main.go
index dd28136..4d6d8f6 100644
--- a/services/arv-git-httpd/main.go
+++ b/services/arv-git-httpd/main.go
@@ -23,14 +23,10 @@ type Config struct {
 var theConfig = defaultConfig()
 
 func defaultConfig() *Config {
-	cwd, err := os.Getwd()
-	if err != nil {
-		log.Fatalln("Getwd():", err)
-	}
 	return &Config{
 		Listen:     ":80",
 		GitCommand: "/usr/bin/git",
-		RepoRoot:   cwd,
+		RepoRoot:   "/var/lib/arvados/git/repositories",
 	}
 }
 
diff --git a/services/arv-git-httpd/usage.go b/services/arv-git-httpd/usage.go
index 666edc0..11b3b9e 100644
--- a/services/arv-git-httpd/usage.go
+++ b/services/arv-git-httpd/usage.go
@@ -56,7 +56,7 @@ GitCommand:
 
 RepoRoot:
 
-    Path to git repositories. Defaults to current working directory.
+    Path to git repositories.
 
 `, exampleConfigFile)
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list