Skip to content

Commit

Permalink
chore: explicitly check for NotFound
Browse files Browse the repository at this point in the history
We shouldn't rely on the fact that a callee only returns NotFound to pun
err != nil. Instead, explicitly handle NotFound and throw out for other
error types.
  • Loading branch information
manadart committed Sep 18, 2024
1 parent 9cab7d9 commit ecfe9f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions worker/uniter/relation/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ func (r *relationsResolver) NextOp(
return nil, resolver.ErrNoOperation
}

// processRelationSnapshot reconciles the local and remote states for a
// single relation and determines what hoof (if any) should be fired.
func (r *relationsResolver) processRelationSnapshot(
relationID int,
relationSnapshot remotestate.RelationSnapshot,
Expand All @@ -139,6 +141,9 @@ func (r *relationsResolver) processRelationSnapshot(
// to be fired for this relation.
relState, err := r.stateTracker.State(relationID)
if err != nil {
if !errors.Is(err, errors.NotFound) {
return nil, errors.Trace(err)
}
relState = NewState(relationID)
}
hInfo, err := r.nextHookForRelation(relState, relationSnapshot, remoteBroken)
Expand Down

0 comments on commit ecfe9f5

Please sign in to comment.