mirror of
https://github.com/kubevirt/kubevirt.core.git
synced 2026-07-31 11:54:38 +00:00
Merge pull request #39 from 0xFelix/bump-version-e2e
Bump e2e-setup.sh version and ensure compatibility with KubeVirt >=1.1.0
This commit is contained in:
1
.github/workflows/integration.yml
vendored
1
.github/workflows/integration.yml
vendored
@@ -101,6 +101,7 @@ jobs:
|
|||||||
if: inputs.ansible_test_targets != ''
|
if: inputs.ansible_test_targets != ''
|
||||||
uses: helm/kind-action@v1.9.0
|
uses: helm/kind-action@v1.9.0
|
||||||
with:
|
with:
|
||||||
|
version: v0.22.0
|
||||||
install_only: true
|
install_only: true
|
||||||
|
|
||||||
- name: Deploy kubevirt
|
- name: Deploy kubevirt
|
||||||
|
|||||||
@@ -23,17 +23,17 @@ set_default_params() {
|
|||||||
BIN_DIR=${BIN_DIR:-$DIR/../bin}
|
BIN_DIR=${BIN_DIR:-$DIR/../bin}
|
||||||
|
|
||||||
KIND=${KIND:-$BIN_DIR/kind}
|
KIND=${KIND:-$BIN_DIR/kind}
|
||||||
KIND_VERSION=${KIND_VERSION:-v0.20.0}
|
KIND_VERSION=${KIND_VERSION:-v0.22.0}
|
||||||
|
|
||||||
KUBECTL=${KUBECTL:-$BIN_DIR/kubectl}
|
KUBECTL=${KUBECTL:-$BIN_DIR/kubectl}
|
||||||
KUBECTL_VERSION=${KUBECTL_VERSION:-v1.28.1}
|
KUBECTL_VERSION=${KUBECTL_VERSION:-v1.29.2}
|
||||||
|
|
||||||
KUBEVIRT_VERSION=${KUBEVIRT_VERSION:-v1.0.0}
|
KUBEVIRT_VERSION=${KUBEVIRT_VERSION:-v1.1.0}
|
||||||
KUBEVIRT_CDI_VERSION=${KUBEVIRT_CDI_VERSION:-v1.57.0}
|
KUBEVIRT_CDI_VERSION=${KUBEVIRT_CDI_VERSION:-v1.58.1}
|
||||||
KUBEVIRT_COMMON_INSTANCETYPES_VERSION=${KUBEVIRT_COMMON_INSTANCETYPES_VERSION:-v0.3.2}
|
KUBEVIRT_COMMON_INSTANCETYPES_VERSION=${KUBEVIRT_COMMON_INSTANCETYPES_VERSION:-v0.4.0}
|
||||||
KUBEVIRT_USE_EMULATION=${KUBEVIRT_USE_EMULATION:-"false"}
|
KUBEVIRT_USE_EMULATION=${KUBEVIRT_USE_EMULATION:-"false"}
|
||||||
|
|
||||||
CNAO_VERSION=${CNAO_VERSION:-v0.89.0}
|
CNAO_VERSION=${CNAO_VERSION:-v0.91.0}
|
||||||
|
|
||||||
CLUSTER_NAME=${CLUSTER_NAME:-kind}
|
CLUSTER_NAME=${CLUSTER_NAME:-kind}
|
||||||
SECONDARY_NETWORK_NAME=${NETWORK_NAME:-kindexgw}
|
SECONDARY_NETWORK_NAME=${NETWORK_NAME:-kindexgw}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ options:
|
|||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 28.1.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -160,6 +160,7 @@ EXAMPLES = """
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from collections import defaultdict
|
||||||
from json import loads
|
from json import loads
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
@@ -170,17 +171,26 @@ from typing import (
|
|||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Handle import errors of python kubernetes client.
|
||||||
|
# HAS_K8S_MODULE_HELPER imported below will print a warning to the user if the client is missing.
|
||||||
try:
|
try:
|
||||||
from kubernetes.dynamic.resource import ResourceField
|
from kubernetes.dynamic.resource import Resource, ResourceField
|
||||||
from kubernetes.dynamic.exceptions import DynamicApiError
|
from kubernetes.dynamic.exceptions import DynamicApiError, ServiceUnavailableError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
||||||
|
class Resource:
|
||||||
|
pass
|
||||||
|
|
||||||
class ResourceField:
|
class ResourceField:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class DynamicApiError(Exception):
|
class DynamicApiError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class ServiceUnavailableError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
||||||
|
|
||||||
@@ -189,11 +199,36 @@ from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
|||||||
k8s_import_exception,
|
k8s_import_exception,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Handle import errors of python kubernetes client.
|
||||||
|
# HAS_K8S_MODULE_HELPER imported above will print a warning to the user if the client is missing.
|
||||||
|
try:
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.client.discovery import (
|
||||||
|
Discoverer,
|
||||||
|
)
|
||||||
|
except ImportError:
|
||||||
|
|
||||||
|
class Discoverer:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Handle import errors of python kubernetes client.
|
||||||
|
# HAS_K8S_MODULE_HELPER imported above will print a warning to the user if the client is missing.
|
||||||
|
try:
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.client.resource import (
|
||||||
|
ResourceList,
|
||||||
|
)
|
||||||
|
except ImportError:
|
||||||
|
|
||||||
|
class ResourceList:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
K8SClient,
|
K8SClient,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
LABEL_KUBEVIRT_IO_DOMAIN = "kubevirt.io/domain"
|
LABEL_KUBEVIRT_IO_DOMAIN = "kubevirt.io/domain"
|
||||||
TYPE_LOADBALANCER = "LoadBalancer"
|
TYPE_LOADBALANCER = "LoadBalancer"
|
||||||
TYPE_NODEPORT = "NodePort"
|
TYPE_NODEPORT = "NodePort"
|
||||||
@@ -310,6 +345,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.host_format = None
|
self.host_format = None
|
||||||
|
|
||||||
|
# Monkey patch the Discoverers method, see end of file for an explanation.
|
||||||
|
Discoverer.get_resources_for_api_version = _get_resources_for_api_version
|
||||||
|
|
||||||
def verify_file(self, path: str) -> None:
|
def verify_file(self, path: str) -> None:
|
||||||
"""
|
"""
|
||||||
verify_file ensures the inventory file is compatible with this plugin.
|
verify_file ensures the inventory file is compatible with this plugin.
|
||||||
@@ -690,3 +728,68 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
return [self.__resource_field_to_dict(item) for item in field]
|
return [self.__resource_field_to_dict(item) for item in field]
|
||||||
|
|
||||||
return field
|
return field
|
||||||
|
|
||||||
|
|
||||||
|
# This function is copied from the kubernetes.core sources and a fix to handle apis of the format a/b/c was applied.
|
||||||
|
# To ensure compatibility with KubeVirt >=1.1.0 the kubernetes.core Discoverers original method is monkey patched with this one.
|
||||||
|
# TODO: Remove this once the fix was applied to the upstream kubernetes.core collection.
|
||||||
|
#
|
||||||
|
# See:
|
||||||
|
# https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/module_utils/client/discovery.py
|
||||||
|
# https://github.com/ansible-collections/kubernetes.core/issues/685
|
||||||
|
# https://github.com/kubernetes-client/python/issues/2091
|
||||||
|
# https://github.com/kubernetes-client/python/pull/2095
|
||||||
|
def _get_resources_for_api_version(self, prefix, group, version, preferred):
|
||||||
|
"""returns a dictionary of resources associated with provided (prefix, group, version)"""
|
||||||
|
|
||||||
|
resources = defaultdict(list)
|
||||||
|
subresources = defaultdict(dict)
|
||||||
|
|
||||||
|
path = "/".join(filter(None, [prefix, group, version]))
|
||||||
|
try:
|
||||||
|
resources_response = self.client.request("GET", path).resources or []
|
||||||
|
except ServiceUnavailableError:
|
||||||
|
resources_response = []
|
||||||
|
|
||||||
|
resources_raw = list(
|
||||||
|
filter(lambda resource: "/" not in resource["name"], resources_response)
|
||||||
|
)
|
||||||
|
subresources_raw = list(
|
||||||
|
filter(lambda resource: "/" in resource["name"], resources_response)
|
||||||
|
)
|
||||||
|
for subresource in subresources_raw:
|
||||||
|
resource, name = subresource["name"].split("/", 1)
|
||||||
|
subresources[resource][name] = subresource
|
||||||
|
|
||||||
|
for resource in resources_raw:
|
||||||
|
# Prevent duplicate keys
|
||||||
|
for key in ("prefix", "group", "api_version", "client", "preferred"):
|
||||||
|
resource.pop(key, None)
|
||||||
|
|
||||||
|
resourceobj = Resource(
|
||||||
|
prefix=prefix,
|
||||||
|
group=group,
|
||||||
|
api_version=version,
|
||||||
|
client=self.client,
|
||||||
|
preferred=preferred,
|
||||||
|
subresources=subresources.get(resource["name"]),
|
||||||
|
**resource,
|
||||||
|
)
|
||||||
|
resources[resource["kind"]].append(resourceobj)
|
||||||
|
|
||||||
|
resource_lookup = {
|
||||||
|
"prefix": prefix,
|
||||||
|
"group": group,
|
||||||
|
"api_version": version,
|
||||||
|
"kind": resourceobj.kind,
|
||||||
|
"name": resourceobj.name,
|
||||||
|
}
|
||||||
|
resource_list = ResourceList(
|
||||||
|
self.client,
|
||||||
|
group=group,
|
||||||
|
api_version=version,
|
||||||
|
base_kind=resource["kind"],
|
||||||
|
base_resource_lookup=resource_lookup,
|
||||||
|
)
|
||||||
|
resources[resource_list.kind].append(resource_list)
|
||||||
|
return resources
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ options:
|
|||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 28.1.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
- "jsonpatch"
|
- "jsonpatch"
|
||||||
- "jinja2"
|
- "jinja2"
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ extends_documentation_fragment:
|
|||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 28.1.0"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
kubernetes>=12.0.0
|
kubernetes>=28.1.0
|
||||||
PyYaml
|
PyYaml
|
||||||
jsonpatch
|
jsonpatch
|
||||||
jinja2
|
jinja2
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
instancetype:
|
instancetype:
|
||||||
name: u1.small
|
name: u1.small
|
||||||
preference:
|
preference:
|
||||||
name: centos.9.stream
|
name: centos.stream9
|
||||||
spec:
|
spec:
|
||||||
domain:
|
domain:
|
||||||
devices: {}
|
devices: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user