17296: Merge branch 'master'
authorTom Clegg <tom@curii.com>
Tue, 25 May 2021 21:05:20 +0000 (17:05 -0400)
committerTom Clegg <tom@curii.com>
Tue, 25 May 2021 21:05:20 +0000 (17:05 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

1  2 
lib/config/config.default.yml
lib/config/export.go
lib/config/generated_config.go
lib/crunchrun/copier.go
lib/crunchrun/copier_test.go
sdk/go/arvados/config.go

index c94b4ee9a1da279e3237a7c152ed215a6257fc93,8ad2cb53fca8d20fce9a091f5a6b781e7e8c9835..e24084ca07382bbab44fbdba0b19f4f1ef9e7208
@@@ -538,7 -538,7 +538,7 @@@ Clusters
          UUIDTTL: 5s
  
          # Block cache entries. Each block consumes up to 64 MiB RAM.
-         MaxBlockEntries: 4
+         MaxBlockEntries: 20
  
          # Collection cache entries.
          MaxCollectionEntries: 1000
          AuthenticationRequestParameters:
            SAMPLE: ""
  
+         # Accept an OIDC access token as an API token if the OIDC
+         # provider's UserInfo endpoint accepts it.
+         #
+         # AcceptAccessTokenScope should also be used when enabling
+         # this feature.
+         AcceptAccessToken: false
+         # Before accepting an OIDC access token as an API token, first
+         # check that it is a JWT whose "scope" value includes this
+         # value. Example: "https://zzzzz.example.com/" (your Arvados
+         # API endpoint).
+         #
+         # If this value is empty and AcceptAccessToken is true, all
+         # access tokens will be accepted regardless of scope,
+         # including non-JWT tokens. This is not recommended.
+         AcceptAccessTokenScope: ""
        PAM:
          # (Experimental) Use PAM to authenticate users.
          Enable: false
        # Minimum time between two attempts to run the same container
        MinRetryPeriod: 0s
  
 +      # Container runtime: "docker" (default) or "singularity" (experimental)
 +      RuntimeEngine: docker
 +
        Logging:
          # When you run the db:delete_old_container_logs task, it will find
          # containers that have been finished for at least this many seconds,
diff --combined lib/config/export.go
index 9163421becb28c22539ffd2f41eb96bfb914d884,890d4ce4711eb4f06a00ada8e9e5adc63b2d7999..bd88c5d013af8df2546116e65a013d397ced4e6c
@@@ -122,7 -122,6 +122,7 @@@ var whitelist = map[string]bool
        "Containers.MaxRetryAttempts":                         true,
        "Containers.MinRetryPeriod":                           true,
        "Containers.ReserveExtraRAM":                          true,
 +      "Containers.RuntimeEngine":                            true,
        "Containers.ShellAccess":                              true,
        "Containers.ShellAccess.Admin":                        true,
        "Containers.ShellAccess.User":                         true,
        "Login.LDAP.UsernameAttribute":                        false,
        "Login.LoginCluster":                                  true,
        "Login.OpenIDConnect":                                 true,
+       "Login.OpenIDConnect.AcceptAccessToken":               false,
+       "Login.OpenIDConnect.AcceptAccessTokenScope":          false,
        "Login.OpenIDConnect.AuthenticationRequestParameters": false,
        "Login.OpenIDConnect.ClientID":                        false,
        "Login.OpenIDConnect.ClientSecret":                    false,
index e344d226652038275a2231b21ba91e2e1984416e,9e59f8c9238606ed8b0926ad2841ce66d20e3565..9f4bf011b8dbf02cf19ec4c61cc919072baf1d08
@@@ -544,7 -544,7 +544,7 @@@ Clusters
          UUIDTTL: 5s
  
          # Block cache entries. Each block consumes up to 64 MiB RAM.
-         MaxBlockEntries: 4
+         MaxBlockEntries: 20
  
          # Collection cache entries.
          MaxCollectionEntries: 1000
          AuthenticationRequestParameters:
            SAMPLE: ""
  
+         # Accept an OIDC access token as an API token if the OIDC
+         # provider's UserInfo endpoint accepts it.
+         #
+         # AcceptAccessTokenScope should also be used when enabling
+         # this feature.
+         AcceptAccessToken: false
+         # Before accepting an OIDC access token as an API token, first
+         # check that it is a JWT whose "scope" value includes this
+         # value. Example: "https://zzzzz.example.com/" (your Arvados
+         # API endpoint).
+         #
+         # If this value is empty and AcceptAccessToken is true, all
+         # access tokens will be accepted regardless of scope,
+         # including non-JWT tokens. This is not recommended.
+         AcceptAccessTokenScope: ""
        PAM:
          # (Experimental) Use PAM to authenticate users.
          Enable: false
        # Minimum time between two attempts to run the same container
        MinRetryPeriod: 0s
  
 +      # Container runtime: "docker" (default) or "singularity" (experimental)
 +      RuntimeEngine: docker
 +
        Logging:
          # When you run the db:delete_old_container_logs task, it will find
          # containers that have been finished for at least this many seconds,
diff --combined lib/crunchrun/copier.go
index 78e5f4faa8074576da0b9c5b6046e5bce3a90c80,132101028ea4d6d5b6b8a76df5238d7ceb0effb7..72c714dfa4ef47bbe4d60adff4693edd97e7b7cb
@@@ -55,7 -55,7 +55,7 @@@ type copier struct 
        keepClient    IKeepClient
        hostOutputDir string
        ctrOutputDir  string
 -      binds         []string
 +      bindmounts    map[string]bindmount
        mounts        map[string]arvados.Mount
        secretMounts  map[string]arvados.Mount
        logger        printfer
@@@ -331,8 -331,8 +331,8 @@@ func (cp *copier) walkHostFS(dest, src 
                })
                return nil
        }
-       return fmt.Errorf("Unsupported file type (mode %o) in output dir: %q", fi.Mode(), src)
+       cp.logger.Printf("Skipping unsupported file type (mode %o) in output dir: %q", fi.Mode(), src)
+       return nil
  }
  
  // Return the host path that was mounted at the given path in the
@@@ -341,8 -341,11 +341,8 @@@ func (cp *copier) hostRoot(ctrRoot stri
        if ctrRoot == cp.ctrOutputDir {
                return cp.hostOutputDir, nil
        }
 -      for _, bind := range cp.binds {
 -              tokens := strings.Split(bind, ":")
 -              if len(tokens) >= 2 && tokens[1] == ctrRoot {
 -                      return tokens[0], nil
 -              }
 +      if mnt, ok := cp.bindmounts[ctrRoot]; ok {
 +              return mnt.HostPath, nil
        }
        return "", fmt.Errorf("not bind-mounted: %q", ctrRoot)
  }
index 9135bcaa1d87808ba64f54594aa6e902b0870c19,07fd795efe45a75c6390520a88de39e479ca1f72..5e92490163f6e34bc935eae42d2002fdea74436f
@@@ -5,27 -5,31 +5,31 @@@
  package crunchrun
  
  import (
+       "bytes"
        "io"
        "io/ioutil"
        "os"
+       "syscall"
  
        "git.arvados.org/arvados.git/sdk/go/arvados"
        "git.arvados.org/arvados.git/sdk/go/arvadosclient"
        "git.arvados.org/arvados.git/sdk/go/arvadostest"
+       "github.com/sirupsen/logrus"
        check "gopkg.in/check.v1"
  )
  
  var _ = check.Suite(&copierSuite{})
  
  type copierSuite struct {
-       cp copier
+       cp  copier
+       log bytes.Buffer
  }
  
  func (s *copierSuite) SetUpTest(c *check.C) {
-       tmpdir, err := ioutil.TempDir("", "crunch-run.test.")
-       c.Assert(err, check.IsNil)
+       tmpdir := c.MkDir()
        api, err := arvadosclient.MakeArvadosClient()
        c.Assert(err, check.IsNil)
+       s.log = bytes.Buffer{}
        s.cp = copier{
                client:        arvados.NewClientFromEnv(),
                arvClient:     api,
                secretMounts: map[string]arvados.Mount{
                        "/secret_text": {Kind: "text", Content: "xyzzy"},
                },
+               logger: &logrus.Logger{Out: &s.log, Formatter: &logrus.TextFormatter{}, Level: logrus.InfoLevel},
        }
  }
  
- func (s *copierSuite) TearDownTest(c *check.C) {
-       os.RemoveAll(s.cp.hostOutputDir)
- }
  func (s *copierSuite) TestEmptyOutput(c *check.C) {
        err := s.cp.walkMount("", s.cp.ctrOutputDir, 10, true)
        c.Check(err, check.IsNil)
@@@ -59,6 -60,8 +60,8 @@@ func (s *copierSuite) TestRegularFilesA
        _, err = io.WriteString(f, "foo")
        c.Assert(err, check.IsNil)
        c.Assert(f.Close(), check.IsNil)
+       err = syscall.Mkfifo(s.cp.hostOutputDir+"/dir1/fifo", 0644)
+       c.Assert(err, check.IsNil)
  
        err = s.cp.walkMount("", s.cp.ctrOutputDir, 10, true)
        c.Check(err, check.IsNil)
@@@ -67,6 -70,7 +70,7 @@@
                {src: os.DevNull, dst: "/dir1/dir2/dir3/.keep"},
                {src: s.cp.hostOutputDir + "/dir1/foo", dst: "/dir1/foo", size: 3},
        })
+       c.Check(s.log.String(), check.Matches, `.* msg="Skipping unsupported file type \(mode 200000644\) in output dir: \\"/ctr/outdir/dir1/fifo\\""\n`)
  }
  
  func (s *copierSuite) TestSymlinkCycle(c *check.C) {
@@@ -128,9 -132,7 +132,9 @@@ func (s *copierSuite) TestSymlinkToMoun
                PortableDataHash: arvadostest.FooCollectionPDH,
                Writable:         true,
        }
 -      s.cp.binds = append(s.cp.binds, bindtmp+":/mnt-w")
 +      s.cp.bindmounts = map[string]bindmount{
 +              "/mnt-w": bindmount{HostPath: bindtmp, ReadOnly: false},
 +      }
  
        c.Assert(os.Symlink("../../mnt", s.cp.hostOutputDir+"/l_dir"), check.IsNil)
        c.Assert(os.Symlink("/mnt/foo", s.cp.hostOutputDir+"/l_file"), check.IsNil)
diff --combined sdk/go/arvados/config.go
index 2ff43232185068683d603bb49768068c818602a3,65e2ff5381e84e9ab4259e0b54b3d033e20d9508..b1ee6e9b992f4446ec1f0f826c22e9bdb244704b
@@@ -167,6 -167,8 +167,8 @@@ type Cluster struct 
                        EmailClaim                      string
                        EmailVerifiedClaim              string
                        UsernameClaim                   string
+                       AcceptAccessToken               bool
+                       AcceptAccessTokenScope          string
                        AuthenticationRequestParameters map[string]string
                }
                PAM struct {
@@@ -414,7 -416,6 +416,7 @@@ type ContainersConfig struct 
        StaleLockTimeout            Duration
        SupportedDockerImageFormats StringSet
        UsePreemptibleInstances     bool
 +      RuntimeEngine               string
  
        JobsAPI struct {
                Enable         string