Browse Source

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

The previous change:

Closes-Bug: 1921788
Change-Id: I1ec790fced00a4e973e546a260d28f52ef06fb3a
Signed-off-by: David Sullivan <>
David Sullivan 3 months ago
1 changed files with 48 additions and 0 deletions
  1. +48

+ 48
- 0
controllerconfig/controllerconfig/controllerconfig/upgrades/ View File

@ -24,6 +24,7 @@ import time
import yaml
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
@ -825,6 +826,51 @@ def migrate_hiera_data(from_release, to_release, role=None):
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()
"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",
fec_device = cur.fetchone()
cur.execute("select id from interfaces "
"where forihostid=%s and iftype='ethernet' "
"and sriov_numvfs>0;",
interface = cur.fetchone()
if interface or fec_device:
# There are FEC devices/sriov vfs configured, apply the sriov manifest"Applying sriov/fec manifest")
personality = sysinv_constants.WORKER
classes = [
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)
mgmt_ip, personality, manifest='runtime', runtime=tmpfile)
def upgrade_controller(from_release, to_release):
""" Executed on the release N+1 side upgrade controller-1. """
@ -987,6 +1033,8 @@ def upgrade_controller(from_release, to_release):"Failed to update hiera configuration")
# Remove /etc/kubernetes/admin.conf after it is used to generate
# the hiera data
admin_conf = os.path.join(utils.KUBERNETES_CONF_PATH,