Skip to content

Commit

Permalink
Merge pull request #1584 from roycaihw/automated-release-of-19.15.0-u…
Browse files Browse the repository at this point in the history
…pstream-release-19.0-1635134453

Generate v19.15.0 client
  • Loading branch information
k8s-ci-robot authored Oct 25, 2021
2 parents b6a5d53 + a66bb80 commit c7f60ed
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v19.15.0

Kubernetes API Version: v1.19.15

### Feature
- The new parameter 'no_proxy' has been added to configuration for the REST and websocket client. ([kubernetes-client/python#1579](https://github.com/kubernetes-client/python/pull/1579), [@itaru2622](https://github.com/itaru2622))//github.com/itaru2622))//github.com/itaru2622))//github.com/itaru2622))//github.com/itaru2622))//github.com/itaru2622))//github.com/itaru2622))//github.com/itaru2622))

# v19.15.0b1

Kubernetes API Version: v1.19.15
Expand All @@ -12,6 +19,7 @@ Kubernetes API Version: v1.19.15
- Type checking in `Client.serialize_body()` was made more restrictive and robust. ([kubernetes-client/python-base#241](https://github.com/kubernetes-client/python-base/pull/241), [@piglei](https://github.com/piglei))

### Feature
- Support Proxy Authentication in websocket client(stream/ws_client) like REST client. ([kubernetes-client/python-base#256](https://github.com/kubernetes-client/python-base/pull/256), [@itaru2622](https://github.com/itaru2622))
- Support for the dryRun parameter has been added to the dynamic client. ([kubernetes-client/python-base#247](https://github.com/kubernetes-client/python-base/pull/247), [@gravesm](https://github.com/gravesm))

### API Change
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ No description provided (generated by Openapi Generator https://github.com/opena
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: release-1.19
- Package version: 19.15.0b1
- Package version: 19.15.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen

## Requirements.
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

__project__ = 'kubernetes'
# The version is auto-updated. Please do not edit.
__version__ = "19.15.0b1"
__version__ = "19.15.0"

import kubernetes.client
import kubernetes.config
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import absolute_import

__version__ = "19.15.0b1"
__version__ = "19.15.0"

# import apis into sdk package
from kubernetes.client.api.admissionregistration_api import AdmissionregistrationApi
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'OpenAPI-Generator/19.15.0b1/python'
self.user_agent = 'OpenAPI-Generator/19.15.0/python'
self.client_side_validation = configuration.client_side_validation

def __enter__(self):
Expand Down
5 changes: 4 additions & 1 deletion kubernetes/client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ def __init__(self, host="http://localhost",
self.proxy = None
"""Proxy URL
"""
self.no_proxy = None
"""bypass proxy for host in the no_proxy list.
"""
self.proxy_headers = None
"""Proxy headers
"""
Expand Down Expand Up @@ -347,7 +350,7 @@ def to_debug_report(self):
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: release-1.19\n"\
"SDK Package Version: 19.15.0b1".\
"SDK Package Version: 19.15.0".\
format(env=sys.platform, pyversion=sys.version)

def get_host_settings(self):
Expand Down
3 changes: 2 additions & 1 deletion kubernetes/client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import urllib3

from kubernetes.client.exceptions import ApiException, ApiValueError
from requests.utils import should_bypass_proxies


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -83,7 +84,7 @@ def __init__(self, configuration, pools_size=4, maxsize=None):
maxsize = 4

# https pool manager
if configuration.proxy:
if configuration.proxy and not should_bypass_proxies(configuration.host, no_proxy=configuration.no_proxy or ''):
self.pool_manager = urllib3.ProxyManager(
num_pools=pools_size,
maxsize=maxsize,
Expand Down
3 changes: 1 addition & 2 deletions kubernetes/e2e_test/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class TestClientBatch(unittest.TestCase):
def setUpClass(cls):
cls.config = base.get_e2e_configuration()


def test_job_apis(self):
client = api_client.ApiClient(configuration=self.config)
api = batch_v1_api.BatchV1Api(client)
Expand Down Expand Up @@ -56,4 +55,4 @@ def test_job_apis(self):
self.assertEqual(name, resp.metadata.name)

resp = api.delete_namespaced_job(
name=name, body={}, namespace='default')
name=name, namespace='default', propagation_policy='Background')
66 changes: 40 additions & 26 deletions kubernetes/e2e_test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
else:
import httplib


def short_uuid():
id = str(uuid.uuid4())
return id[-12:]
Expand All @@ -60,6 +61,7 @@ def manifest_with_command(name, command):
}
}


class TestClient(unittest.TestCase):

@classmethod
Expand All @@ -71,7 +73,8 @@ def test_pod_apis(self):
api = core_v1_api.CoreV1Api(client)

name = 'busybox-test-' + short_uuid()
pod_manifest = manifest_with_command(name, "while true;do date;sleep 5; done")
pod_manifest = manifest_with_command(
name, "while true;do date;sleep 5; done")

# wait for the default service account to be created
timeout = time.time() + 30
Expand All @@ -84,9 +87,10 @@ def test_pod_apis(self):
namespace='default')
except ApiException as e:
if (six.PY3 and e.status != HTTPStatus.NOT_FOUND) or (
six.PY3 is False and e.status != httplib.NOT_FOUND):
six.PY3 is False and e.status != httplib.NOT_FOUND):
print('error: %s' % e)
self.fail(msg="unexpected error getting default service account")
self.fail(
msg="unexpected error getting default service account")
print('default service not found yet: %s' % e)
time.sleep(1)
continue
Expand All @@ -111,25 +115,25 @@ def test_pod_apis(self):
'-c',
'for i in $(seq 1 3); do date; done']
resp = stream(api.connect_get_namespaced_pod_exec, name, 'default',
command=exec_command,
stderr=False, stdin=False,
stdout=True, tty=False)
command=exec_command,
stderr=False, stdin=False,
stdout=True, tty=False)
print('EXEC response : %s' % resp)
self.assertEqual(3, len(resp.splitlines()))

exec_command = 'uptime'
resp = stream(api.connect_post_namespaced_pod_exec, name, 'default',
command=exec_command,
stderr=False, stdin=False,
stdout=True, tty=False)
command=exec_command,
stderr=False, stdin=False,
stdout=True, tty=False)
print('EXEC response : %s' % resp)
self.assertEqual(1, len(resp.splitlines()))

resp = stream(api.connect_post_namespaced_pod_exec, name, 'default',
command='/bin/sh',
stderr=True, stdin=True,
stdout=True, tty=False,
_preload_content=False)
command='/bin/sh',
stderr=True, stdin=True,
stdout=True, tty=False,
_preload_content=False)
resp.write_stdin("echo test string 1\n")
line = resp.readline_stdout(timeout=5)
self.assertFalse(resp.peek_stderr())
Expand Down Expand Up @@ -157,7 +161,8 @@ def test_exit_code(self):
api = core_v1_api.CoreV1Api(client)

name = 'busybox-test-' + short_uuid()
pod_manifest = manifest_with_command(name, "while true;do date;sleep 5; done")
pod_manifest = manifest_with_command(
name, "while true;do date;sleep 5; done")

# wait for the default service account to be created
timeout = time.time() + 30
Expand All @@ -171,9 +176,10 @@ def test_exit_code(self):
namespace='default')
except ApiException as e:
if (six.PY3 and e.status != HTTPStatus.NOT_FOUND) or (
six.PY3 is False and e.status != httplib.NOT_FOUND):
six.PY3 is False and e.status != httplib.NOT_FOUND):
print('error: %s' % e)
self.fail(msg="unexpected error getting default service account")
self.fail(
msg="unexpected error getting default service account")
print('default service not found yet: %s' % e)
time.sleep(1)
continue
Expand Down Expand Up @@ -201,11 +207,16 @@ def test_exit_code(self):
(["/bin/sh", "-c", "ls /"], 0)
)
for command, value in commands_expected_values:
client = stream(api.connect_get_namespaced_pod_exec, name, 'default',
command=command,
stderr=True, stdin=False,
stdout=True, tty=False,
_preload_content=False)
client = stream(
api.connect_get_namespaced_pod_exec,
name,
'default',
command=command,
stderr=True,
stdin=False,
stdout=True,
tty=False,
_preload_content=False)

self.assertIsNone(client.returncode)
client.run_forever(timeout=10)
Expand Down Expand Up @@ -337,7 +348,8 @@ def test_portforward_raw(self):

for sock in (sock1234, sock1235):
self.assertTrue(pf.connected)
sent = b'Another test using fileno %s' % str(sock.fileno()).encode()
sent = b'Another test using fileno %s' % str(
sock.fileno()).encode()
sock.sendall(sent)
reply = b''
while True:
Expand All @@ -361,7 +373,7 @@ def test_portforward_http(self):
client = api_client.ApiClient(configuration=self.config)
api = core_v1_api.CoreV1Api(client)

name = 'portforward-http-' + short_uuid()
name = 'portforward-http-' + short_uuid()
pod_manifest = {
'apiVersion': 'v1',
'kind': 'Pod',
Expand Down Expand Up @@ -404,7 +416,8 @@ def kubernetes_create_connection(address, *args, **kwargs):
socket_create_connection = socket.create_connection
try:
socket.create_connection = kubernetes_create_connection
response = urllib_request.urlopen('http://%s.default.kubernetes/' % name)
response = urllib_request.urlopen(
'http://%s.default.kubernetes/' % name)
html = response.read().decode('utf-8')
finally:
socket.create_connection = socket_create_connection
Expand Down Expand Up @@ -485,7 +498,7 @@ def test_replication_controller_apis(self):
self.assertEqual(2, resp.spec.replicas)

resp = api.delete_namespaced_replication_controller(
name=name, body={}, namespace='default')
name=name, namespace='default', propagation_policy='Background')

def test_configmap_apis(self):
client = api_client.ApiClient(configuration=self.config)
Expand Down Expand Up @@ -521,7 +534,8 @@ def test_configmap_apis(self):
resp = api.delete_namespaced_config_map(
name=name, body={}, namespace='default')

resp = api.list_namespaced_config_map('default', pretty=True, label_selector="e2e-tests=true")
resp = api.list_namespaced_config_map(
'default', pretty=True, label_selector="e2e-tests=true")
self.assertEqual([], resp.items)

def test_node_apis(self):
Expand Down
10 changes: 6 additions & 4 deletions kubernetes/e2e_test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def setUpClass(cls):
cls.test_namespace = "e2e-test-utils"
k8s_client = client.api_client.ApiClient(configuration=cls.config)
core_v1 = client.CoreV1Api(api_client=k8s_client)
body = client.V1Namespace(metadata=client.V1ObjectMeta(name=cls.test_namespace))
body = client.V1Namespace(
metadata=client.V1ObjectMeta(
name=cls.test_namespace))
core_v1.create_namespace(body=body)

@classmethod
Expand Down Expand Up @@ -304,7 +306,7 @@ def test_create_from_multi_resource_yaml(self):
name="mock", namespace="default")
self.assertIsNotNone(ctr)
core_api.delete_namespaced_replication_controller(
name="mock", namespace="default", body={})
name="mock", namespace="default", propagation_policy="Background")
core_api.delete_namespaced_service(name="mock",
namespace="default", body={})

Expand Down Expand Up @@ -362,7 +364,7 @@ def test_create_from_multi_resource_yaml_with_conflict(self):
name="mock-2", namespace="default")
self.assertIsNotNone(ctr)
core_api.delete_namespaced_replication_controller(
name="mock-2", namespace="default", body={})
name="mock-2", namespace="default", propagation_policy="Background")
core_api.delete_namespaced_service(name="mock-2",
namespace="default", body={})

Expand Down Expand Up @@ -396,7 +398,7 @@ def test_create_from_multi_resource_yaml_with_multi_conflicts(self):
def test_create_namespaced_apps_deployment_from_yaml(self):
"""
Should be able to create an apps/v1beta1 deployment
in a test namespace.
in a test namespace.
"""
k8s_client = client.api_client.ApiClient(configuration=self.config)
utils.create_from_yaml(
Expand Down
28 changes: 27 additions & 1 deletion kubernetes/test/test_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import unittest

import kubernetes

from kubernetes.client.configuration import Configuration
import urllib3

class TestApiClient(unittest.TestCase):

Expand All @@ -23,3 +24,28 @@ def test_atexit_closes_threadpool(self):
self.assertIsNotNone(client._pool)
atexit._run_exitfuncs()
self.assertIsNone(client._pool)

def test_rest_proxycare(self):

pool = { 'proxy': urllib3.ProxyManager, 'direct': urllib3.PoolManager }

for dst, proxy, no_proxy, expected_pool in [
( 'http://kube.local/', None, None, pool['direct']),
( 'http://kube.local/', 'http://proxy.local:8080/', None, pool['proxy']),
( 'http://127.0.0.1:8080/', 'http://proxy.local:8080/', 'localhost,127.0.0.0/8,.local', pool['direct']),
( 'http://kube.local/', 'http://proxy.local:8080/', 'localhost,127.0.0.0/8,.local', pool['direct']),
( 'http://kube.others.com:1234/','http://proxy.local:8080/', 'localhost,127.0.0.0/8,.local', pool['proxy']),
( 'http://kube.others.com:1234/','http://proxy.local:8080/', '*', pool['direct']),
]:
# setup input
config = Configuration()
setattr(config, 'host', dst)
if proxy is not None:
setattr(config, 'proxy', proxy)
if no_proxy is not None:
setattr(config, 'no_proxy', no_proxy)
# setup done

# test
client = kubernetes.client.ApiClient(configuration=config)
self.assertEqual( expected_pool, type(client.rest_client.pool_manager) )
4 changes: 2 additions & 2 deletions scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
KUBERNETES_BRANCH = "release-1.19"

# client version for packaging and releasing.
CLIENT_VERSION = "19.15.0b1"
CLIENT_VERSION = "19.15.0"

# Name of the release package
PACKAGE_NAME = "kubernetes"

# Stage of development, mainly used in setup.py's classifiers.
DEVELOPMENT_STATUS = "4 - Beta"
DEVELOPMENT_STATUS = "5 - Production/Stable"


# If called directly, return the constant value given
Expand Down
6 changes: 6 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
# - add a sentence about "changes since {last release}". In most cases our
# releases should be sequential. This script (the workflow above) is based on
# this assumption, and we should make the release note clear about that.
# - update readme; if it's a real release (instead of a snapshot in master
# branch), also create a PR to update changelog and readme in the master
# branch
#
# Usage:
# $ KUBERNETES_BRANCH=release-1.19 CLIENT_VERSION=19.0.0-snapshot DEVELOPMENT_STATUS="3 - Alpha" scripts/release.sh
Expand All @@ -64,6 +67,9 @@ set -o errexit
set -o nounset
set -o pipefail

# used by the client generator: https://github.com/kubernetes-client/gen/blob/729332ad08f0f4d98983b7beb027e2f657236ef9/openapi/openapi-generator/client-generator.sh#L52
export USERNAME=kubernetes

repo_root="$(git rev-parse --show-toplevel)"
declare -r repo_root
cd "${repo_root}"
Expand Down
Loading

0 comments on commit c7f60ed

Please sign in to comment.