# Buggy code
def __dict_to_object_meta(name, namespace, metadata):
    """
    Converts a dictionary into kubernetes ObjectMetaV1 instance.
    """
    meta_obj = kubernetes.client.V1ObjectMeta()
    meta_obj.namespace = namespace
    for key, value in iteritems(metadata):
        if hasattr(meta_obj, key):
            setattr(meta_obj, key, value)

    if meta_obj.name != name:
        log.warning(
            "The object already has a name attribute, overwriting it with "
            "the one defined inside of salt"
        )
        meta_obj.name = name

    return meta_obj


# Traceback (MaxRetryError)
(ve) [root@omniscience salt]# salt-call kubernetes.nodes
[WARNING ] /home/jeff/git/salt/salt/utils/__init__.py:794: DeprecationWarning: Use of 'salt.utils.fopen' detected. This function has been moved to 'salt.utils.files.fopen' as of Salt Oxygen. This warning will be removed in Salt Neon.

2017-10-21 19:35:22,944 WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
2017-10-21 19:35:22,944 WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
[WARNING ] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
2017-10-21 19:35:22,945 WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
2017-10-21 19:35:22,945 WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
[WARNING ] Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
2017-10-21 19:35:22,946 WARNING Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
2017-10-21 19:35:22,946 WARNING Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
[WARNING ] Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),)': /api/v1/nodes
[ERROR   ] Exception when calling CoreV1Api->list_node: HTTPSConnectionPool(host='192.168.99.100', port=8443): Max retries exceeded with url: /api/v1/nodes (Caused by SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),))
Traceback (most recent call last):
File "/home/jeff/git/salt/salt/modules/kubernetes.py", line 216, in nodes
api_response = api_instance.list_node()
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 13990, in list_node
(data) = self.list_node_with_http_info(**kwargs)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 14086, in list_node_with_http_info
collection_formats=collection_formats)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 335, in call_api
_preload_content, _request_timeout)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 148, in __call_api
_request_timeout=_request_timeout)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 371, in request
headers=headers)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/kubernetes/client/rest.py", line 250, in GET
query_params=query_params)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/kubernetes/client/rest.py", line 223, in request
headers=headers)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/urllib3/request.py", line 66, in request
**urlopen_kw)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/urllib3/request.py", line 87, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/urllib3/poolmanager.py", line 321, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen
**response_kw)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen
**response_kw)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen
**response_kw)
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/jeff/git/salt/ve/lib/python2.7/site-packages/urllib3/util/retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
MaxRetryError: HTTPSConnectionPool(host='192.168.99.100', port=8443): Max retries exceeded with url: /api/v1/nodes (Caused by SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),))
Error running 'kubernetes.nodes': HTTPSConnectionPool(host='192.168.99.100', port=8443): Max retries exceeded with url: /api/v1/nodes (Caused by SSLError(SSLError(336265225, u'[SSL] PEM lib (_ssl.c:2718)'),))

# Fixed code
def __dict_to_object_meta(name, namespace, metadata):
    """
    Converts a dictionary into kubernetes ObjectMetaV1 instance.
    """
    meta_obj = kubernetes.client.V1ObjectMeta()
    meta_obj.namespace = namespace

    # Replicate `kubectl [create|replace|apply] --record`
    if "annotations" not in metadata:
        metadata["annotations"] = {}
    if "kubernetes.io/change-cause" not in metadata["annotations"]:
        metadata["annotations"]["kubernetes.io/change-cause"] = " ".join(sys.argv)

    for key, value in iteritems(metadata):
        if hasattr(meta_obj, key):
            setattr(meta_obj, key, value)

    if meta_obj.name != name:
        log.warning(
            "The object already has a name attribute, overwriting it with "
            "the one defined inside of salt"
        )
        meta_obj.name = name

    return meta_obj