-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't fail other tasks when retrying artifact get #1653
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d1da2ce
Don't fail other tasks when retrying artifact get
schmichael 2a88e48
Ensure web task exited successfully
schmichael bbce6c7
Ensure bad task reaches terminal state within test
schmichael 5b0dd7f
Make sure bad doesn't fail before web runs
schmichael File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,22 +25,24 @@ func (m *MockAllocStateUpdater) Update(alloc *structs.Allocation) { | |
m.Allocs = append(m.Allocs, alloc) | ||
} | ||
|
||
func testAllocRunner(restarts bool) (*MockAllocStateUpdater, *AllocRunner) { | ||
func testAllocRunnerFromAlloc(alloc *structs.Allocation, restarts bool) (*MockAllocStateUpdater, *AllocRunner) { | ||
logger := testLogger() | ||
conf := config.DefaultConfig() | ||
conf.StateDir = os.TempDir() | ||
conf.AllocDir = os.TempDir() | ||
upd := &MockAllocStateUpdater{} | ||
alloc := mock.Alloc() | ||
if !restarts { | ||
*alloc.Job.LookupTaskGroup(alloc.TaskGroup).RestartPolicy = structs.RestartPolicy{Attempts: 0} | ||
alloc.Job.Type = structs.JobTypeBatch | ||
} | ||
|
||
ar := NewAllocRunner(logger, conf, upd.Update, alloc) | ||
return upd, ar | ||
} | ||
|
||
func testAllocRunner(restarts bool) (*MockAllocStateUpdater, *AllocRunner) { | ||
return testAllocRunnerFromAlloc(mock.Alloc(), restarts) | ||
} | ||
|
||
func TestAllocRunner_SimpleRun(t *testing.T) { | ||
ctestutil.ExecCompatible(t) | ||
upd, ar := testAllocRunner(false) | ||
|
@@ -61,6 +63,45 @@ func TestAllocRunner_SimpleRun(t *testing.T) { | |
}) | ||
} | ||
|
||
// TestAllocRuner_RetryArtifact ensures that if one task in a task group is | ||
// retrying fetching an artifact, other tasks in the the group should be able | ||
// to proceed. See #1558 | ||
func TestAllocRunner_RetryArtifact(t *testing.T) { | ||
ctestutil.ExecCompatible(t) | ||
|
||
alloc := mock.Alloc() | ||
|
||
// Create a copy of the task for testing #1558 | ||
badtask := alloc.Job.TaskGroups[0].Tasks[0].Copy() | ||
badtask.Name = "bad" | ||
|
||
// Add a bad artifact to one of the tasks | ||
badtask.Artifacts = []*structs.TaskArtifact{ | ||
{GetterSource: "http://127.1.1.111:12315/foo/bar/baz"}, | ||
} | ||
|
||
alloc.Job.TaskGroups[0].Tasks = append(alloc.Job.TaskGroups[0].Tasks, badtask) | ||
upd, ar := testAllocRunnerFromAlloc(alloc, true) | ||
go ar.Run() | ||
defer ar.Destroy() | ||
|
||
testutil.WaitForResult(func() (bool, error) { | ||
if upd.Count < 6 { | ||
return false, fmt.Errorf("Not enough updates") | ||
} | ||
last := upd.Allocs[upd.Count-1] | ||
if last.TaskStates["web"].State != structs.TaskStatePending { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check the desired states at the end of the test |
||
return false, fmt.Errorf("expected web to be pending but found %q", last.TaskStates["web"].State) | ||
} | ||
if last.TaskStates["bad"].State != structs.TaskStatePending { | ||
return false, fmt.Errorf("expected bad to be pending but found %q", last.TaskStates["web"].State) | ||
} | ||
return true, nil | ||
}, func(err error) { | ||
t.Fatalf("err: %v", err) | ||
}) | ||
} | ||
|
||
func TestAllocRunner_TerminalUpdate_Destroy(t *testing.T) { | ||
ctestutil.ExecCompatible(t) | ||
upd, ar := testAllocRunner(false) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally don't do code references back to github issues