Provisioning: always set job status when a sync job is created (#111957)
This commit is contained in:
@@ -20,16 +20,23 @@ type JobQueueGetter interface {
|
||||
}
|
||||
|
||||
type jobsConnector struct {
|
||||
repoGetter RepoGetter
|
||||
jobs JobQueueGetter
|
||||
historic jobs.HistoryReader
|
||||
repoGetter RepoGetter
|
||||
statusPatcherProvider StatusPatcherProvider
|
||||
jobs JobQueueGetter
|
||||
historic jobs.HistoryReader
|
||||
}
|
||||
|
||||
func NewJobsConnector(repoGetter RepoGetter, jobs JobQueueGetter, historic jobs.HistoryReader) *jobsConnector {
|
||||
func NewJobsConnector(
|
||||
repoGetter RepoGetter,
|
||||
statusPatcherProvider StatusPatcherProvider,
|
||||
jobs JobQueueGetter,
|
||||
historic jobs.HistoryReader,
|
||||
) *jobsConnector {
|
||||
return &jobsConnector{
|
||||
repoGetter: repoGetter,
|
||||
jobs: jobs,
|
||||
historic: historic,
|
||||
repoGetter: repoGetter,
|
||||
statusPatcherProvider: statusPatcherProvider,
|
||||
jobs: jobs,
|
||||
historic: historic,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +132,23 @@ func (c *jobsConnector) Connect(
|
||||
}
|
||||
spec.Repository = name
|
||||
|
||||
// If a sync job is being created, we should update its status to pending.
|
||||
if spec.Pull != nil {
|
||||
err = c.statusPatcherProvider.GetStatusPatcher().Patch(ctx, cfg, map[string]interface{}{
|
||||
"op": "replace",
|
||||
"path": "/status/sync",
|
||||
"value": &provisioning.SyncStatus{
|
||||
State: provisioning.JobStatePending,
|
||||
LastRef: cfg.Status.Sync.LastRef,
|
||||
Started: time.Now().UnixMilli(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
responder.Error(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
job, err := c.jobs.GetJobQueue().Insert(ctx, cfg.Namespace, spec)
|
||||
if err != nil {
|
||||
responder.Error(err)
|
||||
|
||||
@@ -494,7 +494,7 @@ func (b *APIBuilder) UpdateAPIGroupInfo(apiGroupInfo *genericapiserver.APIGroupI
|
||||
storage[provisioning.RepositoryResourceInfo.StoragePath("history")] = &historySubresource{
|
||||
repoGetter: b,
|
||||
}
|
||||
storage[provisioning.RepositoryResourceInfo.StoragePath("jobs")] = NewJobsConnector(b, b, jobHistory)
|
||||
storage[provisioning.RepositoryResourceInfo.StoragePath("jobs")] = NewJobsConnector(b, b, b, jobHistory)
|
||||
|
||||
// Add any extra storage
|
||||
for _, extra := range b.extras {
|
||||
|
||||
Reference in New Issue
Block a user