Skip to content

Commit b000549

Browse files
committed
Slight adjustment to logic when resource is seen for first time
1 parent 7082c9c commit b000549

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

internal/watch/watcher.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,20 @@ func (w *Watcher) checkSuspensionStatus(ctx context.Context, resource k8s.Resour
106106
var updated bool
107107
entry, err := w.store.GetEntry(resource)
108108
if err != nil {
109-
if !errors.Is(err, datastore.ErrNotFound) {
110-
return err
109+
if errors.Is(err, datastore.ErrNotFound) {
110+
// First time seeing the resource, so we'll save the state, but not notify - as we don't know what has
111+
// changed
112+
if err = w.store.SaveEntry(datastore.Entry{
113+
Resource: resource,
114+
Suspended: suspended,
115+
UpdatedBy: updatedBy,
116+
UpdatedAt: time.Now().UTC(),
117+
}); err != nil {
118+
return err
119+
}
120+
return nil
111121
}
112-
updated = true
113-
entry = datastore.Entry{}
122+
return fmt.Errorf("failed to fetch entry: %w", err)
114123
} else {
115124
updated = suspended != entry.Suspended
116125
}

0 commit comments

Comments
 (0)