f-41: frr: remarques de vtysh acceptées, l3vni libérée de façon asynchrone par bgpd #41
All checks were successful
Documentation / publish (push) Successful in 1m24s
Release Pipeline / set-release-target (push) Successful in 2s
Release Pipeline / upload-assets (agent.service, systemd/agent.service) (push) Successful in 7s
Release Pipeline / upload-assets (dhcp@.service, systemd/dhcp@.service) (push) Successful in 7s
Release Pipeline / upload-assets (dnsmasq@.service, systemd/dnsmasq@.service) (push) Successful in 7s
Release Pipeline / upload-assets (metadata@.service, systemd/metadata@.service) (push) Successful in 7s
Release Pipeline / upload-assets (run-dhcp-in-netns.sh, scripts/run-dhcp-in-netns.sh) (push) Successful in 7s
Release Pipeline / upload-assets (run-dnsmasq-in-netns.sh, scripts/run-dnsmasq-in-netns.sh) (push) Successful in 7s
Release Pipeline / build (agent, amd64, linux) (push) Successful in 0s
Release Pipeline / build (dhcp, amd64, linux) (push) Successful in 0s
Release Pipeline / build (metadata, amd64, linux) (push) Successful in 0s
Release Pipeline / checksums (push) Successful in 8s
Release Pipeline / release (push) Successful in 29s
Release Pipeline / publish (push) Successful in 0s
Release Pipeline / build (push) Successful in 2m25s
All checks were successful
Documentation / publish (push) Successful in 1m24s
Release Pipeline / set-release-target (push) Successful in 2s
Release Pipeline / upload-assets (agent.service, systemd/agent.service) (push) Successful in 7s
Release Pipeline / upload-assets (dhcp@.service, systemd/dhcp@.service) (push) Successful in 7s
Release Pipeline / upload-assets (dnsmasq@.service, systemd/dnsmasq@.service) (push) Successful in 7s
Release Pipeline / upload-assets (metadata@.service, systemd/metadata@.service) (push) Successful in 7s
Release Pipeline / upload-assets (run-dhcp-in-netns.sh, scripts/run-dhcp-in-netns.sh) (push) Successful in 7s
Release Pipeline / upload-assets (run-dnsmasq-in-netns.sh, scripts/run-dnsmasq-in-netns.sh) (push) Successful in 7s
Release Pipeline / build (agent, amd64, linux) (push) Successful in 0s
Release Pipeline / build (dhcp, amd64, linux) (push) Successful in 0s
Release Pipeline / build (metadata, amd64, linux) (push) Successful in 0s
Release Pipeline / checksums (push) Successful in 8s
Release Pipeline / release (push) Successful in 29s
Release Pipeline / publish (push) Successful in 0s
Release Pipeline / build (push) Successful in 2m25s
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
9477dc91d2
commit
1b80b1c7b6
2 changed files with 106 additions and 14 deletions
|
|
@ -4,18 +4,30 @@ import (
|
|||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
appliedWithNotes = "% Configuration applied with notes:"
|
||||
l3vniStillBound = "% Please unconfigure l3vni"
|
||||
l3vniRetries = 20
|
||||
l3vniRetryDelay = 250 * time.Millisecond
|
||||
)
|
||||
|
||||
type runner func(args ...string) ([]byte, error)
|
||||
|
||||
type Client struct {
|
||||
run runner
|
||||
run runner
|
||||
sleep func(time.Duration)
|
||||
}
|
||||
|
||||
func NewClient() *Client {
|
||||
return &Client{run: func(args ...string) ([]byte, error) {
|
||||
return exec.Command("vtysh", args...).CombinedOutput()
|
||||
}}
|
||||
return &Client{
|
||||
run: func(args ...string) ([]byte, error) {
|
||||
return exec.Command("vtysh", args...).CombinedOutput()
|
||||
},
|
||||
sleep: time.Sleep,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) ApplyBase(b Base) error {
|
||||
|
|
@ -79,7 +91,7 @@ func (c *Client) teardown(v VRF, plan func(VRF, string) []step) error {
|
|||
return err
|
||||
}
|
||||
for _, s := range plan(v, running) {
|
||||
if err := c.configure(s...); err != nil {
|
||||
if err := c.configureStep(s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
@ -92,6 +104,15 @@ func (c *Client) teardown(v VRF, plan func(VRF, string) []step) error {
|
|||
return remaining(plan(v, running))
|
||||
}
|
||||
|
||||
func (c *Client) configureStep(s step) error {
|
||||
err := c.configure(s...)
|
||||
for i := 0; i < l3vniRetries && err != nil && strings.Contains(err.Error(), l3vniStillBound); i++ {
|
||||
c.sleep(l3vniRetryDelay)
|
||||
err = c.configure(s...)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) runningConfig() (string, error) {
|
||||
return c.exec("show running-config")
|
||||
}
|
||||
|
|
@ -116,8 +137,9 @@ func (c *Client) exec(cmds ...string) (string, error) {
|
|||
return "", fmt.Errorf("vtysh %q: %w: %s", cmds, err, strings.TrimSpace(string(out)))
|
||||
}
|
||||
for _, l := range strings.Split(string(out), "\n") {
|
||||
if strings.HasPrefix(strings.TrimSpace(l), "%") {
|
||||
return "", fmt.Errorf("vtysh %q: %s", cmds, strings.TrimSpace(l))
|
||||
l = strings.TrimSpace(l)
|
||||
if strings.HasPrefix(l, "%") && l != appliedWithNotes {
|
||||
return "", fmt.Errorf("vtysh %q: %s", cmds, l)
|
||||
}
|
||||
}
|
||||
return string(out), nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue