Run SRIOV manifest during controller-1 migration

To address another issue we blocked manifests from applying on a
controller with a different version from the active controller. This
blocks the sriov manifest from running on controller-1 after it has been
upgraded to N+1. To address this the data migration will check if
controller-1 has sriov interfaces configured and apply the manifest if
necessary.

The previous change:
https://review.opendev.org/c/starlingx/config/+/766637

Closes-Bug: 1921788
Change-Id: I1ec790fced00a4e973e546a260d28f52ef06fb3a
Signed-off-by: David Sullivan <david.sullivan@windriver.com>
This commit is contained in:
David Sullivan 2021-03-28 14:02:32 -05:00
parent 61b3ffbfc9
commit d225a0217b
1 changed files with 48 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import time
import yaml import yaml
from sysinv.common import constants as sysinv_constants from sysinv.common import constants as sysinv_constants
from sysinv.puppet import common as puppet_common
# WARNING: The controller-1 upgrade is done before any puppet manifests # WARNING: The controller-1 upgrade is done before any puppet manifests
@ -825,6 +826,51 @@ def migrate_hiera_data(from_release, to_release, role=None):
yaml.dump(static_config, yaml_file, default_flow_style=False) yaml.dump(static_config, yaml_file, default_flow_style=False)
def apply_sriov_config(db_credentials):
# If controller-1 has any FEC devices or sriov vfs configured, apply the
# sriov runtime manifest. We can't apply it from controller-0 during the
# host-unlock process as controller-1 is running the new release.
database = 'sysinv'
username = db_credentials[database]['username']
password = db_credentials[database]['password']
# psycopg2 can connect with the barbican string eg postgresql:// ...
connection_string = DB_BARBICAN_CONNECTION_FORMAT % (
username, password, database)
conn = psycopg2.connect(connection_string)
cur = conn.cursor()
cur.execute(
"select id, mgmt_ip from i_host where hostname='controller-1';")
host = cur.fetchone()
host_id = host[0]
mgmt_ip = host[1]
cur.execute("select id from pci_devices "
"where sriov_numvfs > 0 and host_id=%s",
(host_id,))
fec_device = cur.fetchone()
cur.execute("select id from interfaces "
"where forihostid=%s and iftype='ethernet' "
"and sriov_numvfs>0;",
(host_id,))
interface = cur.fetchone()
if interface or fec_device:
# There are FEC devices/sriov vfs configured, apply the sriov manifest
LOG.info("Applying sriov/fec manifest")
personality = sysinv_constants.WORKER
classes = [
'platform::interfaces::sriov::runtime',
'platform::devices::fpga::fec::runtime'
]
config = {'classes': classes}
# create a temporary file to hold the runtime configuration values
fd, tmpfile = tempfile.mkstemp(suffix='.yaml')
with open(tmpfile, 'w') as f:
yaml.dump(config, f, default_flow_style=False)
puppet_common.puppet_apply_manifest(
mgmt_ip, personality, manifest='runtime', runtime=tmpfile)
os.close(fd)
os.remove(tmpfile)
def upgrade_controller(from_release, to_release): def upgrade_controller(from_release, to_release):
""" Executed on the release N+1 side upgrade controller-1. """ """ Executed on the release N+1 side upgrade controller-1. """
@ -987,6 +1033,8 @@ def upgrade_controller(from_release, to_release):
LOG.info("Failed to update hiera configuration") LOG.info("Failed to update hiera configuration")
raise raise
apply_sriov_config(db_credentials)
# Remove /etc/kubernetes/admin.conf after it is used to generate # Remove /etc/kubernetes/admin.conf after it is used to generate
# the hiera data # the hiera data
admin_conf = os.path.join(utils.KUBERNETES_CONF_PATH, admin_conf = os.path.join(utils.KUBERNETES_CONF_PATH,