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 20, 2024
1 parent 842ae45 commit 21ec042
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 @@ -4964,17 +4964,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 @@ -4987,6 +4976,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 21ec042

Please sign in to comment.