Skip to content

Commit 88a1bbf

Browse files
joelanfordPer Goncalves da Silva
authored andcommitted
sort lists of identifiers and conflict messages to reduce SAT solver non-determinism (#3491)
Signed-off-by: Joe Lanford <[email protected]> Upstream-repository: operator-lifecycle-manager Upstream-commit: 451e775ea03eb9280399ba0abaf19bd237df167c
1 parent 6bbfb0a commit 88a1bbf

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

staging/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"slices"
78
"sort"
89
"strings"
910

@@ -513,11 +514,13 @@ func (r *Resolver) addInvariants(namespacedCache cache.MultiCatalogOperatorFinde
513514
}
514515

515516
for gvk, is := range gvkConflictToVariable {
517+
slices.Sort(is)
516518
s := NewSingleAPIProviderVariable(gvk.Group, gvk.Version, gvk.Kind, is)
517519
variables[s.Identifier()] = s
518520
}
519521

520522
for pkg, is := range packageConflictToVariable {
523+
slices.Sort(is)
521524
s := NewSinglePackageInstanceVariable(pkg, is)
522525
variables[s.Identifier()] = s
523526
}

staging/operator-lifecycle-manager/pkg/controller/registry/resolver/solver/lit_mapping.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package solver
22

33
import (
4+
"cmp"
45
"fmt"
6+
"slices"
57
"strings"
68

79
"github.com/go-air/gini/inter"
@@ -203,5 +205,8 @@ func (d *litMapping) Conflicts(g inter.Assumable) []AppliedConstraint {
203205
as = append(as, a)
204206
}
205207
}
208+
slices.SortFunc(as, func(a, b AppliedConstraint) int {
209+
return cmp.Compare(a.String(), b.String())
210+
})
206211
return as
207212
}

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/solver/lit_mapping.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)