Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonic profiling docker features #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,20 @@ endif
rules/config.user:
$(Q)echo -n ""

include rules/config
# Check if SONIC_PROFILE is set
ifeq ($(SONIC_PROFILE),)
CONFIG_FILE := rules/config
$(info SONIC_PROFILE is not set. Using default configuration.)
else
CONFIG_FILE := rules/config.$(SONIC_PROFILE)
ifeq ($(wildcard $(CONFIG_FILE)),)
CONFIG_FILE := rules/config
$(info Configuration file $(CONFIG_FILE) does not exist. Using default configuration.)
endif
endif

# Import the configuration file
include ${CONFIG_FILE}
-include rules/config.user
include rules/sonic-fips.mk

Expand Down
156 changes: 133 additions & 23 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,140 @@
("snmp", "enabled", true, "enabled"),
("swss", "enabled", false, "enabled"),
("syncd", "enabled", false, "enabled")] %}
{%- if include_router_advertiser == "y" %}{% do features.append(("radv", "enabled", false, "enabled")) %}{% endif %}
{%- if include_teamd == "y" %}{% do features.append(("teamd", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] %}disabled{% else %}enabled{% endif %}", false, "enabled")) %}{% endif %}
{% do features.append(("dhcp_relay", "{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] is not in ['ToRRouter', 'EPMS', 'MgmtTsToR', 'MgmtToRRouter', 'BmcMgmtToRRouter']) %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}
{%- if include_dhcp_server == "y" %}{% do features.append(("dhcp_server", "disabled", false, "enabled")) %}{% endif %}
{%- if sonic_asic_platform == "vs" %}{% do features.append(("gbsyncd", "enabled", false, "enabled")) %}{% endif %}
{%- if include_iccpd == "y" %}{% do features.append(("iccpd", "disabled", false, "enabled")) %}{% endif %}
{%- if include_mgmt_framework == "y" %}{% do features.append(("mgmt-framework", "enabled", true, "enabled")) %}{% endif %}
{%- if include_mux == "y" %}{% do features.append(("mux", "{% if 'subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR' %}enabled{% else %}always_disabled{% endif %}", false, "enabled")) %}{% endif %}
{%- if include_nat == "y" %}{% do features.append(("nat", "disabled", false, "enabled")) %}{% endif %}
{%- if include_p4rt == "y" %}{% do features.append(("p4rt", "disabled", false, "enabled")) %}{% endif %}
{%- if include_restapi == "y" and BUILD_REDUCE_IMAGE_SIZE == "y" and sonic_asic_platform == "broadcom" %}
{% do features.append(("restapi", "{% if (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] is not in ['LeafRouter', 'BackEndLeafRouter']) %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}
{%- if include_router_advertiser == "y" %}
{% do features.append((
"radv",
"enabled" if enable_router_advertiser == "y" else "disabled",
true if delay_router_advertiser == "y" else false,
"enabled" if autorestart_router_advertiser == "y" else "disabled"
)) %}
{% endif %}
{%- if include_teamd == "y" %}
{% do features.append((
"teamd",
"{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] %}disabled{% else %}enabled{% endif %}",
true if delay_teamd == "y" else false,
"enabled" if autorestart_teamd == "y" else "disabled"
)) %}
{% endif %}
{% do features.append((
"dhcp_relay",
"{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] is not in ['ToRRouter', 'EPMS', 'MgmtTsToR', 'MgmtToRRouter', 'BmcMgmtToRRouter']) %}enabled{% else %}disabled{% endif %}",
false,
"enabled"
)) %}
{%- if include_dhcp_server == "y" %}
{% do features.append((
"dhcp_server",
"enabled" if enable_dhcp_server == "y" else "disabled",
true if delay_dhcp_server == "y" else false,
"enabled" if autorestart_dhcp_server == "y" else "disabled"
)) %}
{% endif %}
{%- if sonic_asic_platform == "vs" %}
{% do features.append((
"gbsyncd",
"enabled",
false,
"enabled"
)) %}
{% endif %}
{%- if include_iccpd == "y" %}
{% do features.append((
"iccpd",
"enabled" if enable_iccpd == "y" else "disabled",
false if delay_iccpd == "y" else true,
"enabled" if autorestart_iccpd == "y" else "disabled"
)) %}
{% endif %}
{%- if include_mgmt_framework == "y" %}
{% do features.append((
"mgmt-framework",
"enabled" if enable_mgmt_framework == "y" else "disabled",
true if delay_mgmt_framework == "y" else false,
"enabled" if autorestart_mgmt_framework == "y" else "disabled"
)) %}
{% endif %}
{%- if include_mux == "y" %}
{% do features.append((
"mux",
"{% if 'subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR' %}enabled{% else %}always_disabled{% endif %}",
false,
"enabled"
)) %}
{% endif %}
{%- if include_nat == "y" %}
{% do features.append((
"nat",
"enabled" if enable_nat == "y" else "disabled",
true if delay_nat == "y" else false,
"enabled" if autorestart_nat == "y" else "disabled"
)) %}
{% endif %}
{%- if include_p4rt == "y" %}
{% do features.append((
"p4rt",
"enabled" if enable_p4rt == "y" else "disabled",
true if delay_p4rt == "y" else false,
"enabled" if autorestart_p4rt == "y" else "disabled"
)) %}
{% endif %}
{%- if include_restapi == "y" and build_reduce_image_size == "y" and sonic_asic_platform == "broadcom" %}
{% do features.append((
"restapi",
"{% if (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] is not in ['LeafRouter', 'BackEndLeafRouter']) %}enabled{% else %}disabled{% endif %}",
false,
"enabled"
)) %}
{%- elif include_restapi == "y" %}
{% do features.append(("restapi", "enabled", false, "enabled")) %}
{%- endif %}
{%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", true, "enabled")) %}{% endif %}
{%- if include_macsec == "y" %}{% do features.append(("macsec", "{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' and DEVICE_RUNTIME_METADATA['MACSEC_SUPPORTED'] %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}{% endif %}
{%- if include_system_gnmi == "y" %}{% do features.append(("gnmi", "enabled", true, "enabled")) %}{% endif %}
{%- if include_system_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %}
{%- if include_system_eventd == "y" and BUILD_REDUCE_IMAGE_SIZE == "y" %}
{% do features.append(("eventd","disabled", false, "enabled")) %}
{%- elif include_system_eventd == "y" %}
{% do features.append(("eventd", "enabled", false, "enabled")) %}
{% do features.append((
"restapi",
"enabled" if enable_restapi == "y" else "disabled",
true if delay_restapi == "y" else false,
"enabled" if autorestart_restapi == "y" else "disabled"
)) %}
{%- endif %}
{%- if include_sflow == "y" %}
{% do features.append((
"sflow",
"disabled",
true,
"enabled"
)) %}
{% endif %}
{%- if include_macsec == "y" %}
{% do features.append((
"macsec",
"{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' and DEVICE_RUNTIME_METADATA['MACSEC_SUPPORTED'] %}enabled{% else %}disabled{% endif %}",
true if delay_macsec == "y" else false,
"enabled" if autorestart_macsec == "y" else "disabled"
)) %}
{% endif %}
{%- if include_system_gnmi == "y" %}
{% do features.append((
"gnmi",
"enabled" if enable_system_gnmi == "y" else "disabled",
true if delay_system_gnmi == "y" else false,
"enabled" if autorestart_system_gnmi == "y" else "disabled"
)) %}
{% endif %}
{%- if include_system_telemetry == "y" %}
{% do features.append((
"telemetry",
"enabled" if enable_system_telemetry == "y" else "disabled",
true if delay_system_telemetry == "y" else false,
"enabled" if autorestart_system_telemetry == "y" else "disabled"
)) %}
{% endif %}
{%- if include_system_eventd == "y" %}
{% do features.append((
"eventd",
"disabled" if build_reduce_image_size == "y" else ("enabled" if enable_system_eventd == "y" else "disabled"),
true if delay_system_eventd == "y" else false,
"enabled" if autorestart_system_eventd == "y" else "disabled"
)) %}
{% endif %}

"FEATURE": {
{# delayed field if set, will start the feature systemd .timer unit instead of .service unit #}
{%- for feature, state, delayed, autorestart in features %}
Expand Down Expand Up @@ -214,4 +324,4 @@
"vrf": "default"
}
}
}
}
54 changes: 53 additions & 1 deletion rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,72 @@ DEFAULT_VS_PREPARE_MEM = yes

# INCLUDE_SYSTEM_GNMI - build docker-sonic-gnmi for system gnmi support
INCLUDE_SYSTEM_GNMI = y
ENABLE_SYSTEM_GNMI = y
DELAY_SYSTEM_GNMI = y
AUTORESTART_SYSTEM_GNMI = y

# INCLUDE_SYSTEM_BMP - build docker-sonic-bmp for system bmp support
INCLUDE_SYSTEM_BMP = y

# INCLUDE_SYSTEM_EVENTD - build docker-eventd for system eventd support
INCLUDE_SYSTEM_EVENTD = y
ENABLE_SYSTEM_EVENTD = y
DELAY_SYSTEM_EVENTD = n
AUTORESTART_SYSTEM_EVENTD = y

# INCLUDE_SYSTEM_TELEMETRY - build docker-sonic-telemetry for system telemetry support
INCLUDE_SYSTEM_TELEMETRY = n
INCLUDE_SYSTEM_TELEMETRY = y
ENABLE_SYSTEM_TELEMETRY = y
DELAY_SYSTEM_TELEMETRY = y
AUTORESTART_SYSTEM_TELEMETRY = y

# INCLUDE_ICCPD - build docker-iccpd for mclag support
INCLUDE_ICCPD = n
ENABLE_ICCPD = n
DELAY_ICCPD = n
AUTORESTART_ICCPD = y

# INCLUDE_SFLOW - build docker-sflow for sFlow support
INCLUDE_SFLOW = y
ENABLE_SFLOW = n
DELAY_SFLOW = y
AUTORESTART_SFLOW = y

# INCLUDE_MGMT_FRAMEWORK - build docker-sonic-mgmt-framework for CLI and REST server support
INCLUDE_MGMT_FRAMEWORK = y
ENABLE_MGMT_FRAMEWORK = y
DELAY_MGMT_FRAMEWORK = y
AUTORESTART_MGMT_FRAMEWORK = y

# ENABLE_HOST_SERVICE_ON_START - enable sonic-host-server for mgmt-framework and/or
# gnmi containers to access host functionality by default
ENABLE_HOST_SERVICE_ON_START = y

# INCLUDE_RESTAPI - build docker-sonic-restapi for configuring the switch using REST APIs
INCLUDE_RESTAPI ?= n
ENABLE_RESTAPI = y
DELAY_RESTAPI = n
AUTORESTART_RESTAPI = y

# INCLUDE_NAT - build docker-nat for nat support
INCLUDE_NAT = y
ENABLE_NAT = n
DELAY_NAT = n
AUTORESTART_NAT = y

# INCLUDE_DHCP_RELAY - build and install dhcp-relay package
# TODO: In init_cfg.json.j2,this docker is not surrounded by an if
INCLUDE_DHCP_RELAY = y
ENABLE_DHCP_RELAY = y
DELAY_DHCP_RELAY = y
AUTORESTART_DHCP_RELAY = y

# INCLUDE_DHCP_SERVER - build and install dhcp-server package
# TODO: Not added to SONIC_INSTALL_DOCKER_IMAGES in makefile
INCLUDE_DHCP_SERVER ?= n
ENABLE_DHCP_SERVER = n
DELAY_DHCP_SERVER = n
AUTORESTART_DHCP_SERVER = y

# Conditionally enable DHCP_SERVER when SMARTSWITCH is set to 1
ifeq ($(SMARTSWITCH), 1)
Expand All @@ -165,6 +197,9 @@ endif

# INCLUDE_P4RT - build docker-p4rt for P4RT support
INCLUDE_P4RT = n
ENABLE_P4RT = n
DELAY_P4RT = n
AUTORESTART_P4RT = y

# ENABLE_AUTO_TECH_SUPPORT - Enable the configuration for event-driven techsupport & coredump mgmt feature
ENABLE_AUTO_TECH_SUPPORT = y
Expand All @@ -177,16 +212,30 @@ ENABLE_AUTO_TECH_SUPPORT = y
ENABLE_NATIVE_WRITE = y

# INCLUDE_MACSEC - build docker-macsec for macsec support
# TODO: no SONIC_INSTALL_DOCKER_IMAGES in makefile
INCLUDE_MACSEC = y
ENABLE_MACSEC = y
DELAY_MACSEC = y
AUTORESTART_MACSEC = y

# INCLUDE_GBSYNCD - build docker-gbsyncd-* for gearbox support
# TODO: only built for VS, no makefile?
INCLUDE_GBSYNCD ?= y
ENABLE_GBSYNCD = y
DELAY_GBSYNCD = y
AUTORESTART_GBSYNCD = y

# INCLUDE_TEAMD - build docker-teamd for LAG protocol support
INCLUDE_TEAMD ?= y
ENABLE_TEAMD = y
DELAY_TEAMD = n
AUTORESTART_TEAMD = y

# INCLUDE_ROUTER_ADVERTISER - build docker-router-advertiser for router advertisements support
INCLUDE_ROUTER_ADVERTISER ?= y
ENABLE_ROUTER_ADVERTISER = y
DELAY_ROUTER_ADVERTISER = n
AUTORESTART_ROUTER_ADVERTISER = y

# INCLUDE_KUBERNETES - if set to y kubernetes packages are installed to be able to
# run as worker node in kubernetes cluster.
Expand Down Expand Up @@ -298,6 +347,9 @@ BUILD_MULTIASIC_KVM = n

# INCLUDE_MUX - build docker-mux for dual ToR (Gemini)
INCLUDE_MUX = y
ENABLE_SYSTEM_GNMI = y
DELAY_SYSTEM_GNMI = y
AUTORESTART_SYSTEM_GNMI = y

# ENABLE_ASAN - enable address sanitizer
ENABLE_ASAN ?= n
Expand Down
4 changes: 2 additions & 2 deletions rules/docker-dhcp-server.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ $(DOCKER_DHCP_SERVER)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON)
$(DOCKER_DHCP_SERVER)_PYTHON_WHEELS += $(SONIC_DHCP_UTILITIES_PY3)
$(DOCKER_DHCP_SERVER)_INSTALL_PYTHON_WHEELS = $(SONIC_UTILITIES_PY3)

SONIC_DOCKER_IMAGES += $(DOCKER_DHCP_SERVER)
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DHCP_SERVER_DBG)

ifeq ($(INCLUDE_KUBERNETES),y)
$(DOCKER_DHCP_SERVER)_DEFAULT_FEATURE_OWNER = kube
Expand All @@ -27,6 +25,8 @@ endif
$(DOCKER_DHCP_SERVER)_DEFAULT_FEATURE_STATE_ENABLED = y

ifeq ($(INCLUDE_DHCP_SERVER), y)
SONIC_DOCKER_IMAGES += $(DOCKER_DHCP_SERVER)
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DHCP_SERVER_DBG)
ifeq ($(INSTALL_DEBUG_TOOLS),y)
SONIC_PACKAGES_LOCAL += $(DOCKER_DHCP_SERVER_DBG)
else
Expand Down
10 changes: 5 additions & 5 deletions rules/docker-eventd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ $(DOCKER_EVENTD)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON)
$(DOCKER_EVENTD)_VERSION = 1.0.0
$(DOCKER_EVENTD)_PACKAGE_NAME = eventd

SONIC_DOCKER_IMAGES += $(DOCKER_EVENTD)
ifeq ($(INCLUDE_SYSTEM_EVENTD), y)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_EVENTD)
endif

# Build System Eventd Dockers
SONIC_DOCKER_IMAGES += $(DOCKER_EVENTD)
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_EVENTD_DBG)
ifeq ($(INCLUDE_SYSTEM_EVENTD), y)

# Install System Eventd Dockers
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_EVENTD)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_EVENTD_DBG)
endif

Expand Down
10 changes: 6 additions & 4 deletions rules/docker-gnmi.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ $(DOCKER_GNMI)_PACKAGE_NAME = gnmi

$(DOCKER_GNMI)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES)

ifeq ($(INCLUDE_SYSTEM_GNMI), y)
# Build System GNMI Dockers
SONIC_DOCKER_IMAGES += $(DOCKER_GNMI)
SONIC_BOOKWORM_DOCKERS += $(DOCKER_GNMI)
ifeq ($(INCLUDE_SYSTEM_GNMI), y)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_GNMI)
endif

# Build System GNMI Debug Dockers
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_GNMI_DBG)
SONIC_BOOKWORM_DBG_DOCKERS += $(DOCKER_GNMI_DBG)
ifeq ($(INCLUDE_SYSTEM_GNMI), y)

# Install System GNMI Dockers
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_GNMI)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_GNMI_DBG)
endif

Expand Down
Loading