fix(GODT-3124): Handling of sync child jobs

Improve the handling of sync child jobs to ensure it behaves correctly
in all scenarios.

The sync service now uses a isolated context to avoid all the pipeline
stages shutting down before all the sync tasks have had the opportunity
to run their course.

The job waiter now immediately starts with a counter of 1 and waits
until all the child and the parent job finish before considering the
work to be finished.

Finally, we also handle the case where a sync job can't be queued
because the calling context has been cancelled.
This commit is contained in:
Leander Beernaert
2023-11-29 13:52:12 +01:00
parent 9449177553
commit 7a1c7e8743
15 changed files with 100 additions and 78 deletions

View File

@ -127,9 +127,11 @@ func (mr *MockBuildStageOutputMockRecorder) Close() *gomock.Call {
}
// Produce mocks base method.
func (m *MockBuildStageOutput) Produce(arg0 context.Context, arg1 ApplyRequest) {
func (m *MockBuildStageOutput) Produce(arg0 context.Context, arg1 ApplyRequest) error {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Produce", arg0, arg1)
ret := m.ctrl.Call(m, "Produce", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// Produce indicates an expected call of Produce.
@ -212,9 +214,11 @@ func (mr *MockDownloadStageOutputMockRecorder) Close() *gomock.Call {
}
// Produce mocks base method.
func (m *MockDownloadStageOutput) Produce(arg0 context.Context, arg1 BuildRequest) {
func (m *MockDownloadStageOutput) Produce(arg0 context.Context, arg1 BuildRequest) error {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Produce", arg0, arg1)
ret := m.ctrl.Call(m, "Produce", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// Produce indicates an expected call of Produce.
@ -297,9 +301,11 @@ func (mr *MockMetadataStageOutputMockRecorder) Close() *gomock.Call {
}
// Produce mocks base method.
func (m *MockMetadataStageOutput) Produce(arg0 context.Context, arg1 DownloadRequest) {
func (m *MockMetadataStageOutput) Produce(arg0 context.Context, arg1 DownloadRequest) error {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Produce", arg0, arg1)
ret := m.ctrl.Call(m, "Produce", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// Produce indicates an expected call of Produce.
@ -478,9 +484,11 @@ func (m *MockRegulator) EXPECT() *MockRegulatorMockRecorder {
}
// Sync mocks base method.
func (m *MockRegulator) Sync(arg0 context.Context, arg1 *Job) {
func (m *MockRegulator) Sync(arg0 context.Context, arg1 *Job) error {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Sync", arg0, arg1)
ret := m.ctrl.Call(m, "Sync", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// Sync indicates an expected call of Sync.