Skip to content

Conversation

@ericbram
Copy link

Add None check if no VMs are present in resources list. This allows an empty array to be successfully returned instead of causing an exception.

Add None check if no VMs are present in resources list.  This allows an empty array to be successfully returned instead of causing an exception.
@nmaludy
Copy link
Contributor

nmaludy commented Apr 13, 2020

@ericbram i would think that you would want to action to fail if it failed to find the VM?

@ericbram
Copy link
Author

In my case, I'm getting a list of VMs in a cluster. It makes sense to me to return an empty list if there are no VMs present, as that's representative of the truth.

If there are cases where it's good to fail the action, I think that's understandable, but I don't think the correct action is to fail due to a null exception

@nmaludy
Copy link
Contributor

nmaludy commented Apr 13, 2020

I know right now we use get_vms to search for specific VMs and rely on the fact that it fails if it doesn't find the VM.

Maybe you could add a flag like return_empty_array_if_not_found (really long name, you might think of a better name) that would change this behavior, but only when the user requests it.

Just don't want to break a bunch of existing workflows for current users.

@ericbram
Copy link
Author

I think that's a fair point, is that the line where you actually get your failure?

I was just looking for a quick fix to solve the issue in my case, but it seems like this function is overloaded and I don't have a pressing need to rework it. I'll just make note that the exception I see means no VMs are found, and not that our configuration is wrong. Thanks!

@nmaludy
Copy link
Contributor

nmaludy commented Apr 13, 2020

I know for us, we don't look at the error message. We assume error = VM not found.

I don't mind a change here, you could totally add a flag in if you would like different default behavior. I certainly see the value of that change and would appreciate the contribution!

Copy link
Contributor

@nmaludy nmaludy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to see this different behavior turned into a flag, if possible.

Please also update the CHANGELOG entry and increment the pack's version by 0.1.0 (added new feature).

Thanks!

@ericbram
Copy link
Author

ericbram commented May 5, 2021

@nmaludy I'm really sorry about this, I started using my work account permanently and forgot I did this PR. I updated with your requests, please let me know if you'd like to see any other changes.

@nmaludy
Copy link
Contributor

nmaludy commented May 5, 2021

@jschoewe @bishopbm1 thoughts?

@jschoewe
Copy link
Contributor

jschoewe commented May 5, 2021

@nmaludy @ericbram I definitely see the use case for this, I tested it in our environment and it looks good to me.

Something I just noticed when testing this, though, is that if we provide a cluster with no VMs in it then it fails and if we provide an moid that doesn't exist in the "ids" field then it also fails, but if we provide a name that doesn't exist in the "names" field then the action succeeds and returns an empty array. I'm thinking this should fail too if the name isn't found but I don't want to mess up anyone's current workflows so I'm fine leaving it how it is if you are.

Copy link
Contributor

@bishopbm1 bishopbm1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ericbram ericbram closed this May 11, 2022
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

Successfully merging this pull request may close these issues.

5 participants