New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean old bundle data before new activation #4944
Clean old bundle data before new activation #4944
Conversation
} | ||
} | ||
|
||
params.RootOverwrite = rootOverwrite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other idea was to pass this in the context's value but did not seem right.
storage/disk/disk.go
Outdated
if params.RootOverwrite { | ||
newPath, ok := storage.ParsePathEscaped("/" + "") | ||
if !ok { | ||
return fmt.Errorf("storage path invalid: %v", newPath) | ||
} | ||
|
||
sTxn, err := db.doTruncateData(ctx, underlyingTxn, newDB, params, newPath, map[string]interface{}{}) | ||
if err != nil { | ||
return wrapError(err) | ||
} | ||
|
||
if sTxn != nil { | ||
underlyingTxn = sTxn | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part I'm not sure if it wipes out everything. The tests seem to indicate that is not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still an open issue with that change?
Isn't the same true when the roots differ? I.e. when the old roots are different from the new roots, does the old data get deleted properly? |
When the roots are specified in the manifest we delete the contents before calling the truncate call. https://github.com/open-policy-agent/opa/blob/main/bundle/store.go#L622. The issue comes up when no roots are defined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry just skimmed it. Nothing raising eye brows but I'm also tired
storage/disk/disk.go
Outdated
@@ -263,6 +263,22 @@ func (db *Store) Truncate(ctx context.Context, txn storage.Transaction, params s | |||
xid := atomic.AddUint64(&db.xid, uint64(1)) | |||
underlyingTxn := newTransaction(xid, true, underlying, params.Context, db.pm, db.partitions, nil) | |||
|
|||
if params.RootOverwrite { | |||
newPath, ok := storage.ParsePathEscaped("/" + "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 "/" + ""
is "/"
, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Updated.
If OPA has an activated bundle that owns all roots and a new bundle with empty roots is to be activated, the old bundle's data should first be erased from the store. Currently both the old and new data is kept in the store. This commit attempts to fix this by providing an indication to the truncate call about the scenario in which the root is to be overwritten. Fixes: open-policy-agent#4940 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
437d15f
to
503e2b5
Compare
If OPA has an activated bundle that owns all roots
and a new bundle with empty roots is to be activated, the
old bundle's data should first be erased from the store.
Currently both the old and new data is kept in the store.
This commit attempts to fix this by providing an indication to
the truncate call about the scenario in which the root is to be
overwritten.
Fixes: #4940
Signed-off-by: Ashutosh Narkar anarkar4387@gmail.com