Skip to content

create_from_yaml verbose flag causes crash when status field is missing #937

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

Closed
hacker-h opened this issue Aug 20, 2019 · 3 comments
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@hacker-h
Copy link

What happened (please include outputs or screenshots):

Output:

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    namespace="default", verbose=True)
  File "/home/hhaecker/virtualenvs/test/lib/python3.7/site-packages/kubernetes/utils/create_from_yaml.py", line 89, in create_from_yaml
    k8s_client, yml_document, verbose, namespace, **kwargs)
  File "/home/hhaecker/virtualenvs/test/lib/python3.7/site-packages/kubernetes/utils/create_from_yaml.py", line 131, in create_from_yaml_single_item
    print("{0} created. status='{1}'".format(kind, str(resp.status)))
AttributeError: 'V1NetworkPolicy' object has no attribute 'status'

What you expected to happen:
Proper confirmation log message for the creation of the NetworkPolicy and no crash.

How to reproduce it (as minimally and precisely as possible):

Use the following two files:

test.py

from kubernetes import client, config, utils
namespace = "01-deny-all"
config.load_kube_config()
k8s_client = client.ApiClient()
corev1 = client.CoreV1Api()
# utils.create_from_yaml = create_from_yaml
utils.create_from_yaml(k8s_client, "e2e-manifests/01-deny-all-traffic-to-an-application.yml",
                                     namespace=namespace, verbose=True)

policy.yml

kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  namespace: default
  name: web-deny-all
spec:
  podSelector:
    matchLabels:
      app: web
  ingress: []

Anything else we need to know?:

Environment:
python kubernetes client 10.0.1
Python 3.7.2
kubernetes v1.13.3

@hacker-h hacker-h added the kind/bug Categorizes issue or PR as related to a bug. label Aug 20, 2019
@micw523
Copy link
Contributor

micw523 commented Aug 20, 2019

This is fixed in #824

@micw523
Copy link
Contributor

micw523 commented Aug 20, 2019

/close

@k8s-ci-robot
Copy link
Contributor

@micw523: Closing this issue.

In response to this:

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants