-
Notifications
You must be signed in to change notification settings - Fork 70
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
Add support for cli and json styled SR Linux configs #343
Conversation
Pull Request Test Coverage Report for Build 4612322046
💛 - Coveralls |
configResetCmd = "load factory auto-commit" | ||
// srl-controller v0.6.0+ creates a named checkpoint "initial" on node startup | ||
// configuration reset is therefore done by reverting to this checkpoint | ||
configResetCmd = "/tools system configuration checkpoint initial revert" |
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.
resetting is now done by reverting to a checkpoint named initial
.
This checkpoint is created by srl-controller:v0.6.0+ and will capture the config state of a node once it has booted and applied startup config (if present)
topo/node/srl/srl.go
Outdated
err := n.ControllerClient.Delete(ctx, &srlinuxv1.Srlinux{ObjectMeta: metav1.ObjectMeta{Name: n.Name()}}) | ||
err := n.ControllerClient.Delete(ctx, &srlinuxv1.Srlinux{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: n.GetNamespace(), Name: n.Name()}}, | ||
) |
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.
Namespace info was missing before in a call to Delete
// SR Linux default name for config file is either config.json or config.cli. | ||
// This depends on the extension of the provided startup-config file. | ||
if pb.Config.ConfigFile == "" { | ||
pb.Config.ConfigFile = "config.json" | ||
ext := filepath.Ext(pb.Config.GetFile()) | ||
if ext != ".json" { | ||
ext = ".cli" | ||
} | ||
|
||
pb.Config.ConfigFile = "config" + ext | ||
} |
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.
The default file name used to contain startup-config lines is derived from the file extension provided by a user in the topo.
This is done to let srl-controller know what format the config is provided with.
} | ||
services:{ | ||
key: 22 | ||
value: { | ||
name: "ssh" | ||
inside: 22 | ||
outside: 22 |
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.
outside ports were removed, as keys already convey this info
I took a quick glance, the behavior is exactly what we would want to support (cli or json), simplified cfgs, reset to initial cfg commit. Can you update the examples/multivendor/. topo + cfg as well as cloudbuild/vendors/. topo + cfg to match the new simplified cfgs? Assigning to Paul to do an actual code review here |
6a599fe
to
5804601
Compare
Thanks @alexmasi |
// srl-controller v0.6.0+ creates a named checkpoint "initial" on node startup | ||
// configuration reset is therefore done by reverting to this checkpoint | ||
configResetCmd = "/tools system configuration checkpoint initial revert" | ||
pushCfgFile = "/home/admin/kne-push-config" |
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.
configpush functionality now undergoes the following steps:
- config from a file is read into a string, and all double quotes are escaped
- the escaped config is then transferred to the srlinux node using pty transport opened with scrapligo over
kubectl exec
. - the transfer happens via
echo "<config lines>" > pushCfgFile
command. - then a candidate is opened and pushed config is sourced via
source pushCfgFile
- It is then committed and persisted.
A:pod1# file cat /etc/opt/srlinux/devices/app_ephemeral.mgmt_server.ready_for_config | ||
loaded initial configuration |
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.
in srlinux-scrapli package v0.6.0 we improved the way to check when the NOS is ready to accept configs. This is the new way
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.
The Go changes are simply nits
|
||
log.V(1).Infof("config to push:\n%s", cfgs) | ||
log.V(1).Infof("config to push:\n%s", cfg) |
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.
Shouldn't these lines be after the check for err?
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.
topo/node/srl/srl.go
Outdated
err := n.ControllerClient.Delete(ctx, &srlinuxv1.Srlinux{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: n.GetNamespace(), Name: n.Name()}}, | ||
) |
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.
When breaking up the line you should match the {}'s.
err := n.ControllerClient.Delete(ctx, &srlinuxv1.Srlinux{
ObjectMeta: metav1.ObjectMeta{
Namespace: n.GetNamespace(), Name: n.Name(),
},
})
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.
thanks
Done in 9a561cd
Looks like one of those commits caused the go test to fail |
@alexmasi it is a wild west in go test output there, I couldn't find which test was failing, I saw that some cluster tests failed, so maybe try to rerun to exclude flakiness? |
@alexmasi looks like some metallb tests failed -- https://github.com/openconfig/kne/actions/runs/4582237788/jobs/8092328043?pr=343#step:4:643 |
I have no clue how that test could have failed, the context gets cancelled as expected. Anyway rerunning now to confirm its a flake. This PR doesn't directly modify that code so I'm even more confused, we haven't seen a flake like that before |
/gcbrun |
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.
carrying over borman's approval that was dismissed, assuming the presubmit passes I will merge
sorry for the hassle here
9a561cd
to
fa62bee
Compare
/gcbrun |
This is a matching PR to support CLI and JSON-styled configs for SR Linux srl-labs/srl-controller#37
The idea is that KNE calculates how the config file should be named (
config.cli
orconfig.json
) based on the extension provided to the startup config file.Then srl-controller loads the appropriate startup config file.
Changes to resetter
Resetter now resets to startup config if it was provided, or to a default config (factory) if no startup config was provided (see inline comments)
Changes to ConfigPush
Config push now works with CLI snippets expressed both in
set /
flat syntax as well as multiline CLI-styled blobs.Changes to examples
I have thus removed the JSON config example and used CLI format hereafter.