mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-21 14:20:41 +08:00
[MM-69484] Fix SetJobWarning not decrementing active job metric (#37213)
* [MM-26508] Fix SetJobWarning not decrementing active job metric SetJobWarning was the only terminal-state job setter that did not call DecrementJobActive, causing a permanent metrics leak in the mattermost_jobs_active gauge for any job completing with warnings (message_export, and soon LDAP sync). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add missing metrics mock expectations to TestSetJobWarning Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Enforce single DecrementJobActive call in TestSetJobWarning Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
Mattermost Build
parent
4d1849f346
commit
577d84d82c
@@ -122,6 +122,11 @@ func (srv *JobServer) SetJobWarning(job *model.Job) *model.AppError {
|
||||
if _, err := srv.Store.Job().UpdateStatus(job.Id, model.JobStatusWarning); err != nil {
|
||||
return model.NewAppError("SetJobWarning", "app.job.update.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if srv.metrics != nil {
|
||||
srv.metrics.DecrementJobActive(job.Type)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,26 @@ func TestSetJobWarning(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("status updated", func(t *testing.T) {
|
||||
jobServer, mockStore, _ := makeJobServer(t)
|
||||
jobServer, mockStore, mockMetrics := makeJobServer(t)
|
||||
|
||||
job := &model.Job{
|
||||
Id: "job_id",
|
||||
Type: "job_type",
|
||||
}
|
||||
retJob := *job
|
||||
retJob.Status = model.JobStatusWarning
|
||||
|
||||
mockStore.JobStore.
|
||||
On("UpdateStatus", "job_id", model.JobStatusWarning).
|
||||
Return(&retJob, nil)
|
||||
mockMetrics.On("DecrementJobActive", "job_type").Once()
|
||||
|
||||
err := jobServer.SetJobWarning(job)
|
||||
require.Nil(t, err)
|
||||
})
|
||||
|
||||
t.Run("status updated, nil metrics service", func(t *testing.T) {
|
||||
jobServer, mockStore := makeTeamEditionJobServer(t)
|
||||
|
||||
job := &model.Job{
|
||||
Id: "job_id",
|
||||
|
||||
Reference in New Issue
Block a user