You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When OPA 0.43.0 loads two bundles (via config or discovery) whose paths are partially overlapping (e.g. store/a and store/b)
then final state contains only store/a or store/b, not both
Reproduceable on Windows or Kubernetes, with the latest version: 0.43.0 (while 0.42.2 works fine)
Steps To Reproduce
Create two very simple bundles, only containing manifest and data:
validate the data via REST: GET localhost:8181/v1/data
the result contains exactly one of the data, depending on the loading order:
{
"result": {
"store": {
"a": {
"v1": {}
}
}
}
}
when the loading order is b and then a
{"level":"info","msg":"Starting bundle loader.","name":"a","plugin":"bundle","time":"2022-08-10T16:03:01+02:00"}
{"level":"info","msg":"Starting bundle loader.","name":"b","plugin":"bundle","time":"2022-08-10T16:03:01+02:00"}
{"level":"info","msg":"Bundle loaded and activated successfully. Etag updated to \"d7afa6a214d03f32ea740f60e8bc0e03\".","name":"b","plugin":"bundle","time":"2022-08-10T16:03:03+02:00"}
{"level":"info","msg":"Bundle loaded and activated successfully. Etag updated to \"8a5f55ef77291df643eda67b872ef684\".","name":"a","plugin":"bundle","time":"2022-08-10T16:03:04+02:00"}
OR
{
"result": {
"store": {
"b": {
"v1": {}
}
}
}
}
when the loading order is a and then b
{"level":"info","msg":"Starting bundle loader.","name":"a","plugin":"bundle","time":"2022-08-10T16:04:11+02:00"}
{"level":"info","msg":"Starting bundle loader.","name":"b","plugin":"bundle","time":"2022-08-10T16:04:11+02:00"}
{"level":"info","msg":"Bundle loaded and activated successfully. Etag updated to \"8a5f55ef77291df643eda67b872ef684\".","name":"a","plugin":"bundle","time":"2022-08-10T16:04:13+02:00"}
{"level":"info","msg":"Bundle loaded and activated successfully. Etag updated to \"d7afa6a214d03f32ea740f60e8bc0e03\".","name":"b","plugin":"bundle","time":"2022-08-10T16:04:13+02:00"}
Similarly, if there are multiple (more than two) bundles containing data, only the one which has been loaded last remains and the others are removed from the json tree.
Expected behavior
on 0.42.2 the above REST call works as intended and returns the following structure:
If the bundles being activated share a manifest root prefix, it
would result in overwriting the bundle data based on the activation
order. This happened since the truncate call writes data to the
store based on the top-level keys in the data. When multiple
bundles with overlapping bundle root prefixes are being activated
as part of the same txn, adding data to the store by iterating
over the top-level keys in the data object would result in an unintended
overwrite. The truncate call would be able to properly write
data if it had knowledge of the bundle roots. This commit passes
the bundle roots to the truncate call to assist in writing data
to the store.
Fixes: open-policy-agent#4998
Signed-off-by: Ashutosh Narkar <[email protected]>
If the bundles being activated share a manifest root prefix, it
would result in overwriting the bundle data based on the activation
order. This happened since the truncate call writes data to the
store based on the top-level keys in the data. When multiple
bundles with overlapping bundle root prefixes are being activated
as part of the same txn, adding data to the store by iterating
over the top-level keys in the data object would result in an unintended
overwrite. The truncate call would be able to properly write
data if it had knowledge of the bundle roots. This commit passes
the bundle roots to the truncate call to assist in writing data
to the store.
Fixes: #4998
Signed-off-by: Ashutosh Narkar <[email protected]>
Short description
When OPA 0.43.0 loads two bundles (via config or discovery) whose paths are partially overlapping (e.g. store/a and store/b)
then final state contains only store/a or store/b, not both
Reproduceable on Windows or Kubernetes, with the latest version: 0.43.0 (while 0.42.2 works fine)
Steps To Reproduce
a.tar.gz
{ "revision": "a", "roots": ["store/a"] }
{ "v1" : {}}
b.tar.gz
{ "revision": "b", "roots": ["store/b"] }
{ "v1" : {} }
GET localhost:8181/v1/data
the result contains exactly one of the data, depending on the loading order:
when the loading order is b and then a
OR
when the loading order is a and then b
Similarly, if there are multiple (more than two) bundles containing data, only the one which has been loaded last remains and the others are removed from the json tree.
Expected behavior
on 0.42.2 the above REST call works as intended and returns the following structure:
The result is also correct even on 0.43.0 if the either
opa run -s --skip-verify -b a.tar.gz -b b.tar.gz
Additional context
N/A
The text was updated successfully, but these errors were encountered: