[2.6.8] model-config prints a cryptic error message if a file was not found

Bug #1843456 reported by Dmitrii Shcherbakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Nam Nguyen

Bug Description

ubuntu@maas:~/bundles$ juju model-config -h | grep path/to
    juju model-config ftp-proxy=10.0.0.1:8000 path/to/file.yaml
    juju model-config path/to/file.yaml

ubuntu@maas:~/bundles$ juju model-config bundles/k8s-model-config.yaml
ERROR key "bundles/k8s-model-config.yaml" not found in {<nil> ""} model.

ubuntu@maas:~/bundles$ juju model-config ~/bundles/k8s-model-config.yaml
ubuntu@maas:~/bundles$ echo $?
0

Revision history for this message
Ian Booth (wallyworld) wrote :

You will get this error if the supplied file doesn't exist, since in that case the arg is treated as a config key.

The arg currently must be an absolute path. I think adding support for relative paths is reasonable. Plus, if the supplied arg looks like a file path, we can do better with the error message.

tags: added: bitesize
Changed in juju:
milestone: none → 2.7-beta1
status: New → Triaged
importance: Undecided → High
Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

Right, I was in the "bundles" directory already so it was treated a key because the file did not exist.

ubuntu@maas:~$ juju model-config bundles/k8s-model-config.yaml && echo $?
0

It looks like relative paths are supported but the error message is a bit cryptic.

I'll rename the bug.

summary: - [2.6.8] model-config does not handle relative paths as documented
+ [2.6.8] model-config prints a cryptic error message if a file was not
+ found
Nam Nguyen (nammn)
Changed in juju:
assignee: nobody → Nam Nguyen (nammn)
Revision history for this message
Nam Nguyen (nammn) wrote :

So I was looking into it. I see the following ways to fix it:
1. kind of parsing/regexing to check this a kind-of path and return earlier with an error. But how do we want to make this check? Because the input used is not actually a path, detecting it to be possibly one can be difficult, depending on the case. Possible checks: File-ending, Slash in name,

2. another way is to just change the error message
"ERROR key "bundlesk8s-dsds" not found in {<nil> ""} model." and if {<nil> ""} comes, this means neither key, nor model exists and thus just change the error message

3.?

Revision history for this message
Richard Harding (rharding) wrote :

My preference is that we take a more explicit approach:

Step 1: can we reverse that. e.g. "does this match one of the model-config keys?"

Step 2: and if not, "does it look like a file?"

Step 3: "if it looks like a file can I see it"

If we pass step one, then we attempt to set the config.

If we fail on step 2, then we get a "ERROR: key XXX is not a valid model-config"

And if we fail step 3, then we get "ERROR: file XXX is not found"

Revision history for this message
Nam Nguyen (nammn) wrote :

This is the corresponding PR: https://github.com/juju/juju/pull/10665

Nam Nguyen (nammn)
Changed in juju:
status: Triaged → Fix Committed
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.