SigChan chan os.Signal
ArvMountExit chan error
finalState string
- trashLifetime time.Duration
statLogger io.WriteCloser
statReporter *crunchstat.Reporter
if mnt.Writable {
return fmt.Errorf("Can never write to a collection specified by portable data hash")
}
+ idx := strings.Index(mnt.PortableDataHash, "/")
+ if idx > 0 {
+ mnt.Path = path.Clean(mnt.PortableDataHash[idx:])
+ mnt.PortableDataHash = mnt.PortableDataHash[0:idx]
+ runner.Container.Mounts[bind] = mnt
+ }
src = fmt.Sprintf("%s/by_id/%s", runner.ArvMountPoint, mnt.PortableDataHash)
+ if mnt.Path != "" && mnt.Path != "." {
+ if strings.HasPrefix(mnt.Path, "./") {
+ mnt.Path = mnt.Path[2:]
+ } else if strings.HasPrefix(mnt.Path, "/") {
+ mnt.Path = mnt.Path[1:]
+ }
+ src += "/" + mnt.Path
+ }
} else {
src = fmt.Sprintf("%s/tmp%d", runner.ArvMountPoint, tmpcount)
arvMountCmd = append(arvMountCmd, "--mount-tmp")
continue
}
- if strings.HasPrefix(bindSuffix, "/") == false {
- bindSuffix = "/" + bindSuffix
- }
-
if mnt.ExcludeFromOutput == true {
continue
}
- idx := strings.Index(mnt.PortableDataHash, "/")
- if idx > 0 {
- mnt.Path = mnt.PortableDataHash[idx:]
- mnt.PortableDataHash = mnt.PortableDataHash[0:idx]
- }
-
// append to manifest_text
m, err := runner.getCollectionManifestForPath(mnt, bindSuffix)
if err != nil {
// Save output
var response arvados.Collection
- manifestText := manifest.Manifest{Text: manifestText}.NormalizedText()
+ manifest := manifest.Manifest{Text: manifestText}
+ manifestText = manifest.Extract(".", ".").Text
err = runner.ArvClient.Create("collections",
arvadosclient.Dict{
"collection": arvadosclient.Dict{
- "trash_at": time.Now().Add(runner.trashLifetime).Format(time.RFC3339),
+ "is_trashed": true,
"name": "output for " + runner.Container.UUID,
"manifest_text": manifestText}},
&response)
return "", nil
}
- manifest := manifest.Manifest{Text: collection.ManifestText}
- manifestText := manifest.ManifestTextForPath(mnt.Path, bindSuffix)
- return manifestText, nil
-}
-
-func (runner *ContainerRunner) loadDiscoveryVars() {
- tl, err := runner.ArvClient.Discovery("defaultTrashLifetime")
- if err != nil {
- log.Fatalf("getting defaultTrashLifetime from discovery document: %s", err)
+ mft := manifest.Manifest{Text: collection.ManifestText}
+ extracted := mft.Extract(mnt.Path, bindSuffix)
+ if extracted.Err != nil {
+ return "", fmt.Errorf("Error parsing manifest for %v: %v", mnt.PortableDataHash, extracted.Err.Error())
}
- runner.trashLifetime = time.Duration(tl.(float64)) * time.Second
+ return extracted.Text, nil
}
func (runner *ContainerRunner) CleanupDirs() {
err = runner.ArvClient.Create("collections",
arvadosclient.Dict{
"collection": arvadosclient.Dict{
- "trash_at": time.Now().Add(runner.trashLifetime).Format(time.RFC3339),
+ "is_trashed": true,
"name": "logs for " + runner.Container.UUID,
"manifest_text": mt}},
&response)
cr.Container.UUID = containerUUID
cr.CrunchLog = NewThrottledLogger(cr.NewLogWriter("crunch-run"))
cr.CrunchLog.Immediate = log.New(os.Stderr, containerUUID+" ", 0)
- cr.loadDiscoveryVars()
return cr
}