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
Misleading storage_not_found_error when delta bundle uses persistence #5959
Comments
In the downloader we know if the bundle will be persisted to disk. If we can pass that to the bundle reader and add a check during the read operation we should be able to generate a better error message. |
Can I handle this bug. I am looking to understand OPA and contribute to it |
Sure go for it @yogisinha! |
Ok. thanks. it might take some time as I am new to code. |
Take your time, @yogisinha! There's a #contributors channel on the OPA Slack if you'd like to get some help while you're working on this. But asking here is fine too. |
I am able to replicate the error. I did the following.
Looking into the code now. |
Hi @ashutosh-narkar and @anderseknert I think my delta bundle is not correct. I have 2 files input.json and patch.json in 2 different folders. folder "patch" has only patch.json. From same location I create the complete and patch bundle and a python process is exposing the bundle.tar.gz on localhost:8080
It loaded the bundle successfully. terminal output : {"addrs":[":8181"],"diagnostic-addrs":[],"level":"info","msg":"Initializing server. OPA is running on a public (0.0.0.0) network interface. Unless you intend to expose OPA outside of the host, binding to the localhost interface (--addr localhost:8181) is recommended. See https://www.openpolicyagent.org/docs/latest/security/#interface-binding","time":"2023-06-09T08:20:34-04:00"}
After some time, the Terminal 2 output looks like this: {"addrs":[":8181"],"diagnostic-addrs":[],"level":"info","msg":"Initializing server. OPA is running on a public (0.0.0.0) network interface. Unless you intend to expose OPA outside of the host, binding to the localhost interface (--addr localhost:8181) is recommended. See https://www.openpolicyagent.org/docs/latest/security/#interface-binding","time":"2023-06-09T08:20:34-04:00"} So even persist=false is passed, its throwing the same "storage not found error". Am I doing something wrong here ? |
@yogisinha try a patch document with a As far as implementation goes, one option is to add a check like below here before we attempt to activate the bundle. Alternatively we can also add a check in the bundle reader as mentioned here. if u.Bundle.Type() == bundle.DeltaBundleType && p.persistBundle(name) {
errMsg := "Persisting delta bundle to disk is not supported"
p.log(name).Error(errMsg)
p.status[name].SetError(fmt.Errorf(errMsg))
if !p.stopped {
etag := p.etags[name]
p.downloaders[name].SetCache(etag)
}
return
} |
Ok. thanks @ashutosh-narkar I will try upsert. So there is no issue in steps what I explained before ? Yes, I was thinking to put the code in bundle reader as there is already some checks for delta bundle there in Read() method. I can add the check there. |
If you simply load a delta bundle and set |
@ashutosh-narkar thanks for your help. I appreciate it. I am passing persist=true in command line through --set options as explained in OPA doc and it says that Here is my finding about delta bundle. do you see any difference in behavior when you use different values for persist property for delta bundle? I put your code where you suggested (before call to activate() inside process method) and ran the code with persist=false and loading of delta bundle still failed. The error is coming in downstream calls which starts in from acitvate() method this is the call chain I could find In newUpdateObject, its returning the error. (return nil, errors.NewNotFoundError(path)) Can you help in creating a valid delta bundle ? and how you are running it ? |
Hi @ashutosh-narkar, @anderseknert , I found my issue. data.json file inside the snapshot bundle I created was empty. So OPA was starting with no data, so it makes sense to throw the error in all the case which I was getting before. I was using the file name input.json when I was creating the snapshot bundle. I had to use file name as data.json. But now with persist=true, I can successfully load the delta bundle. there is no issue. For example , I did this 3 steps.
{"level":"info","msg":"Bundle loaded and activated successfully.","name":"cli1","plugin":"bundle","time":"2023-06-10T09:44:14-04:00"} I tried with both true and false values for persist property and is able to load the delta bundle. The only logic I see related to persist field is in download method of download.go where it populates the raw field of downloaderResponse. May be we can change the error msg a little bit more clear like : path_not_found_error: "path in delta bundle" does not exist in snapshot bundle |
HI @ashutosh-narkar @anderseknert Can you look at my findings and let me know if its still a bug or we just need more clear error msg? |
Hey @yogisinha
The problem is that the |
@jnethery So you are saying if you do persist=false, you are not getting any error even if the path in delta bundle is invalid ? I think it would throw the error if the path is invalid, even if persist=false. What I am saying is that even if you set persist=false, if the path is invalid in delta bundle, it would throw the same error. So its not depending on persist value really. Can you please try loading a delta bundle with persist=false and pass the invalid path? |
@yogisinha If my path was invalid, then the error message would technically be correct, just for the wrong reason :) It does depend on the persist value, because the issue is that delta bundles do not persist, so the setting is invalid. The error should say something to this effect, rather than saying the path is unfound, which is not true. |
@jnethery So basically we don't want to even load the delta bundle and try to update it if the persist value is true ? So basically its a validation logic we are trying to put, right ? |
@yogisinha It already does not load; the solution here is simply to make the error message more clear. I suggest following the advice of @ashutosh-narkar |
@jnethery So finally we are doing this
|
@yogisinha Sounds correct to me |
…_error) message while loading the delta bundle when persist property in config is true. The fix is to prevent the loading of delta bundle when persist is true and give a more clear error message. Fixes open-policy-agent#5959
@ashutosh-narkar @anderseknert I have created the PR for this issue. Please review and let me know any feedback. |
…_error) message while loading the delta bundle when persist property in config is true. The fix is to prevent the loading of delta bundle when persist is true and give a more clear error message. Fixes open-policy-agent#5959 Signed-off-by: Yogesh Sinha <sinhayogi@gmail.com>
…_error) message while loading the delta bundle when persist property in config is true. The fix is to prevent the loading of delta bundle when persist is true and give a more clear error message. Fixes open-policy-agent#5959 Signed-off-by: Yogesh Sinha <sinhayogi@gmail.com>
…_error) message while loading the delta bundle when persist property in config is true. The fix is to prevent the loading of delta bundle when persist is true and give a more clear error message. Fixes #5959 Signed-off-by: Yogesh Sinha <sinhayogi@gmail.com>
…_error) message while loading the delta bundle when persist property in config is true. The fix is to prevent the loading of delta bundle when persist is true and give a more clear error message. Fixes open-policy-agent#5959 Signed-off-by: Yogesh Sinha <sinhayogi@gmail.com> Signed-off-by: Fred Feng <superffeng@gmail.com>
Version Details
Description
If
persist: true
is set in the config for a delta bundle, OPA will throw the following error:storage_not_found_error: <path>: document does not exist
.This seems to be a slightly misleading or perhaps incomplete error, as it doesn't provide much information or feedback to the user.
Steps To Reproduce
persist: true
as a field to the bundle config for a delta bundle inconfig.yaml
.storage_not_found_error
in the logs.Expected behavior
I would expect a more specific error, maybe one pointing out that not only is
persist: true
not available for delta bundles, but is also invalid.The text was updated successfully, but these errors were encountered: