-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix(evpn-bridge): fix for frr to handle vrf setup and teardown #401
base: main
Are you sure you want to change the base?
Conversation
pkg/frr/frr.go
Outdated
if err != nil { | ||
data, err = Frr.FrrZebraCmd(ctx, fmt.Sprintf("configure terminal\n %s\n exit\n", delCmd2)) | ||
if err != nil || checkFrrResult(data, false) { | ||
log.Printf("FRR: Error %s\n", data) |
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.
Does data contain error description?
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.
Yes data contains the complete FRR command output.
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.
would it be better in case of an error, in FrrBgpCmd, just add data content into err and return empty first argument?
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.
Done
pkg/frr/frr.go
Outdated
@@ -437,7 +430,7 @@ func setUpVrf(vrf *infradb.Vrf) (string, bool) { | |||
|
|||
// checkFrrResult checks the vrf result | |||
func checkFrrResult(cp string, show bool) bool { | |||
return ((show && reflect.ValueOf(cp).IsZero()) || strings.Contains(cp, "warning") || strings.Contains(cp, "unknown") || strings.Contains(cp, "Unknown") || strings.Contains(cp, "Warning") || strings.Contains(cp, "Ambiguous") || strings.Contains(cp, "specified does not exist")) | |||
return ((show && reflect.ValueOf(cp).IsZero()) || strings.Contains(cp, "warning") || strings.Contains(cp, "unknown") || strings.Contains(cp, "Unknown") || strings.Contains(cp, "Warning") || strings.Contains(cp, "Ambiguous") || strings.Contains(cp, "specified does not exist") || strings.Contains(cp, "Error")) |
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.
reflect.ValueOf(cp).IsZero()) -> cp == ""
what if cp contains waRning
? Will you add a new comparison then? Will it be better to lower case the string and only then check what itcontains?
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.
Done
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.
- all local vars should start from lowercase. I see
Patterns
in that function. Pls check the code you touched in the PR - do not use
reflect.ValueOf(...).IsZero()
frequently, you can use simple comparison. Pls check all cases
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.
Changed all local vars names in frr.go and replaced all reflect.valueof IsZero with simple comparison.
pkg/frr/frr.go
Outdated
} | ||
hname, _ := os.Hostname() | ||
L2vpnCmd := strings.Split(cp, "json") | ||
L2vpnCmd = strings.Split(L2vpnCmd[1], hname) | ||
cp = L2vpnCmd[0] | ||
// fmt.Printf("FRR_L2vpn[0]: %s\n",cp) | ||
if len(cp) != 7 { | ||
if len(cp) != 7 { // Checking CMD o/p |
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.
magic number. Rely on string length is very unreliable
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.
Addressed this and changed to string compare instead of string length
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.
is response should be in json format? Should we better try to Unmarshall it then using"\r\n{}\r\n{\r\n}\r\n"
? If not, maybe we could check if it contains alphanumerical values instead?
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.
Changed the comparing the string with alphanumerical.
585cd47
to
138318f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #401 +/- ##
==========================================
- Coverage 50.77% 42.82% -7.95%
==========================================
Files 37 25 -12
Lines 2525 1721 -804
==========================================
- Hits 1282 737 -545
+ Misses 1114 896 -218
+ Partials 129 88 -41 ☔ View full report in Codecov by Sentry. |
a553e28
to
5ab2fc8
Compare
05da753
to
a8da21f
Compare
Signed-off-by: Venkatesh, Vemula <[email protected]>
Signed-off-by: atulpatel261194 <[email protected]>
Signed-off-by: Vemula Venkatesh <[email protected]>
Signed-off-by: atulpatel261194 <[email protected]>
Signed-off-by: Vemula Venkatesh <[email protected]>
4ee351a
to
165664c
Compare
Signed-off-by: atulpatel261194 <[email protected]>
165664c
to
3174273
Compare
Signed-off-by: atulpatel261194 <[email protected]>
fix: frr handle the duplicate vni and deleting of non-existence vrf and svi.