Skip to content

Only mark Cell Active once reboot, BGP, and VLANs are confirmed - #29

Open
afritzler wants to merge 1 commit into
mainfrom
enh/cell-active
Open

afritzler wants to merge 1 commit into
mainfrom
enh/cell-active

Conversation

@afritzler

@afritzler afritzler commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Proposed Changes

CellStatus on sonic.ScriptRuntime previously just checked for /etc/sonic/fabric-cell.done, so a cell reported Active the moment the provisioning script ran, long before the switch finished rebooting and BGP came up. This makes the phase check reflect real readiness:

  • Reboot check: compares the done-flag mtime against /proc/uptime; if the flag is newer than the last boot, the scripted reboot hasn't happened yet → stays Created.
  • BGP check: counts Established vs configured neighbors via vtysh -c "show bgp neighbors json"; not all up → Created.
  • VLAN check: reads operstate of the south-port VLAN interfaces from /sys/class/net; any down → Created. The VLAN list is persisted to /etc/sonic/fabric-cell.state at ApplyCell time (removed on DeleteCell) so status doesn't re-derive it from the API.

Only when all three pass does the cell go Active.

No changes to the provisioning/reset scripts themselves.

Fixes #27

@github-actions github-actions Bot added the enhancement New feature or request label Oct 27, 2026
@hardikdr hardikdr added the area/switch-automation Automation processes for network switch management and operations. label Oct 27, 2026
@hardikdr hardikdr moved this to In Progress in Roadmap Oct 27, 2026
Signed-off-by: Andreas Fritzler <andreas.fritzler@sap.com>
@hardikdr hardikdr moved this from Todo to Needs Review/Discussion in Fabric Automation Oct 27, 2026
@afritzler
afritzler marked this pull request as ready for review October 28, 2026 09:31
@afritzler
afritzler requested a review from a team as a code owner October 28, 2026 09:31

@hardikdr hardikdr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @afritzler, dropped few comments inline.

Comment thread sonic/script.go
const (
ProviderName = "sonic"
doneFlagFile = "/etc/sonic/fabric-cell.done"
stateFile = "/etc/sonic/fabric-cell.state"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Would it help if we called it fabric-cell-vlan.state since it's only storing the states of the VLANs at the moment?

Comment thread sonic/script.go
}
vlans = append(vlans, fmt.Sprintf("Vlan%d", portNum/4+1001))
}
return os.WriteFile(r.stateFilePath, []byte(strings.Join(vlans, "\n")), 0o644)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that if runScript() has already written doneFile and executed reboot, the code might not get a chance to write the stateFile. Is this understanding correct?
In that case, it might be helpful to move the state-file writing block before runScript. wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/switch-automation Automation processes for network switch management and operations. enhancement New feature or request

Projects

Status: Needs Review/Discussion
Status: In Progress

Development

Successfully merging this pull request may close these issues.

Don't mark a Cell Active until the device config is actually live

2 participants