Browse Source

kubernetes: add V1DeleteOptions when deleting services

delete_namespaced_service() now takes an required body (delete option)
parameter in the newly released Kubernetes client 6.0.0 [1]. This is not
backward compatible so this commit fixes that by adding the new required
parameter.

NOTE: the requirement of the kubernetes client will be updated by a
following change to avoid requirements check with this one.

[1] https://github.com/kubernetes-client/python/blob/master/CHANGELOG.md#v600b1

Change-Id: I751691b356bf1ca2e43838bb341e0455286e6a1f
changes/32/568332/3
Hunt Xu 3 years ago
parent
commit
2edca386c8
2 changed files with 7 additions and 4 deletions
  1. +3
    -0
      qinling/orchestrator/kubernetes/manager.py
  2. +4
    -4
      qinling/tests/unit/orchestrator/kubernetes/test_manager.py

+ 3
- 0
qinling/orchestrator/kubernetes/manager.py View File

@ -18,6 +18,7 @@ import os
import time
import jinja2
from kubernetes.client import V1DeleteOptions
from oslo_log import log as logging
import requests
import tenacity
@ -147,6 +148,7 @@ class KubernetesManager(base.OrchestratorBase):
self.v1.delete_namespaced_service(
svc_name,
self.conf.kubernetes.namespace,
V1DeleteOptions(),
)
LOG.info("Services in deployment %s deleted.", name)
@ -489,6 +491,7 @@ class KubernetesManager(base.OrchestratorBase):
self.v1.delete_namespaced_service(
svc_name,
self.conf.kubernetes.namespace,
V1DeleteOptions(),
)
self.v1.delete_collection_namespaced_pod(


+ 4
- 4
qinling/tests/unit/orchestrator/kubernetes/test_manager.py View File

@ -218,8 +218,8 @@ class TestKubernetesManager(base.DbTestCase):
self.fake_namespace,
label_selector='runtime_id=%s' % fake_deployment_name)
delete_service_calls = [
mock.call(svc1_name, self.fake_namespace),
mock.call(svc2_name, self.fake_namespace),
mock.call(svc1_name, self.fake_namespace, mock.ANY),
mock.call(svc2_name, self.fake_namespace, mock.ANY),
]
self.k8s_v1_api.delete_namespaced_service.assert_has_calls(
delete_service_calls)
@ -680,8 +680,8 @@ class TestKubernetesManager(base.DbTestCase):
)
delete_service_calls = [
mock.call(svc1_name, self.fake_namespace),
mock.call(svc2_name, self.fake_namespace)
mock.call(svc1_name, self.fake_namespace, mock.ANY),
mock.call(svc2_name, self.fake_namespace, mock.ANY)
]
self.k8s_v1_api.delete_namespaced_service.assert_has_calls(
delete_service_calls)


Loading…
Cancel
Save