Fix deprecated code

This PS replaces deprecared module pkg_resources,
also fixes the schema validation by adding
specific schema draft to choose in order to
prevent the processor to fall back to use the
latest draft that may potentially cause issues.

Also switched to quay.io/airshipit for base ubuntu
image

Change-Id: I687ef267ee3b027e80815e8852c8edcab5b5b727
This commit is contained in:
Sergiy Markin 2024-12-23 04:16:41 +00:00
parent db33bcbe73
commit 108a3c1ee4
21 changed files with 29 additions and 35 deletions

View File

@ -18,9 +18,9 @@
# 429 Too Many Requests - Server message: too many requests:
# You have reached your pull rate limit.
# You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
ARG FROM=public.ecr.aws/docker/library/ubuntu:jammy
ARG FROM=quay.io/airshipit/ubuntu:jammy
FROM public.ecr.aws/docker/library/golang:1.23.1-bullseye as baclient_builder
FROM quay.io/airshipit/golang:1.23.1-bullseye as baclient_builder
COPY ./tools/baclient_build.sh /tmp/drydock/
COPY ./go /tmp/drydock/go

View File

@ -241,7 +241,7 @@ class BootactionUtils(object):
challenges=['Bootaction-Key'])
if ba_ctx['identity_key'] != bytes.fromhex(identity_key):
logger.warn(
logger.warning(
"Forbidding boot action access - node: %s, identity_key: %s, req header: %s"
% (ba_ctx['node_name'], str(
ba_ctx['identity_key']), str(bytes.fromhex(identity_key))))

View File

@ -203,7 +203,7 @@ class PromenadeSession(object):
elif timeout is not None:
raise ValueError("Non integer timeout value")
except ValueError:
self.logger.warn(
self.logger.warning(
"Timeout value must be a tuple of integers or a "
"single integer. Proceeding with values of "
"(%s, %s)", connect_timeout, read_timeout)

View File

@ -631,7 +631,7 @@ class Machines(model_base.ResourceCollectionBase):
node_oob_ip = node_model.get_network_address(node_oob_network)
if node_oob_ip is None:
self.logger.warn("Node model missing OOB IP address")
self.logger.warning("Node model missing OOB IP address")
raise ValueError('Node model missing OOB IP address')
maas_node = self.find_node_with_power_address(node_oob_ip)

View File

@ -204,7 +204,7 @@ class DrydockSession(object):
elif timeout is not None:
raise ValueError("Non integer timeout value")
except ValueError:
self.logger.warn(
self.logger.warning(
"Timeout value must be a tuple of integers or a "
"single integer. Proceeding with values of "
"(%s, %s)", connect_timeout, read_timeout)

View File

@ -97,7 +97,7 @@ class Ingester(object):
status, design_items = self.registered_plugin.ingest_data(
content=design_blob, **kwargs)
except errors.IngesterError as vex:
self.logger.warn(
self.logger.warning(
"Ingester:ingest_data - Unexpected error processing data - %s"
% (str(vex)))
return None, None

View File

@ -17,7 +17,7 @@ import yaml
import logging
import jsonschema
import os
import pkg_resources
from importlib.resources import files
import copy
import hashlib
@ -717,8 +717,7 @@ class DeckhandIngester(IngesterPlugin):
f.close()
def _get_schema_dir(self):
return pkg_resources.resource_filename('drydock_provisioner',
'schemas')
return str(files('drydock_provisioner') / 'schemas')
# Mapping of handlers for different document kinds
v1_doc_handlers = {

View File

@ -18,7 +18,7 @@ import logging
import base64
import jsonschema
import os
import pkg_resources
from importlib.resources import files
import drydock_provisioner.objects.fields as hd_fields
@ -648,8 +648,7 @@ class YamlIngester(IngesterPlugin):
f.close()
def _get_schema_dir(self):
return pkg_resources.resource_filename('drydock_provisioner',
'schemas')
return str(files('drydock_provisioner') / 'schemas')
# Mapping of handlers for different document kinds
v1_doc_handlers = {

View File

@ -6,7 +6,7 @@ metadata:
labels:
application: drydock
data:
$schema: 'http://json-schema.org/schema#'
$schema: 'http://json-schema.org/draft-04/schema#'
id: 'http://att.com/att-comdev/drydock/baremetalNode.yaml'
type: 'object'
properties:

View File

@ -6,7 +6,7 @@ metadata:
labels:
application: drydock
data:
$schema: 'http://json-schema.org/schema#'
$schema: 'http://json-schema.org/draft-04/schema#'
id: 'http://att.com/att-comdev/drydock/bootaction.yaml'
type: 'object'
additionalProperties: false

View File

@ -6,7 +6,7 @@ metadata:
labels:
application: drydock
data:
$schema: 'http://json-schema.org/schema#'
$schema: 'http://json-schema.org/draft-04/schema#'
id: 'http://att.com/att-comdev/drydock/hardwareProfile.yaml'
type: 'object'
properties:

View File

@ -6,7 +6,7 @@ metadata:
labels:
application: drydock
data:
$schema: 'http://json-schema.org/schema#'
$schema: 'http://json-schema.org/draft-04/schema#'
id: 'http://att.com/att-comdev/drydock/hostProfile.yaml'
type: 'object'
properties:

View File

@ -6,7 +6,7 @@ metadata:
labels:
application: drydock
data:
$schema: 'http://json-schema.org/schema#'
$schema: 'http://json-schema.org/draft-04/schema#'
id: 'http://att.com/att-comdev/drydock/network.yaml'
type: 'object'
properties:

View File

@ -6,7 +6,7 @@ metadata:
labels:
application: drydock
data:
$schema: 'http://json-schema.org/schema#'
$schema: 'http://json-schema.org/draft-04/schema#'
id: 'http://att.com/att-comdev/drydock/networkLink.yaml'
type: 'object'
properties:

View File

@ -6,7 +6,7 @@ metadata:
labels:
application: drydock
data:
$schema: 'http://json-schema.org/schema#'
$schema: 'http://json-schema.org/draft-04/schema#'
id: 'http://att.com/att-comdev/drydock/rack.yaml'
type: 'object'
properties:

View File

@ -6,7 +6,7 @@ metadata:
labels:
application: drydock
data:
$schema: 'http://json-schema.org/schema#'
$schema: 'http://json-schema.org/draft-04/schema#'
id: 'http://att.com/att-comdev/drydock/region.yaml'
type: 'object'
properties:

View File

@ -49,7 +49,7 @@ class DrydockState(object):
max_overflow=config.config_mgr.conf.database.pool_overflow,
pool_timeout=config.config_mgr.conf.database.pool_timeout,
pool_recycle=config.config_mgr.conf.database.connection_recycle)
self.db_metadata = MetaData(bind=self.db_engine)
self.db_metadata = MetaData()
self.tasks_tbl = tables.Tasks(self.db_metadata)
self.result_message_tbl = tables.ResultMessage(self.db_metadata)

View File

@ -1,5 +1,5 @@
pytest >= 3.0
pytest-cov==4.0.0
pytest
pytest-cov
pytest-mock

View File

@ -95,7 +95,8 @@ def mock_process_node_filter(mocker, deckhand_orchestrator):
n2.site = 'test2'
mock_results = [n1, n2]
with mocker.patch(
'drydock_provisioner.orchestrator.orchestrator.Orchestrator.process_node_filter',
mocker.MagicMock(return_value=mock_results)):
yield
mocker.patch(
'drydock_provisioner.orchestrator.orchestrator.Orchestrator.process_node_filter',
return_value=mock_results
)
yield

View File

@ -53,7 +53,6 @@ class TestClientSession(object):
sess = DrydockSession("testdrydock")
result = sess.get('bogus')
assert result.status_code == 200
return True
@responses.activate
def test_get_with_timeout(self):
@ -62,7 +61,6 @@ class TestClientSession(object):
sess = DrydockSession("testdrydock")
result = sess.get('bogus', timeout=(60, 60))
assert result.status_code == 200
return True
post_responses_inp = {
'method': 'POST',
@ -79,7 +77,6 @@ class TestClientSession(object):
sess = DrydockSession("testdrydock")
result = sess.post('bogus')
assert result.status_code == 200
return True
@responses.activate
def test_post_with_timeout(self):
@ -88,7 +85,6 @@ class TestClientSession(object):
sess = DrydockSession("testdrydock")
result = sess.post('bogus', timeout=(60, 60))
assert result.status_code == 200
return True
def test_timeout(self):
"""Tests the _timeout method"""

View File

@ -1,7 +1,7 @@
import pylibyaml # noqa: F401 # patch pyyaml to use libyaml bindings
import yaml
import jsonschema
import pkg_resources
from importlib.resources import files
import os
import shutil
import pytest
@ -18,8 +18,7 @@ class BaseSchemaValidationTest(object):
:param expect_failure: should the validation pass or fail.
:param input_files: pytest fixture used to access the test input files
:param input: test input yaml doc filename"""
schema_dir = pkg_resources.resource_filename('drydock_provisioner',
'schemas')
schema_dir = str(files('drydock_provisioner') / 'schemas')
schema_filename = os.path.join(schema_dir, schema)
schema_file = open(schema_filename, 'r')
schema = yaml.safe_load(schema_file)