Skip to content

Commit

Permalink
fix(diff): avoid cache miss in server-side diff (argoproj#20605)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crenshaw <[email protected]>
  • Loading branch information
crenshaw-dev authored Oct 31, 2024
1 parent eb10b70 commit e861b55
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,10 @@ func specEqualsCompareTo(spec v1alpha1.ApplicationSpec, comparedTo v1alpha1.Comp
currentSpec.Destination.Name = ""
}

// Set IsServerInferred to false on both, because that field is not important for comparison.
comparedTo.Destination.SetIsServerInferred(false)
currentSpec.Destination.SetIsServerInferred(false)

return reflect.DeepEqual(comparedTo, currentSpec)
}

Expand Down
4 changes: 4 additions & 0 deletions controller/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,10 @@ func TestUseDiffCache(t *testing.T) {
t.Fatalf("error merging app: %s", err)
}
}
if app.Spec.Destination.Name != "" && app.Spec.Destination.Server != "" {
// Simulate the controller's process for populating both of these fields.
app.Spec.Destination.SetInferredServer(app.Spec.Destination.Server)
}
return app
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,12 @@ type ApplicationDestination struct {
isServerInferred bool `json:"-"`
}

// SetIsServerInferred sets the isServerInferred flag. This is used to allow comparison between two destinations where
// one server is inferred and the other is not.
func (d *ApplicationDestination) SetIsServerInferred(inferred bool) {
d.isServerInferred = inferred
}

type ResourceHealthLocation string

var (
Expand Down

0 comments on commit e861b55

Please sign in to comment.