I noticed that we iterate over maps here:
|
for packageName, bundleIDMap := range pkgToBundleMap { |
|
var bundleIDs []deppy.Identifier |
|
for bundleID := range bundleIDMap { |
|
bundleIDs = append(bundleIDs, bundleID) |
|
} |
|
varID := deppy.IdentifierFromString(fmt.Sprintf("%s package uniqueness", packageName)) |
|
variables = append(variables, olmvariables.NewBundleUniquenessVariable(varID, bundleIDs...)) |
|
} |
I believe this results in randomised order of variables.
Tests do not flag this because they use ConsistOf which ignores order:
|
// Note: As above, the 5 GVKs would appear here as GVK uniqueness constraints |
|
// if GVK Uniqueness were being accounted for. |
|
Expect(crdConstraintVariables).To(WithTransform(CollectGlobalConstraintVariableIDs, ConsistOf([]string{ |
|
"another-package package uniqueness", |
|
"bar-package package uniqueness", |
|
"test-package-2 package uniqueness", |
|
"test-package package uniqueness", |
|
"some-package package uniqueness", |
|
"some-other-package package uniqueness", |
|
}))) |
It likely contributes to what was reported in operator-framework/deppy#142:
It turns out the assertion is flaky because the content of the message changes from run to run, only in terms of the order in which the individual constraint messages appear. This is problematic when this error message is written to a kubernetes status object because it results in a reconcile -> update status -> reconcile -> update status loop until we get "lucky" and deppy returns the same message two reconciles in a row.
I noticed that we iterate over maps here:
operator-controller/internal/resolution/variablesources/crd_constraints.go
Lines 66 to 73 in e001a0f
I believe this results in randomised order of variables.
Tests do not flag this because they use
ConsistOfwhich ignores order:operator-controller/internal/resolution/variablesources/crd_constraints_test.go
Lines 285 to 294 in e001a0f
It likely contributes to what was reported in operator-framework/deppy#142: