Remove UpdateGraphService feature (#18330)

### Why I did it
Remove UpdateGraphService feature from sonic image. The goal is to simplify the bootup process.

### How I did it
Remove updategraph service and updategraph script.
Update all related services, replace updategraph.service with config-setup.service.

#### How to verify it
Build and install new image, load minigraph and check all the services.
This commit is contained in:
ganglv 2024-03-15 04:12:26 +08:00 committed by GitHub
parent 9da50901c4
commit 9a6d6137a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
39 changed files with 58 additions and 177 deletions

View File

@ -5,8 +5,6 @@
#
# * PLATFORM: Specific platform we wish to build images for.
# * BUILD_NUMBER: Desired version-number to pass to the building-system.
# * ENABLE_DHCP_GRAPH_SERVICE: Enables get-graph service to fetch minigraph files
# through http.
# * ENABLE_ZTP: Enables zero touch provisioning.
# * SHUTDOWN_BGP_ON_START: Sets admin-down state for all bgp peerings after restart.
# * INCLUDE_KUBERNETES: Allows including Kubernetes
@ -523,7 +521,6 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \
BUILD_TIMESTAMP=$(BUILD_TIMESTAMP) \
SONIC_IMAGE_VERSION=$(SONIC_IMAGE_VERSION) \
SLAVE_TAG=$(SLAVE_TAG) \
ENABLE_DHCP_GRAPH_SERVICE=$(ENABLE_DHCP_GRAPH_SERVICE) \
ENABLE_ZTP=$(ENABLE_ZTP) \
INCLUDE_PDE=$(INCLUDE_PDE) \
SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \

View File

@ -1,7 +1,7 @@
[Unit]
Description=DHCP relay container
Requires=updategraph.service
After=updategraph.service swss.service syncd.service teamd.service
Requires=config-setup.service
After=config-setup.service swss.service syncd.service teamd.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

View File

@ -1,7 +1,7 @@
[Unit]
Description=EVENTD container
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
StartLimitIntervalSec=1200

View File

@ -1,7 +1,7 @@
[Unit]
Description=ICCPD container
Requires=updategraph.service swss.service
After=updategraph.service swss.service
Requires=config-setup.service swss.service
After=config-setup.service swss.service
BindsTo=sonic.target
After=sonic.target

View File

@ -1,6 +1,6 @@
[Unit]
Description=MUX Cable Container
Requires=database.service updategraph.service swss.service
Requires=database.service config-setup.service swss.service
After=swss.service interfaces-config.service
BindsTo=sonic.target
After=sonic.target

View File

@ -1,7 +1,7 @@
[Unit]
Description=NAT container
Requires=updategraph.service
After=updategraph.service swss.service syncd.service
Requires=config-setup.service
After=config-setup.service swss.service syncd.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

View File

@ -5,7 +5,7 @@ Requires=opennsl-modules.service
ConditionPathExists=!/usr/bin/swss.sh
{% endif %}
After=updategraph.service
After=config-setup.service
{% if sonic_asic_platform == 'broadcom' %}
After=opennsl-modules.service
{% endif %}

View File

@ -2,8 +2,8 @@
Description=BGP container
Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service
After=database{% if multi_instance == 'true' %}@%i{% endif %}.service
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

View File

@ -1,8 +1,8 @@
[Unit]
Description={{docker_container_name}} service
Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service updategraph.service
Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service config-setup.service
ConditionPathExists=!/usr/share/sonic/hwsku/gearbox_config.json
After=database{% if multi_instance == 'true' %}@%i{% endif %}.service updategraph.service
After=database{% if multi_instance == 'true' %}@%i{% endif %}.service config-setup.service
After=interfaces-config.service
After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service
BindsTo=sonic.target

View File

@ -4,8 +4,8 @@ Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service
After=database{% if multi_instance == 'true' %}@%i{% endif %}.service
After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service
After=syncd{% if multi_instance == 'true' %}@%i{% endif %}.service
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
BindsTo=sonic.target

View File

@ -9,8 +9,8 @@ After=topology.service
{% if sonic_asic_platform == 'broadcom' %}
Requires=opennsl-modules.service
{% endif %}
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

View File

@ -14,8 +14,8 @@ After=opennsl-modules.service
Requires=nps-modules.service
After=nps-modules.service
{% endif %}
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

View File

@ -5,8 +5,8 @@ After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service
Requires=topology.service
After=topology.service
{% endif %}
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

View File

@ -1,7 +1,7 @@
[Unit]
Description=Platform monitor container
Requires=database.service updategraph.service
After=database.service updategraph.service
Requires=database.service config-setup.service
After=database.service config-setup.service
{% if sonic_asic_platform == 'mellanox' %}
After=syncd.service
{% endif %}

View File

@ -1,7 +1,7 @@
[Unit]
Description=Router advertiser container
Requires=updategraph.service
After=updategraph.service swss.service syncd.service
Requires=config-setup.service
After=config-setup.service swss.service syncd.service
Before=ntp-config.service
BindsTo=sonic.target
After=sonic.target

View File

@ -1,7 +1,7 @@
[Unit]
Description=RestAPI container
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

View File

@ -1,8 +1,8 @@
[Unit]
Description=SNMP container
Requires=updategraph.service
Requires=config-setup.service
Requisite=swss.service
After=updategraph.service swss.service syncd.service interfaces-config.service
After=config-setup.service swss.service syncd.service interfaces-config.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

View File

@ -610,18 +610,6 @@ sudo cp $IMAGE_CONFIGS/config-topology/config-topology.service $FILESYSTEM_ROOT_
echo "config-topology.service" | sudo tee -a $GENERATED_SERVICE_FILE
sudo cp $IMAGE_CONFIGS/config-topology/config-topology.sh $FILESYSTEM_ROOT/usr/bin
# Copy updategraph script and service file
j2 files/build_templates/updategraph.service.j2 | sudo tee $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/updategraph.service
sudo cp $IMAGE_CONFIGS/updategraph/updategraph $FILESYSTEM_ROOT/usr/bin/
echo "updategraph.service" | sudo tee -a $GENERATED_SERVICE_FILE
{% if enable_dhcp_graph_service == "y" %}
sudo bash -c "echo enabled=true > $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
sudo bash -c "echo src=dhcp >> $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
sudo bash -c "echo dhcp_as_static=true >> $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
{% else %}
sudo bash -c "echo enabled=false > $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
{% endif %}
# Generate initial SONiC configuration file
j2 files/build_templates/init_cfg.json.j2 | sudo tee $FILESYSTEM_ROOT/etc/sonic/init_cfg.json

View File

@ -1,7 +1,7 @@
[Unit]
Description=TACACS application
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target

View File

@ -1,7 +1,7 @@
[Unit]
Description=Delays tacacs apply until SONiC has started
PartOf=tacacs-config.service
After=updategraph.service
After=config-setup.service
[Timer]
OnUnitActiveSec=0 sec

View File

@ -1,12 +0,0 @@
[Unit]
Description=Update minigraph and set configuration based on minigraph
After=config-setup.service
Requires=config-setup.service
[Service]
Type=oneshot
ExecStart=/usr/bin/updategraph
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

View File

@ -25,7 +25,6 @@
###########################################################################
# Initialize constants
UPDATEGRAPH_CONF=/etc/sonic/updategraph.conf
INIT_CFG_JSON=/etc/sonic/init_cfg.json
CONFIG_DB_JSON=/etc/sonic/config_db.json
CONFIG_DB_PATH=/etc/sonic/
@ -180,24 +179,6 @@ check_system_warm_boot()
fi
}
# Check if updategraph service is administratively enabled
updategraph_is_enabled()
{
rv=1
if [ -e ${UPDATEGRAPH_CONF} ]; then
updategraph_mode=$(grep enabled ${UPDATEGRAPH_CONF} | head -n 1 | cut -f2 -d=)
[ "${updategraph_mode}" = "true" ] && rv=0
fi
return $rv
}
# Disable updategraph admininistratively
disable_updategraph()
{
sed -i "/enabled=/d" ${UPDATEGRAPH_CONF}
echo "enabled=false" >> ${UPDATEGRAPH_CONF}
}
# Check if Zero Touch Provisioning is available and is administratively enabled
ztp_is_enabled()
{
@ -273,18 +254,14 @@ generate_config()
# Create SONiC configuration for first time bootup
# - If ZTP is enabled, ZTP configuraion is created
# - If ZTP is disabled and updategraph is disabled, factory default configuration
# - If ZTP is disabled, factory default configuration
# is created
# - If updategraph is enabled and ZTP is disabled, updategraph initializes
# configuration
do_config_initialization()
{
if ! updategraph_is_enabled ; then
if ! ztp_is_enabled ; then
echo "No configuration detected, generating factory default configuration..."
generate_config factory ${CONFIG_DB_JSON}
reload_configdb ${CONFIG_DB_JSON}
fi
if ! ztp_is_enabled ; then
echo "No configuration detected, generating factory default configuration..."
generate_config factory ${CONFIG_DB_JSON}
reload_configdb ${CONFIG_DB_JSON}
fi
if ztp_is_enabled ; then
@ -376,7 +353,6 @@ do_config_migration()
if [ x"${WARM_BOOT}" == x"true" ]; then
echo "Warm reboot detected..."
disable_updategraph
do_db_migration
rm -f /tmp/pending_config_migration
exit 0
@ -384,14 +360,10 @@ do_config_migration()
echo "Use config_db.json from old system..."
reload_configdb
do_db_migration
# Disable updategraph
disable_updategraph
elif [ -r ${MINGRAPH_FILE} ]; then
echo "Use minigraph.xml from old system..."
reload_minigraph
do_db_migration
# Disable updategraph
disable_updategraph
else
echo "Didn't found neither config_db.json nor minigraph.xml ..."
fi

View File

@ -1,7 +1,7 @@
[Unit]
Description=Update CoPP configuration
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target

View File

@ -1,7 +1,7 @@
[Unit]
Description=Update hostname based on configdb
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target

View File

@ -1,7 +1,7 @@
[Unit]
Description=Update interfaces configuration
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target

View File

@ -1,7 +1,7 @@
[Unit]
Description=Update logrotate configuration
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
[Service]
Type=oneshot

View File

@ -1,7 +1,7 @@
[Unit]
Description=Update NTP configuration
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
Before=ntp.service

View File

@ -254,7 +254,7 @@ if [ -f $FIRST_BOOT_FILE ]; then
fi
# Try to take old configuration saved during installation
# and create a flag in /tmp/ to let updategraph service know
# and create a flag in /tmp/
if [ -d /host/old_config ]; then
mv -f /host/old_config /etc/sonic/
rm -rf /etc/sonic/old_config/old_config
@ -275,7 +275,6 @@ if [ -f $FIRST_BOOT_FILE ]; then
[ -f /host/migration/snmp.yml ] && mv /host/migration/snmp.yml /etc/sonic/old_config/
[ -f /host/migration/golden_config_db.json ] && mv /host/migration/golden_config_db.json /etc/sonic/old_config/
touch /tmp/pending_config_migration
[ -f /etc/sonic/updategraph.conf ] && sed -i -e "s/enabled=false/enabled=true/g" /etc/sonic/updategraph.conf
else
touch /tmp/pending_config_initialization
fi

View File

@ -1,7 +1,7 @@
[Unit]
Description=Update DNS configuration
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
StartLimitIntervalSec=0

View File

@ -1,7 +1,7 @@
[Unit]
Description=Update rsyslog configuration
Requires=updategraph.service
After=updategraph.service
Requires=config-setup.service
After=config-setup.service
BindsTo=sonic.target
After=sonic.target
After=interfaces-config.service

View File

@ -28,7 +28,6 @@ etc/sonic/old_config/.*
etc/sonic/port_config.json
etc/sonic/snmp.yml
etc/sonic/sonic-environment
etc/sonic/updategraph.conf
etc/ssh/ssh_host_rsa_key.pub
etc/ssh/ssh_host_rsa_key
etc/subgid

View File

@ -1,7 +1,7 @@
[Unit]
Description=SONiC system health monitor
Requires=database.service updategraph.service
After=database.service updategraph.service
Requires=database.service config-setup.service
After=database.service config-setup.service
[Service]
ExecStart=/usr/local/bin/healthd

View File

@ -1,51 +0,0 @@
#!/bin/bash
# read SONiC immutable variables
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment
if [ ! -f /etc/sonic/updategraph.conf ]; then
echo "No updategraph.conf found, generating a default one."
echo "enabled=false" >/etc/sonic/updategraph.conf
fi
. /etc/sonic/updategraph.conf
if [ "$enabled" = "reload_only" ]; then
echo "reload_only will not be supported in file updategraph.conf"
exit 1
fi
if [ "$enabled" != "true" ]; then
echo "Disabled in updategraph.conf. Skipping graph update."
exit 0
fi
# If ZTP package is available and enabled, use ZTP to download and load the graph.
if [ -e /usr/bin/ztp ] && [ "$(ztp status -c)" != "0:DISABLED" ]; then
echo "ZTP is available and enabled. Skipping graph update."
exit 0
fi
# "`cat /tmp/dhcp_graph_url`" is always "N/A"
echo "No graph_url option in DHCP response. Skipping graph update and generating an empty configuration."
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
if [ -f /etc/sonic/minigraph.xml ]; then
sonic-cfggen -H -m /etc/sonic/minigraph.xml --preset empty > /tmp/device_meta.json
else
PRESET=(`head -n 1 /usr/share/sonic/device/$PLATFORM/default_sku`)
sonic-cfggen -H -k ${PRESET[0]} --preset empty > /tmp/device_meta.json
fi
if [ -f /etc/sonic/init_cfg.json ]; then
sonic-cfggen -j /tmp/device_meta.json -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json
else
cp -f /tmp/device_meta.json /etc/sonic/config_db.json
fi
sonic-db-cli CONFIG_DB FLUSHDB
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
if [ "$dhcp_as_static" = "true" ]; then
sed -i "/enabled=/d" /etc/sonic/updategraph.conf
echo "enabled=false" >> /etc/sonic/updategraph.conf
fi
exit 0

View File

@ -48,12 +48,6 @@ DEFAULT_USERNAME = admin
# DEFAULT_PASSWORD - default password for installer build
DEFAULT_PASSWORD = YourPaSsWoRd
# ENABLE_DHCP_GRAPH_SERVICE - specify the source of minigraph to generate configuration file.
# If set to y SONiC will get the minigraph from graph service. Graph service URL need to be
# passed through DHCP option 225.
# If not set (default behavior) the default minigraph built into the image will be used.
# ENABLE_DHCP_GRAPH_SERVICE = y
# ENABLE_ZTP - installs Zero Touch Provisioning support.
# ENABLE_ZTP = y

View File

@ -23,7 +23,7 @@ $(DOCKER_DHCP_RELAY)_VERSION = 1.0.0
$(DOCKER_DHCP_RELAY)_PACKAGE_NAME = dhcp-relay
$(DOCKER_DHCP_RELAY)_PACKAGE_DEPENDS = database^1.0.0
$(DOCKER_DHCP_RELAY)_SERVICE_REQUIRES = updategraph
$(DOCKER_DHCP_RELAY)_SERVICE_REQUIRES = config-setup
$(DOCKER_DHCP_RELAY)_SERVICE_AFTER = swss syncd teamd
$(DOCKER_DHCP_RELAY)_SERVICE_BEFORE = ntp-config
$(DOCKER_DHCP_RELAY)_SERVICE_DEPENDENT_OF = swss

View File

@ -38,7 +38,7 @@ $(DOCKER_DHCP_SERVER)_CONTAINER_NAME = dhcp_server
$(DOCKER_DHCP_SERVER)_VERSION = 1.0.0
$(DOCKER_DHCP_SERVER)_PACKAGE_NAME = dhcp-server
$(DOCKER_MACSEC)_SERVICE_REQUIRES = updategraph
$(DOCKER_MACSEC)_SERVICE_REQUIRES = config-setup
$(DOCKER_MACSEC)_SERVICE_AFTER = swss syncd
$(DOCKER_DHCP_SERVER)_CONTAINER_PRIVILEGED = false

View File

@ -21,9 +21,6 @@ $(DOCKER_EVENTD)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON)
$(DOCKER_EVENTD)_VERSION = 1.0.0
$(DOCKER_EVENTD)_PACKAGE_NAME = eventd
$(DOCKER_DHCP)_SERVICE_REQUIRES = updategraph
$(DOCKER_DHCP)_SERVICE_AFTER = database
SONIC_DOCKER_IMAGES += $(DOCKER_EVENTD)
ifeq ($(INCLUDE_SYSTEM_EVENTD), y)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_EVENTD)

View File

@ -44,7 +44,7 @@ $(DOCKER_MACSEC)_CONTAINER_VOLUMES += /etc/sonic:/etc/sonic:ro
$(DOCKER_MACSEC)_CONTAINER_VOLUMES += /etc/timezone:/etc/timezone:ro
$(DOCKER_MACSEC)_CONTAINER_VOLUMES += /host/warmboot:/var/warmboot
$(DOCKER_MACSEC)_SERVICE_REQUIRES = updategraph
$(DOCKER_MACSEC)_SERVICE_REQUIRES = config-setup
$(DOCKER_MACSEC)_SERVICE_AFTER = swss syncd
$(DOCKER_MACSEC)_CLI_CONFIG_PLUGIN = /cli/config/plugins/macsec.py

View File

@ -397,7 +397,6 @@ $(info "SECURE_UPGRADE_SIGNING_CERT" : "$(SECURE_UPGRADE_SIGNING_CERT)")
$(info "SECURE_UPGRADE_PROD_SIGNING_TOOL": "$(SECURE_UPGRADE_PROD_SIGNING_TOOL)")
$(info "SECURE_UPGRADE_PROD_TOOL_ARGS" : "$(SECURE_UPGRADE_PROD_TOOL_ARGS)")
$(info "ONIE_IMAGE_PART_SIZE" : "$(ONIE_IMAGE_PART_SIZE)")
$(info "ENABLE_DHCP_GRAPH_SERVICE" : "$(ENABLE_DHCP_GRAPH_SERVICE)")
$(info "SHUTDOWN_BGP_ON_START" : "$(SHUTDOWN_BGP_ON_START)")
$(info "ENABLE_PFCWD_ON_START" : "$(ENABLE_PFCWD_ON_START)")
$(info "SONIC_BUFFER_MODEL" : "$(SONIC_BUFFER_MODEL)")
@ -1412,7 +1411,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export sonicadmin_user="$(USERNAME)"
export sonic_asic_platform="$(patsubst %-$(CONFIGURED_ARCH),%,$(CONFIGURED_PLATFORM))"
export enable_organization_extensions="$(ENABLE_ORGANIZATION_EXTENSIONS)"
export enable_dhcp_graph_service="$(ENABLE_DHCP_GRAPH_SERVICE)"
export enable_ztp="$(ENABLE_ZTP)"
export include_teamd="$(INCLUDE_TEAMD)"
export include_router_advertiser="$(INCLUDE_ROUTER_ADVERTISER)"