Skip to content

Commit

Permalink
fix(api): do not update condition transition time if status not chang…
Browse files Browse the repository at this point in the history
…ed (#544)

Do not update condition last transition time if status not changed.

---------

Signed-off-by: Valeriy Khorunzhin <[email protected]>
  • Loading branch information
eofff authored Nov 28, 2024
1 parent befc9b7 commit 668201a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func (c *ConditionBuilder) Condition() metav1.Condition {
Type: c.conditionType.String(),
Status: c.status,
Reason: c.reason,
LastTransitionTime: metav1.Now(),
Message: c.message,
ObservedGeneration: c.generation,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,22 @@ import (

// Deprecated: use direct SetCondition instead.
type Manager struct {
conds []metav1.Condition
indexConds map[string]int
conds []metav1.Condition
}

// Deprecated: use direct SetCondition instead.
func NewManager(conditions []metav1.Condition) *Manager {
conds := make([]metav1.Condition, len(conditions))
indexConds := make(map[string]int, len(conds))
for i, c := range conditions {
conds[i] = c
indexConds[c.Type] = i
}
return &Manager{
conds: conds,
indexConds: indexConds,
conds: slices.Clone(conditions),
}
}

func (m *Manager) Add(c metav1.Condition) (addedCondition bool) {
if _, found := m.indexConds[c.Type]; found {
findCond := meta.FindStatusCondition(m.conds, c.Type)
if findCond != nil {
return false
}
m.conds = append(m.conds, c)
m.indexConds[c.Type] = len(m.conds) - 1
return true
return meta.SetStatusCondition(&m.conds, c)
}

func (m *Manager) Update(c metav1.Condition) {
Expand Down

0 comments on commit 668201a

Please sign in to comment.