Skip to content
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

oci-public-ip -j doesn't print valid json, -g has extra text #154

Open
cpoczatek opened this issue Feb 17, 2023 · 3 comments
Open

oci-public-ip -j doesn't print valid json, -g has extra text #154

cpoczatek opened this issue Feb 17, 2023 · 3 comments

Comments

@cpoczatek
Copy link
Member

In some situations, it looks like warning messages are getting sent to stdout when they should maybe get sent to stderr.
I don't know why this warning appears either, as it's a vanilla instance in IAD with 1 vnic. Actual ip obfuscated.

sudo dnf list installed | grep utils | grep oci
oci-utils.noarch                         0.14.0-2.el8                                @ol8_oci_included 

oci-public-ip -j
No public ip addresses found from OCI, falling back to the stun servers.
The stun servers do not provide details on the vNIC and might find only the primary IP address.

[{"IP Address": "XXX"}]

oci-public-ip -j 2>/dev/null
No public ip addresses found from OCI, falling back to the stun servers.
The stun servers do not provide details on the vNIC and might find only the primary IP address.

[{"IP Address": "XXX"}]

oci-public-ip -j 2>/dev/null | jq .
parse error: Invalid numeric literal at line 1, column 3

oci-public-ip -g
No public ip addresses found from OCI, falling back to the stun servers.
The stun servers do not provide details on the vNIC and might find only the primary IP address.

   XXX

oci-public-ip -g 2>/dev/null
No public ip addresses found from OCI, falling back to the stun servers.
The stun servers do not provide details on the vNIC and might find only the primary IP address.

   XXX

@guidotijskens
Copy link
Member

The message on using the stun servers is not warning, it is informational, in situations where you cannot get the public ip data from OCI, it falls back to scanning, which does not guarantee all data is found.
the -j and -g options (which are both deprecated) work fine on the test env, oci-utils 0.14.0-2
`# oci-public-ip --help
usage: oci-public-ip [--output-mode {parsable,table,json,text}] [-d] [-s SOURCEIP] [-S STUN_SERVER] [-L] [--instance-id OCID] [--help]

Utility for displaying the public IP address of the current OCI instance.

optional arguments:
--output-mode {parsable,table,json,text}
Set output mode
-d, --details display details information
-s SOURCEIP, --sourceip SOURCEIP
Specify the source IP address to use
-S STUN_SERVER, --stun-server STUN_SERVER
Specify the STUN server to use
-L, --list-servers Print a list of known STUN servers and exit
--instance-id OCID Display the public IP address of the given instance instead of the current one. Requires the OCI Python SDK to be installed and configured
`

@cpoczatek
Copy link
Member Author

Ok, it's informational but it should still go to stderr imo. If -j/-g are deprecated, there's no warning that they are on use.

Am I correct in assuming the ability to get public ip data "from OCI" means there's an instance principal (or similar) to allow API calls? I would say the base case of just having created an instance is the simpler situation and should give valid json even if it's not guaranteed.

oci-public-ip --output-mode json | jq .
parse error: Invalid numeric literal at line 1, column 3
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe

@guidotijskens
Copy link
Member

I agree it the information should go to stderr;
.
the public ip is not in the metadata, if you do not have instance principal nor direct authentication set up, the only way is using stun servers.
I cannot reproduce your output...

oci-public-ip -S stun.stunprotocol.org --output-mode json|jq

[
{
"IP Address": "www.xxx.yyy.zzz"
}
]
please file a ticket at oracle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants