Skip to content

Commit

Permalink
Add to job table when unsetting job tag on latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Sep 24, 2024
1 parent 5f5eb2c commit e5ed8a2
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4982,17 +4982,6 @@ func (s *StateStore) updateJobVersionTagImpl(index uint64, namespace, jobID stri
return s.upsertJobVersion(index, versionCopy, txn)
}

func (s *StateStore) UnsetJobVersionTag(index uint64, namespace, jobID string, name string) error {
txn := s.db.WriteTxn(index)
defer txn.Abort()

if err := s.unsetJobVersionTagImpl(index, namespace, jobID, name, txn); err != nil {
return err
}

return txn.Commit()
}

func (s *StateStore) unsetJobVersionTagImpl(index uint64, namespace, jobID string, name string, txn *txn) error {
job, err := s.JobVersionByTagName(nil, namespace, jobID, name)
if err != nil {
Expand All @@ -5005,6 +4994,16 @@ func (s *StateStore) unsetJobVersionTagImpl(index uint64, namespace, jobID strin
versionCopy := job.Copy()
versionCopy.TaggedVersion = nil
versionCopy.ModifyIndex = index
latestJob, err := s.JobByID(nil, namespace, jobID)
if err != nil {
return err
}
if versionCopy.Version == latestJob.Version {
if err := txn.Insert("jobs", versionCopy); err != nil {
return err
}
}

return s.upsertJobVersion(index, versionCopy, txn)
}

Expand Down

0 comments on commit e5ed8a2

Please sign in to comment.