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

Profile behavior behaves badly when unsuccessful #353

Open
waynew opened this issue Jan 20, 2023 · 1 comment
Open

Profile behavior behaves badly when unsuccessful #353

waynew opened this issue Jan 20, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@waynew
Copy link
Contributor

waynew commented Jan 20, 2023

See #351 for more info, but generally speaking there are two behaviors when using profiles that are just terrible.

<snip>
  File "/home/wayne/mine/review-saltext/src/saltext/vmware/utils/connect.py", line 45, in get_config
    credentials = conf[profile]
KeyError: 'fnord'

A huge stack trace appears when doing something like salt-call vmware_vm.list profile=fnord and the profile doesn't exist.

We could pretty easily catch a KeyError here and then look for profiles that might match, and provide a useful error/exit like "Profile 'fnord' does not exist. Perhaps you meant X?"

Alternatively, if you don't have any config data in the base and only have profiles, and do not provide a profile, you get this:

<snip>
  File "/home/wayne/mine/review-saltext/src/saltext/vmware/utils/connect.py", line 134, in get_service_instance
    config = get_config(config=config, profile=profile, esxi_host=esxi_host)
  File "/home/wayne/mine/review-saltext/src/saltext/vmware/utils/connect.py", line 60, in get_config
    raise ValueError("Cannot create service instance, VMware credentials incomplete.")
ValueError: Cannot create service instance, VMware credentials incomplete.

Also super useless.

Basically what we should do in this case is check if there's a host/user/pass, and if any of those things are missing then we should provide a useful message such as:

No credentials found in the base profile, and no profiles found.

Or

No credentials found in the base profile, but profiles <a, b, c> exist. Are you missing profile=a?

Something to that effect.

@waynew waynew added the bug Something isn't working label Jan 20, 2023
@jgangel
Copy link
Contributor

jgangel commented Jan 23, 2023

This is the behavior when using connect.get_service_instance but a different handling/error is done when using connect.request which is used by other modules. Not sure how profiles are supposed to work, is there any guide for using them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants