-
Notifications
You must be signed in to change notification settings - Fork 185
ExecProvider errors when parsing null values #91
ExecProvider errors when parsing null values #91
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Codecov Report
@@ Coverage Diff @@
## master #91 +/- ##
==========================================
+ Coverage 91.71% 91.72% +<.01%
==========================================
Files 13 13
Lines 1135 1136 +1
==========================================
+ Hits 1041 1042 +1
Misses 94 94
Continue to review full report at Codecov.
|
signed CLA? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I left some comments.
config/exec_provider_test.py
Outdated
exec_config['args'] = None | ||
exec_config['env'] = None | ||
try: | ||
ExecProvider(exec_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the test fails when exec_config
is of ConfigNode
class, e.g. having
exec_config = ConfigNode('test', self.input_ok)
config/exec_provider.py
Outdated
@@ -38,10 +38,10 @@ def __init__(self, exec_config): | |||
'exec: malformed request. missing key \'%s\'' % key) | |||
self.api_version = exec_config['apiVersion'] | |||
self.args = [exec_config['command']] | |||
if 'args' in exec_config: | |||
if 'args' in exec_config and exec_config['args']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception comes from ConfigNode
which implements __getitem__
under the assumption that
all access keys are present in a well-formed kube-config.
Calling the __getitem__
in the if statement would also raise the exception.
To tolerate malformed config, I'd suggest using exec_config.safe_get(key)
to verify if the value is null. Note that the unit test used dict for exec_config which didn't reflect the safe_get attribute.
I've updated the PR to use safe_get and the unit tests to use ConfigNode instead of dict() so they work correctly. I also updated the input_ok to include a |
@fillbit Thanks. Could you also add a comment in |
Please fix the pycodestyle error for travis CI to pass, and squash commits before submit :) |
*Update unit tests to use ConfigNode() instead of dict()
1baf95a
to
3682e9b
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fillbit, roycaihw The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
kubernetes-client/python#678 hi I've been seeing the error mentioned in the issue while using both 8.0.0a and 8.0.0. If anyone has any tips/ideas for what I'm doing wrong or if there is something we need to change with the way we are doing exec-provider, please let me know |
When executing a command like kubectl config use-context kubectl rewrite the the kubeconfig file and adds null to optional parameters. For example a a config with
is rewritten as:
When the ExecParser reads this it returns the error:
This PR adds a test case and a fix for this issue.