Pass Artifact DB path to Dryad jobs 43/185943/12
authorPawel Wieczorek <p.wieczorek2@samsung.com>
Fri, 3 Aug 2018 17:41:51 +0000 (19:41 +0200)
committerPawel Wieczorek <p.wieczorek2@samsung.com>
Fri, 14 Sep 2018 14:15:03 +0000 (16:15 +0200)
After reverse SSHFS introduction for transferring files between Weles
and Dryad assigned for a given job, Artifact DB had to be available
under proper mountpoint on Dryad. This patch propagates path to Artifact
DB from command line flag through Dryad Job Manager to newly created
Dryad Jobs.

Change-Id: I36fdec4ec6f04b2e544a38218b0faeeec1dddaa2
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
cmd/weles-server/main.go
manager/dryad_job.go
manager/dryad_job_manager.go
manager/dryad_job_manager_test.go

index ede46d9..024dc07 100644 (file)
@@ -111,7 +111,7 @@ func main() {
                artifactDownloadQueueCap)
        exitOnErr("failed to initialize ArtifactManager ", err)
        bor := client.NewBorutaClient(borutaAddress)
-       djm := manager.NewDryadJobManager()
+       djm := manager.NewDryadJobManager(artifactDBLocation)
        jm := controller.NewJobManager(am, &yap, bor, borutaRefreshPeriod, djm)
 
        api := operations.NewWelesAPI(swaggerSpec)
index 97dcdac..61c23ee 100644 (file)
@@ -55,10 +55,9 @@ func newDryadJobWithCancel(job weles.JobID, changes chan<- weles.DryadJobStatusC
 // newDryadJob creates an instance of dryadJob and starts a goroutine
 // executing phases of given job implemented by provider of DryadJobRunner interface.
 func newDryadJob(job weles.JobID, rusalka weles.Dryad, conf weles.Config,
-       changes chan<- weles.DryadJobStatusChange) *dryadJob {
+       changes chan<- weles.DryadJobStatusChange, artifactDBPath string) *dryadJob {
 
-       // FIXME: It should use the proper path to the artifactory.
-       session := dryad.NewSessionProvider(rusalka, "")
+       session := dryad.NewSessionProvider(rusalka, artifactDBPath)
        device := dryad.NewDeviceCommunicationProvider(session)
 
        ctx, cancel := context.WithCancel(context.Background())
index 4dacf21..a530cd3 100644 (file)
@@ -27,15 +27,17 @@ import (
 // DryadJobs implements DryadJobManager interface.
 type DryadJobs struct {
        weles.DryadJobManager
-       jobs      map[weles.JobID]*dryadJob
-       jobsMutex *sync.RWMutex
+       jobs           map[weles.JobID]*dryadJob
+       jobsMutex      *sync.RWMutex
+       artifactDBPath string
 }
 
 // NewDryadJobManager returns DryadJobManager interface of a new instance of DryadJobs.
-func NewDryadJobManager() weles.DryadJobManager {
+func NewDryadJobManager(artifactDBPath string) weles.DryadJobManager {
        return &DryadJobs{
-               jobs:      make(map[weles.JobID]*dryadJob),
-               jobsMutex: new(sync.RWMutex),
+               jobs:           make(map[weles.JobID]*dryadJob),
+               jobsMutex:      new(sync.RWMutex),
+               artifactDBPath: artifactDBPath,
        }
 }
 
@@ -50,7 +52,7 @@ func (d *DryadJobs) Create(job weles.JobID, rusalka weles.Dryad, conf weles.Conf
        d.jobsMutex.Lock()
        defer d.jobsMutex.Unlock()
        // FIXME(amistewicz): dryadJobs should not be stored indefinitely.
-       d.jobs[job] = newDryadJob(job, rusalka, conf, changes)
+       d.jobs[job] = newDryadJob(job, rusalka, conf, changes, d.artifactDBPath)
        return nil
 }
 
index df0f635..d96473c 100644 (file)
@@ -29,9 +29,10 @@ import (
 var _ = Describe("DryadJobManager", func() {
        var djm DryadJobManager
        jobID := JobID(666)
+       artifactDBPath := "/artifact/db/path"
 
        BeforeEach(func() {
-               djm = NewDryadJobManager()
+               djm = NewDryadJobManager(artifactDBPath)
        })
 
        create := func() {