Update tests for node-attributes

This found problems with the openshift and openshiftpods drivers,
so that is fixed. Also update the docs to reflect the fact that
node-attributes is supported across all drivers.

Note that we do not appear to have GCE driver tests, so that one
is just assumed to work.  :(

Change-Id: I98b6f871815d2b564d1550d960e682c180bac7c2
This commit is contained in:
David Shrewsbury 2020-03-24 14:28:06 -04:00 committed by James E. Blair
parent 24db91f96b
commit 8528322cf0
11 changed files with 72 additions and 4 deletions

View File

@ -1301,6 +1301,12 @@ Selecting the kubernetes driver adds the following options to the
Namespaces are prefixed with the pool's name.
.. attr:: node-attributes
:type: dict
A dictionary of key-value pairs that will be stored with the node data
in ZooKeeper. The keys and values can be any arbitrary string.
.. attr:: labels
:type: list
@ -1427,6 +1433,12 @@ Selecting the openshift driver adds the following options to the
Project's name are prefixed with the pool's name.
.. attr:: node-attributes
:type: dict
A dictionary of key-value pairs that will be stored with the node data
in ZooKeeper. The keys and values can be any arbitrary string.
.. attr:: labels
:type: list
@ -1557,6 +1569,12 @@ Selecting the openshift pods driver adds the following options to the
The project's name that will be used to create the pods.
.. attr:: node-attributes
:type: dict
A dictionary of key-value pairs that will be stored with the node data
in ZooKeeper. The keys and values can be any arbitrary string.
.. attr:: labels
:type: list
@ -1789,6 +1807,12 @@ section of the configuration.
A unique name within the provider for this pool of resources.
.. attr:: node-attributes
:type: dict
A dictionary of key-value pairs that will be stored with the node data
in ZooKeeper. The keys and values can be any arbitrary string.
.. attr:: subnet-id
If provided, specifies the subnet to assign to the primary network
@ -2079,6 +2103,12 @@ section of the configuration.
A unique name within the provider for this pool of resources.
.. attr:: node-attributes
:type: dict
A dictionary of key-value pairs that will be stored with the node data
in ZooKeeper. The keys and values can be any arbitrary string.
.. attr:: host-key-checking
:type: bool
:default: True

View File

@ -109,10 +109,11 @@ class OpenshiftProviderConfig(ProviderConfig):
'python-path': str,
}
pool = {
pool = ConfigPool.getCommonSchemaDict()
pool.update({
v.Required('name'): str,
v.Required('labels'): [openshift_label],
}
})
schema = ProviderConfig.getCommonSchemaDict()
schema.update({

View File

@ -17,6 +17,7 @@
import math
import voluptuous as v
from nodepool.driver import ConfigPool
from nodepool.driver.openshift.config import OpenshiftPool
from nodepool.driver.openshift.config import OpenshiftProviderConfig
@ -52,10 +53,11 @@ class OpenshiftPodsProviderConfig(OpenshiftProviderConfig):
'python-path': str,
}
pool = {
pool = ConfigPool.getCommonSchemaDict()
pool.update({
v.Required('name'): str,
v.Required('labels'): [openshift_label],
}
})
schema = OpenshiftProviderConfig.getCommonSchemaDict()
schema.update({

View File

@ -51,6 +51,9 @@ providers:
max-servers: 1
subnet-id: null
security-group-id: null
node-attributes:
key1: value1
key2: value2
labels:
- name: ubuntu1404-ebs-optimized
cloud-image: ubuntu1404
@ -61,6 +64,9 @@ providers:
max-servers: 1
subnet-id: null
security-group-id: null
node-attributes:
key1: value1
key2: value2
labels:
- name: ubuntu1404
cloud-image: ubuntu1404
@ -92,6 +98,9 @@ providers:
subnet-id: null
security-group-id: null
host-key-checking: false
node-attributes:
key1: value1
key2: value2
labels:
- name: ubuntu1404-non-host-key-checking
cloud-image: ubuntu1404
@ -102,6 +111,9 @@ providers:
subnet-id: null
security-group-id: null
public-ip-address: false
node-attributes:
key1: value1
key2: value2
labels:
- name: ubuntu1404-private-ip
cloud-image: ubuntu1404
@ -111,6 +123,9 @@ providers:
max-servers: 1
subnet-id: null
security-group-id: null
node-attributes:
key1: value1
key2: value2
labels:
- name: ubuntu1404-with-tags
cloud-image: ubuntu1404
@ -122,6 +137,9 @@ providers:
max-servers: 1
subnet-id: null
security-group-id: null
node-attributes:
key1: value1
key2: value2
labels:
- name: ubuntu1404-with-name-tag
cloud-image: ubuntu1404

View File

@ -13,6 +13,9 @@ providers:
context: admin-cluster.local
pools:
- name: main
node-attributes:
key1: value1
key2: value2
labels:
- name: kubernetes-namespace
type: namespace

View File

@ -13,6 +13,9 @@ providers:
context: admin-cluster.local
pools:
- name: main
node-attributes:
key1: value1
key2: value2
labels:
- name: openshift-project
type: project

View File

@ -12,6 +12,9 @@ providers:
context: service-account.local
pools:
- name: main
node-attributes:
key1: value1
key2: value2
labels:
- name: pod-fedora
image: docker.io/fedora:28

View File

@ -145,6 +145,8 @@ class TestDriverAws(tests.DBTestCase):
self.assertEqual(node.state, zk.READY)
self.assertIsNotNone(node.launcher)
self.assertEqual(node.connection_type, 'ssh')
self.assertEqual(node.attributes,
{'key1': 'value1', 'key2': 'value2'})
if host_key_checking:
nodescan.assert_called_with(
node.interface_ip,

View File

@ -122,6 +122,8 @@ class TestDriverKubernetes(tests.DBTestCase):
self.assertIsNotNone(node.launcher)
self.assertEqual(node.connection_type, 'kubectl')
self.assertEqual(node.connection_port.get('token'), 'fake-token')
self.assertEqual(node.attributes,
{'key1': 'value1', 'key2': 'value2'})
node.state = zk.DELETING
self.zk.storeNode(node)

View File

@ -120,6 +120,8 @@ class TestDriverOpenshift(tests.DBTestCase):
self.assertEqual(node.connection_type, 'kubectl')
self.assertEqual(node.connection_port.get('token'), 'fake-token')
self.assertEqual(node.python_path, '/usr/bin/python3')
self.assertEqual(node.attributes,
{'key1': 'value1', 'key2': 'value2'})
node.state = zk.DELETING
self.zk.storeNode(node)

View File

@ -103,6 +103,8 @@ class TestDriverOpenshiftPods(tests.DBTestCase):
self.assertIsNotNone(node.launcher)
self.assertEqual(node.connection_type, 'kubectl')
self.assertEqual(node.connection_port.get('token'), 'fake-token')
self.assertEqual(node.attributes,
{'key1': 'value1', 'key2': 'value2'})
node.state = zk.DELETING
self.zk.storeNode(node)