Skip to content

Commit

Permalink
fix: don't clean up old offloaded records during save. Fixes: #13220 (#…
Browse files Browse the repository at this point in the history
…13286)

Signed-off-by: shuangkun <[email protected]>
  • Loading branch information
shuangkun authored and Joibel committed Sep 20, 2024
1 parent 67253e8 commit 472843a
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions persist/sqldb/offload_node_status_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,8 @@ func (wdc *nodeOffloadRepo) Save(uid, namespace string, nodes wfv1.Nodes) (strin
}
logCtx.WithField("err", err).Info("Ignoring duplicate key error")
}

logCtx.Debug("Nodes offloaded, cleaning up old offloads")

// This might fail, which kind of fine (maybe a bug).
// It might not delete all records, which is also fine, as we always key on resource version.
// We also want to keep enough around so that we can service watches.
rs, err := wdc.session.SQL().
DeleteFrom(wdc.tableName).
Where(db.Cond{"clustername": wdc.clusterName}).
And(db.Cond{"uid": uid}).
And(db.Cond{"version <>": version}).
And(wdc.oldOffload()).
Exec()
if err != nil {
return "", err
}
rowsAffected, err := rs.RowsAffected()
if err != nil {
return "", err
}
logCtx.WithField("rowsAffected", rowsAffected).Debug("Deleted offloaded nodes")
// Don't need to clean up the old records here, we have a scheduled cleanup mechanism.
// If we clean them up here, when we update, if there is an update conflict, we will not be able to go back.
return version, nil
}

Expand Down

0 comments on commit 472843a

Please sign in to comment.