Provisioning: always set job status when a sync job is created (#111957)

This commit is contained in:
Daniele Stefano Ferru
2025-10-02 12:03:21 -05:00
committed by GitHub
parent 3acb8aa20e
commit 6336e8cdd2
2 changed files with 32 additions and 8 deletions
+31 -7
View File
@@ -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)
+1 -1
View File
@@ -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 {