-
Notifications
You must be signed in to change notification settings - Fork 379
[Nexthop] Use split sw/hw agents in Distro #936
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
Open
travisb-nexthop
wants to merge
10
commits into
facebook:main
Choose a base branch
from
nexthop-ai:split_swhw_agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+919
−1
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
721c284
PR813
marif-nexthop 985a470
[Nexthop] Create device-local RPM repo for run-time installation
travisb-nexthop c3a239d
Merge branch 'main' into local_rpm_repo
travisb-nexthop 0c27eef
FBOSS Distro init service and default configs
marif-nexthop 928f147
Merge branch 'main' into marif.fboss-distro-init
travisb-nexthop 9d2fe51
Minor update: changed default config name for minipack3 and product n…
travisb-nexthop 84d2282
Merge branch 'main' into marif.fboss-distro-init
marif-nexthop 3e05437
[Nexthop] Use split sw/hw agents in Distro
travisb-nexthop 57d2128
Merge branch 'main' into split_swhw_agent
travisb-nexthop ab4073d
Merge branch 'main' into split_swhw_agent
travisb-nexthop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...-image/image_builder/templates/centos-09.0/root_files/etc/yum.repos.d/local_rpm_repo.repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [local_rpm_repo] | ||
| name=Local Platform RPM repo | ||
| baseurl=file:///usr/local/share/local_rpm_repo | ||
| gpgcheck=0 | ||
| metadata_expire=6h | ||
| enabled=1 |
34 changes: 34 additions & 0 deletions
34
...e_builder/templates/centos-09.0/root_files/usr/lib/systemd/system/fboss_hw_agent@.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # /usr/lib/systemd/system/fboss_hw_agent@.service | ||
| [Unit] | ||
| Description=FBOSS HW Agent %i | ||
| PartOf=fboss_hw_agents.target | ||
| After=platform_manager.service | ||
| After=qsfp_service.service | ||
| After=rc-local.service | ||
| Wants=fboss_init.service | ||
| After=fboss_init.service | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| LimitNOFILE=10000000 | ||
| LimitCORE=32G | ||
| MemoryMax=3.75G | ||
| MemorySwapMax=0 | ||
|
|
||
| Environment="PATH=/opt/fboss/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" | ||
| Environment="LD_LIBRARY_PATH=/opt/fboss/lib" | ||
| WorkingDirectory=/opt/fboss | ||
| ExecStart=/bin/bash -c 'source /opt/fboss/bin/setup_fboss_env && exec /opt/fboss/bin/fboss_hw_agent-sai_impl --switchIndex %i' | ||
|
|
||
| Restart=always | ||
| RestartSec=30 | ||
| TimeoutStartSec=180s | ||
| TimeoutStopSec=30s | ||
|
|
||
| # Logging to journald | ||
| StandardOutput=journal | ||
| StandardError=journal | ||
| SyslogIdentifier=fboss_hw_agent%i | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
6 changes: 6 additions & 0 deletions
6
...ge_builder/templates/centos-09.0/root_files/usr/lib/systemd/system/fboss_hw_agents.target
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [Unit] | ||
| Description=FBOSS HW Agents Target | ||
| Wants=fboss_hw_agent@0.service fboss_hw_agent@1.service fboss_hw_agent@2.service fboss_hw_agent@3.service | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
19 changes: 19 additions & 0 deletions
19
.../image_builder/templates/centos-09.0/root_files/usr/lib/systemd/system/fboss_init.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # /usr/lib/systemd/system/fboss_init.service | ||
| [Unit] | ||
| Description=FBOSS Initialization | ||
| DefaultDependencies=no | ||
| Before=platform_manager.service | ||
| After=local-fs.target | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| RemainAfterExit=yes | ||
| ExecStart=/usr/local/bin/fboss_init.sh | ||
|
|
||
| # Logging to journald | ||
| StandardOutput=journal | ||
| StandardError=journal | ||
| SyslogIdentifier=fboss_init | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
33 changes: 33 additions & 0 deletions
33
...ge_builder/templates/centos-09.0/root_files/usr/lib/systemd/system/fboss_sw_agent.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # /usr/lib/systemd/system/fboss_sw_agent.service | ||
| [Unit] | ||
| Description=FBOSS SW Agent | ||
| After=platform_manager.service | ||
| After=qsfp_service.service | ||
| After=rc-local.service | ||
| StartLimitIntervalSec=600 | ||
| StartLimitBurst=5 | ||
|
|
||
| [Service] | ||
| Type=notify | ||
| LimitNOFILE=10000000 | ||
| LimitCORE=32G | ||
| MemoryMax=3.75G | ||
| MemorySwapMax=0 | ||
|
|
||
| Environment="PATH=/opt/fboss/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" | ||
| Environment="LD_LIBRARY_PATH=/opt/fboss/lib" | ||
| WorkingDirectory=/opt/fboss | ||
| ExecStart=/bin/bash -c 'source /opt/fboss/bin/setup_fboss_env && exec /opt/fboss/bin/fboss_sw_agent' | ||
|
|
||
| Restart=always | ||
| RestartSec=30 | ||
| TimeoutStartSec=180s | ||
| TimeoutStopSec=30s | ||
|
|
||
| # Logging to journald | ||
| StandardOutput=journal | ||
| StandardError=journal | ||
| SyslogIdentifier=fboss_sw_agent | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
10 changes: 10 additions & 0 deletions
10
...ge_builder/templates/centos-09.0/root_files/usr/lib/systemd/system/local_rpm_repo.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [Unit] | ||
| Description=Enable local_rpm_repo | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=/usr/bin/createrepo /usr/local/share/local_rpm_repo | ||
| RemainAfterExit=yes | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
fboss-image/image_builder/templates/centos-09.0/root_files/usr/local/bin/fboss_init.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| #!/bin/bash | ||
| # Initialize FBOSS configuration based on platform detection | ||
|
|
||
| set -e | ||
|
|
||
| FBOSS_SHARE="/opt/fboss/share" | ||
| COOP_DIR="/etc/coop" | ||
| FRUID_FILE="/var/facebook/fboss/fruid.json" | ||
|
|
||
| log() { | ||
| echo "[fboss_init] $1" >&2 | ||
| } | ||
|
|
||
| error() { | ||
| echo "[fboss_init] ERROR: $1" >&2 | ||
| } | ||
|
|
||
| get_platform_dir() { | ||
| local platform | ||
| # convert the platform name to lowercase and delete spaces | ||
| platform=$(dmidecode -s system-product-name 2>/dev/null | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]-_') | ||
| if [[ -z $platform ]]; then | ||
| error "Failed to get system-product-name from dmidecode" | ||
| return 1 | ||
| fi | ||
| log "Detected platform: $platform" | ||
|
|
||
| local platform_dir="${FBOSS_SHARE}/default_configs/${platform}" | ||
| if [[ ! -d $platform_dir ]]; then | ||
| error "Platform config directory not found: $platform_dir" | ||
| return 1 | ||
| fi | ||
| log "Using platform config directory: $platform_dir" | ||
|
|
||
| echo "$platform_dir" | ||
| } | ||
|
|
||
| copy_config() { | ||
| local src="$1" | ||
| local dst="$2" | ||
| local name="$3" | ||
|
|
||
| if [[ -e $dst ]]; then | ||
| log "$name already exists at $dst (skipping)" | ||
| return | ||
| fi | ||
|
|
||
| if [[ -f $src ]]; then | ||
| cp "$src" "$dst" | ||
| log "Copied $name: $src -> $dst" | ||
| else | ||
| log "No $name found at $src (skipping)" | ||
| fi | ||
| } | ||
|
|
||
| generate_fruid() { | ||
| if [[ -e $FRUID_FILE ]]; then | ||
| log "fruid.json already exists at $FRUID_FILE (skipping)" | ||
| return | ||
| fi | ||
|
|
||
| mkdir -p "$(dirname "$FRUID_FILE")" | ||
|
|
||
| if /opt/fboss/bin/weutil --json >"$FRUID_FILE" 2>/dev/null; then | ||
| log "Generated fruid.json: $FRUID_FILE" | ||
| else | ||
| error "Failed to generate fruid.json" | ||
| rm -f "$FRUID_FILE" | ||
| fi | ||
| } | ||
|
|
||
| setup_coop_configs() { | ||
| local platform_dir="$1" | ||
| mkdir -p "$COOP_DIR" | ||
| copy_config "${platform_dir}/agent.conf" "${COOP_DIR}/agent.conf" "agent.conf" | ||
| copy_config "${platform_dir}/qsfp.conf" "${COOP_DIR}/qsfp.conf" "qsfp.conf" | ||
| } | ||
|
|
||
| enable_hw_agents() { | ||
| local platform_dir="$1" | ||
| local num_hw_agents | ||
| if [ ! -f "${platform_dir}/num_hw_agents" ]; then | ||
| num_hw_agents=1 | ||
| else | ||
| num_hw_agents=$(cat "${platform_dir}/num_hw_agents") | ||
| fi | ||
| for i in $(seq ${num_hw_agents}); do | ||
| systemctl enable "fboss_hw_agent@$((i - 1)).service" | ||
| # Calling systemctl start inside a starting systemd service deadlocks | ||
| systemctl start "fboss_hw_agent@$((i - 1)).service" & | ||
| done | ||
| } | ||
|
|
||
| main() { | ||
| log "Starting FBOSS initialization" | ||
|
|
||
| local platform_dir | ||
| if ! platform_dir=$(get_platform_dir); then | ||
| exit 1 | ||
| fi | ||
|
|
||
| setup_coop_configs "$platform_dir" | ||
| generate_fruid | ||
| enable_hw_agents "$platform_dir" | ||
|
|
||
| log "FBOSS initialization complete" | ||
| } | ||
|
|
||
| main "$@" |
3 changes: 3 additions & 0 deletions
3
...mage/image_builder/templates/centos-09.0/root_files/usr/local/share/local_rpm_repo/README
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| This directory contains RPMs which need to be installed at run-time, mostly by | ||
| platform_manager. Common contents include BSP kmods RPMs, SAI kmods RPMs, and | ||
| dependencies of those types of RPMs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we decide on mutli selection of sai sdk's are we going to stick with the assumption there is only 1 sai_impl on the target distro device?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now Distro Image is designed with the assumption that any particular image will only be built with one ASIC SAI. That is the logic implemented here.
When multi-SAI SDK support is added, the logic here would be extended to use whatever the new choice mechanism is.