From 0de3f63a136cab2227204eb16da9ea0eb9b68349 Mon Sep 17 00:00:00 2001 From: Eric Biagiotti Date: Fri, 16 Aug 2019 11:40:14 -0400 Subject: [PATCH] 14712: Adds arv-git-httpd to cluster config loading Also removes assert path from service file Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti 14712: Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti --- lib/config/config.default.yml | 11 +++++ lib/config/deprecated.go | 41 +++++++++++++++++++ lib/config/generated_config.go | 11 +++++ lib/config/load.go | 6 +++ sdk/go/arvados/config.go | 2 + .../arv-git-httpd/arvados-git-httpd.service | 1 - 6 files changed, 71 insertions(+), 1 deletion(-) diff --git a/lib/config/config.default.yml b/lib/config/config.default.yml index 163cd87ec5..3e098a0029 100644 --- a/lib/config/config.default.yml +++ b/lib/config/config.default.yml @@ -419,6 +419,17 @@ Clusters: ProviderAppID: "" Git: + # Path to git or gitolite-shell executable. Each authenticated + # request will execute this program with the single argument http-backend" + GitCommand: /usr/bin/git + + # 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. + GitoliteHome: "" + # Git repositories must be readable by api server, or you won't be # able to submit crunch jobs. To pass the test suites, put a clone # of the arvados tree in {git_repositories_dir}/arvados.git or diff --git a/lib/config/deprecated.go b/lib/config/deprecated.go index df872111db..9eb8c40c18 100644 --- a/lib/config/deprecated.go +++ b/lib/config/deprecated.go @@ -468,3 +468,44 @@ func (ldr *Loader) loadOldKeepWebConfig(cfg *arvados.Config) error { cfg.Clusters[cluster.ClusterID] = *cluster return nil } + +const defaultGitHttpdConfigPath = "/etc/arvados/git-httpd/git-httpd.yml" + +type oldGitHttpdConfig struct { + Client *arvados.Client + Listen string + GitCommand string + GitoliteHome string + RepoRoot string + ManagementToken string +} + +func (ldr *Loader) loadOldGitHttpdConfig(cfg *arvados.Config) error { + if ldr.GitHttpdPath == "" { + return nil + } + var oc oldGitHttpdConfig + err := ldr.loadOldConfigHelper("arv-git-httpd", ldr.GitHttpdPath, &oc) + if os.IsNotExist(err) && ldr.GitHttpdPath == defaultGitHttpdConfigPath { + return nil + } else if err != nil { + return err + } + + cluster, err := cfg.GetCluster("") + if err != nil { + return err + } + + loadOldClientConfig(cluster, oc.Client) + + cluster.Services.GitHTTP.InternalURLs[arvados.URL{Host: oc.Listen}] = arvados.ServiceInstance{} + cluster.TLS.Insecure = oc.Client.Insecure + cluster.ManagementToken = oc.ManagementToken + cluster.Git.GitCommand = oc.GitCommand + cluster.Git.GitoliteHome = oc.GitoliteHome + cluster.Git.Repositories = oc.RepoRoot + + cfg.Clusters[cluster.ClusterID] = *cluster + return nil +} diff --git a/lib/config/generated_config.go b/lib/config/generated_config.go index 1eae24d84e..d06ed2602a 100644 --- a/lib/config/generated_config.go +++ b/lib/config/generated_config.go @@ -425,6 +425,17 @@ Clusters: ProviderAppID: "" Git: + # Path to git or gitolite-shell executable. Each authenticated + # request will execute this program with the single argument http-backend" + GitCommand: /usr/bin/git + + # 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. + GitoliteHome: "" + # Git repositories must be readable by api server, or you won't be # able to submit crunch jobs. To pass the test suites, put a clone # of the arvados tree in {git_repositories_dir}/arvados.git or diff --git a/lib/config/load.go b/lib/config/load.go index 84de9b60e9..7e48493939 100644 --- a/lib/config/load.go +++ b/lib/config/load.go @@ -35,6 +35,7 @@ type Loader struct { CrunchDispatchSlurmPath string WebsocketPath string KeepproxyPath string + GitHttpdPath string configdata []byte } @@ -66,6 +67,7 @@ func (ldr *Loader) SetupFlags(flagset *flag.FlagSet) { flagset.StringVar(&ldr.CrunchDispatchSlurmPath, "legacy-crunch-dispatch-slurm-config", defaultCrunchDispatchSlurmConfigPath, "Legacy crunch-dispatch-slurm configuration `file`") flagset.StringVar(&ldr.WebsocketPath, "legacy-ws-config", defaultWebsocketConfigPath, "Legacy arvados-ws configuration `file`") flagset.StringVar(&ldr.KeepproxyPath, "legacy-keepproxy-config", defaultKeepproxyConfigPath, "Legacy keepproxy configuration `file`") + flagset.StringVar(&ldr.GitHttpdPath, "legacy-git-httpd-config", defaultGitHttpdConfigPath, "Legacy arv-git-httpd configuration `file`") flagset.BoolVar(&ldr.SkipLegacy, "skip-legacy", false, "Don't load legacy config files") } @@ -143,6 +145,9 @@ func (ldr *Loader) MungeLegacyConfigArgs(lgr logrus.FieldLogger, args []string, if legacyConfigArg != "-legacy-keepproxy-config" { ldr.KeepproxyPath = "" } + if legacyConfigArg != "-legacy-git-httpd-config" { + ldr.GitHttpdPath = "" + } return munged } @@ -244,6 +249,7 @@ func (ldr *Loader) Load() (*arvados.Config, error) { ldr.loadOldCrunchDispatchSlurmConfig(&cfg), ldr.loadOldWebsocketConfig(&cfg), ldr.loadOldKeepproxyConfig(&cfg), + ldr.loadOldGitHttpdConfig(&cfg), } { if err != nil { return nil, err diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go index 93f52f3c80..5a18972f52 100644 --- a/sdk/go/arvados/config.go +++ b/sdk/go/arvados/config.go @@ -114,6 +114,8 @@ type Cluster struct { WebDAVCache WebDAVCacheConfig } Git struct { + GitCommand string + GitoliteHome string Repositories string } Login struct { diff --git a/services/arv-git-httpd/arvados-git-httpd.service b/services/arv-git-httpd/arvados-git-httpd.service index 6f8cca856b..7ac160eea3 100644 --- a/services/arv-git-httpd/arvados-git-httpd.service +++ b/services/arv-git-httpd/arvados-git-httpd.service @@ -6,7 +6,6 @@ Description=Arvados git server Documentation=https://doc.arvados.org/ After=network.target -AssertPathExists=/etc/arvados/git-httpd/git-httpd.yml # systemd==229 (ubuntu:xenial) obeys StartLimitInterval in the [Unit] section StartLimitInterval=0 -- 2.30.2