Skip to content

Commit

Permalink
Remove re-indexing code (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkw31 authored Dec 12, 2024
1 parent ab2c1a5 commit 8c1597d
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 1,442 deletions.
19 changes: 0 additions & 19 deletions build/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ type Builder struct {
mu sync.Mutex
runningEnvironments map[string]bool

postBuildMu sync.RWMutex
postBuild func()

statusMu sync.RWMutex
statuses map[string]*Status

Expand Down Expand Up @@ -216,14 +213,6 @@ type templateVars struct {
Packages []core.Package
}

// SetPostBuildCallback causes the passed callback to be called after the
// spack-related parts of a build have completed.
func (b *Builder) SetPostBuildCallback(cb func()) {
b.postBuildMu.Lock()
defer b.postBuildMu.Unlock()
b.postBuild = cb
}

// Status returns the status of all known builds.
func (b *Builder) Status() []Status {
b.statusMu.RLock()
Expand Down Expand Up @@ -391,14 +380,6 @@ func (b *Builder) asyncBuild(def *Definition, wrInput, s3Path, singDef string) e
status.BuildDone = &buildDone
b.statusMu.Unlock()

b.postBuildMu.RLock()
if b.postBuild != nil {
// if spack ran at all, it might've pushed things to the cache, even if
// it didn't succeed or if later steps don't run
go b.postBuild()
}
b.postBuildMu.RUnlock()

if err != nil || wrStatus != wr.WRJobStatusComplete {
b.addLogToRepo(s3Path, def.FullEnvironmentPath())

Expand Down
33 changes: 1 addition & 32 deletions build/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"os/exec"
"path/filepath"
"strings"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -97,21 +96,6 @@ func TestBuilder(t *testing.T) {
builder, err := New(&conf, ms3, mwr)
So(err, ShouldBeNil)

var bcbCount atomic.Uint64

bcbWait := 0 * time.Millisecond

bcb := func() {
<-time.After(bcbWait)
bcbCount.Add(1)

if bcbWait > 0 {
slog.Error("bcb finished")
}
}

builder.SetPostBuildCallback(bcb)

def := getExampleDefinition()

Convey("You can generate a singularity .def", func() {
Expand Down Expand Up @@ -238,8 +222,6 @@ Stage: final
err := builder.Build(def)
So(err, ShouldBeNil)

So(bcbCount.Load(), ShouldEqual, 0)

So(ms3.Def, ShouldEqual, filepath.Join(def.getS3Path(), "singularity.def"))
So(ms3.Data, ShouldContainSubstring, "specs:\n - [email protected] arch=None-None-x86_64_v4\n"+
" - r-seurat@4 arch=None-None-x86_64_v4\n - [email protected] arch=None-None-x86_64_v4\n view")
Expand Down Expand Up @@ -356,21 +338,16 @@ packages:

So(ms3.SoftpackYML, ShouldEqual, expectedSoftpackYaml)
So(ms3.Readme, ShouldContainSubstring, expectedReadmeContent)

So(bcbCount.Load(), ShouldEqual, 1)
})

Convey("Build returns an error if the upload fails", func() {
ms3.Fail = true
err := builder.Build(def)
So(err, ShouldNotBeNil)

So(bcbCount.Load(), ShouldEqual, 0)
})

Convey("Build logs an error if the run fails", func() {
mwr.Fail = true
bcbWait = 500 * time.Millisecond

err := builder.Build(def)
So(err, ShouldBeNil)
Expand All @@ -384,21 +361,15 @@ packages:
})
So(ok, ShouldBeTrue)

<-time.After(bcbWait)

logLines := strings.Split(logWriter.String(), "\n")
So(len(logLines), ShouldEqual, 3)
So(len(logLines), ShouldEqual, 2)

So(logLines[0], ShouldContainSubstring,
"msg=\"Async part of build failed\" err=\""+ErrBuildFailed+"\" s3Path=some_path/"+def.getS3Path())

So(logLines[1], ShouldContainSubstring, "finished")

data, ok := mc.GetFile(filepath.Join(def.getRepoPath(), core.BuilderOut))
So(ok, ShouldBeTrue)
So(data, ShouldContainSubstring, "output")

So(bcbCount.Load(), ShouldEqual, 1)
})

Convey("You can't run the same build simultaneously", func() {
Expand Down Expand Up @@ -477,8 +448,6 @@ packages:
expectedLog = "\"Async part of build failed\" err=\"an error\\n\""

So(logWriter.String(), ShouldContainSubstring, expectedLog)

So(bcbCount.Load(), ShouldEqual, 2)
})
})
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/spf13/cobra"
"github.com/wtsi-hgi/go-softpack-builder/build"
"github.com/wtsi-hgi/go-softpack-builder/config"
"github.com/wtsi-hgi/go-softpack-builder/reindex"
"github.com/wtsi-hgi/go-softpack-builder/server"
)

Expand Down Expand Up @@ -143,10 +142,6 @@ past reindexHours, and only if a reindex is not still ongoing.
die("could not create a builder: %s", err)
}

r := reindex.New(conf)

b.SetPostBuildCallback(r.Reindex)

s := server.New(b, conf)
defer s.Stop()

Expand Down
12 changes: 3 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ type Config struct {
} `yaml:"module"`
CustomSpackRepo string `yaml:"customSpackRepo"`
Spack struct {
BuildImage string `yaml:"buildImage"`
FinalImage string `yaml:"finalImage"`
ProcessorTarget string `yaml:"processorTarget"`
ReindexHours float64 `yaml:"reindexHours"`
Path string `yaml:"path"`
BuildImage string `yaml:"buildImage"`
FinalImage string `yaml:"finalImage"`
ProcessorTarget string `yaml:"processorTarget"`
} `yaml:"spack"`
CoreURL string `yaml:"coreURL"`
ListenURL string `yaml:"listenURL"`
Expand Down Expand Up @@ -106,9 +104,5 @@ func Parse(r io.Reader) (*Config, error) {
}
}

if c.Spack.Path == "" {
c.Spack.Path = "spack"
}

return c, nil
}
2 changes: 0 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func TestConfig(t *testing.T) {
So(config.Spack.BuildImage, ShouldEqual, "spack/ubuntu-jammy:latest")
So(config.Spack.FinalImage, ShouldEqual, "ubuntu:22.04")
So(config.Spack.ProcessorTarget, ShouldEqual, "x86_64_v4")
So(config.Spack.ReindexHours, ShouldEqual, 24.0)
So(config.Spack.Path, ShouldEqual, "/usr/bin/spack")
So(config.CoreURL, ShouldEqual, "http://x.y.z:9837/softpack")
So(config.ListenURL, ShouldEqual, "localhost:2456")
})
Expand Down
106 changes: 0 additions & 106 deletions debounce/debounce.go

This file was deleted.

84 changes: 0 additions & 84 deletions debounce/debounce_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/tests/testdata/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ spack:
buildImage: "spack/ubuntu-jammy:latest"
finalImage: "ubuntu:22.04"
processorTarget: "x86_64_v4"
reindexHours: 24
path: "/usr/bin/spack"

coreURL: "http://x.y.z:9837/softpack"
listenURL: "localhost:2456"
Loading

0 comments on commit 8c1597d

Please sign in to comment.