diff --git a/orderer/kahn_lock_orderer.go b/orderer/kahn_lock_orderer.go index 144b164e1..4c470c02e 100644 --- a/orderer/kahn_lock_orderer.go +++ b/orderer/kahn_lock_orderer.go @@ -3,7 +3,6 @@ package orderer import ( "errors" - "fmt" "github.com/cloudfoundry-incubator/bosh-backup-and-restore/orchestrator" ) @@ -50,10 +49,7 @@ func findLockingDependencies(jobs []orchestrator.Job, orderConstraintSpecifier o jobSpecifiersThatShouldBeLockedAfter := orderConstraintSpecifier.Before(job) for _, jobSpecifierThatShouldBeLockedAfter := range jobSpecifiersThatShouldBeLockedAfter { - jobsThatShouldBeLockedAfter, err := findJobsBySpecifier(jobs, jobSpecifierThatShouldBeLockedAfter) - if err != nil { - return nil, err - } + jobsThatShouldBeLockedAfter := findJobsBySpecifier(jobs, jobSpecifierThatShouldBeLockedAfter) for _, afterJob := range jobsThatShouldBeLockedAfter { lockingDependencies = append(lockingDependencies, lockingDependency{Before: job, After: afterJob}) @@ -64,7 +60,7 @@ func findLockingDependencies(jobs []orchestrator.Job, orderConstraintSpecifier o return lockingDependencies, nil } -func findJobsBySpecifier(jobs []orchestrator.Job, specifier orchestrator.JobSpecifier) ([]orchestrator.Job, error) { +func findJobsBySpecifier(jobs []orchestrator.Job, specifier orchestrator.JobSpecifier) []orchestrator.Job { var foundJobs []orchestrator.Job for _, job := range jobs { if job.Name() == specifier.Name && job.Release() == specifier.Release { @@ -72,11 +68,7 @@ func findJobsBySpecifier(jobs []orchestrator.Job, specifier orchestrator.JobSpec } } - if len(foundJobs) == 0 { - return nil, fmt.Errorf("could not find locking dependency %s/%s", specifier.Release, specifier.Name) - } - - return foundJobs, nil + return foundJobs } func orderJobsUsingTheKahnAlgorithm(jobs []orchestrator.Job, lockingDependencies []lockingDependency) ([][]orchestrator.Job, error) { diff --git a/orderer/kahn_lock_orderer_test.go b/orderer/kahn_lock_orderer_test.go index e06425667..65bd1302c 100644 --- a/orderer/kahn_lock_orderer_test.go +++ b/orderer/kahn_lock_orderer_test.go @@ -52,18 +52,6 @@ var _ = Describe("KahnLockOrderer", func() { } }), - Entry("one job, dependency on non-existent job", func() lockingTestCase { - var job = fakeJob("test", "releasetest") - - orderConstraintSpecifier := NewFakeOrderConstraintSpecifier() - - return lockingTestCase{ - inputJobs: []Job{job}, - orderedJobs: [][]Job{{job}}, - orderConstraintSpecifier: orderConstraintSpecifier, - } - }), - Entry("multiple jobs, no dependencies", func() lockingTestCase { var a = fakeJob("a", "releasea") var b = fakeJob("b", "releaseb") @@ -103,7 +91,7 @@ var _ = Describe("KahnLockOrderer", func() { return lockingTestCase{ inputJobs: []Job{a, b, c}, - errorMessage: "could not find locking dependency releasee/e", + orderedJobs: [][]Job{{a, b, c}}, orderConstraintSpecifier: orderConstraintSpecifier, } }),