-
Notifications
You must be signed in to change notification settings - Fork 1
check admin status instead of actual status #197
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f25d97a
check admin status instead of actual status
iljarotar 97fe648
use running instead of admin state of a nic
iljarotar 81907e4
log switch notify request
iljarotar a854219
print nic flags for debug
iljarotar ed4c796
debug log for down ports
iljarotar 493f88f
remove switch notify request log
iljarotar 23fc084
fix flaky test
iljarotar dc1f76e
log port admin state
iljarotar ceee83f
remove log
iljarotar 726a287
get rid of downports and bool port status
iljarotar 8887d26
compare desired port states current admin states in configDB
iljarotar 8bdc6a0
fix wrong condition
iljarotar e8bb39a
pin metal-api and metal-go
iljarotar 4db5b7c
Update cmd/internal/switcher/sonic/db/configdb.go
iljarotar a0dfbcc
return error when admin status is not up or down
iljarotar 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
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 |
|---|---|---|
|
|
@@ -4,13 +4,12 @@ import ( | |
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/metal-stack/metal-core/cmd/internal/switcher/types" | ||
| "github.com/valkey-io/valkey-go" | ||
| ) | ||
|
|
||
| const ( | ||
| adminStatus = "admin_status" | ||
| adminStatusUp = "up" | ||
| adminStatusDown = "down" | ||
| adminStatusField = "admin_status" | ||
| alias = "alias" | ||
| enable = "enable" | ||
| interfaceTable = "INTERFACE" | ||
|
|
@@ -35,7 +34,7 @@ type ConfigDB struct { | |
| type Port struct { | ||
| Name string | ||
| Alias string | ||
| AdminStatus bool | ||
| AdminStatus string | ||
| Mtu string | ||
| } | ||
|
|
||
|
|
@@ -303,7 +302,7 @@ func (d *ConfigDB) GetPort(ctx context.Context, interfaceName string) (*Port, er | |
| return &Port{ | ||
| Name: interfaceName, | ||
| Alias: result[alias], | ||
| AdminStatus: result[adminStatus] == adminStatusUp, | ||
| AdminStatus: result[adminStatusField], | ||
| Mtu: result[mtu], | ||
| }, nil | ||
| } | ||
|
|
@@ -333,7 +332,7 @@ func (d *ConfigDB) GetPorts(ctx context.Context) ([]*Port, error) { | |
| ports = append(ports, &Port{ | ||
| Name: p, | ||
| Alias: result[alias], | ||
| AdminStatus: result[adminStatus] == adminStatusUp, | ||
| AdminStatus: result[adminStatusField], | ||
| Mtu: result[mtu], | ||
| }) | ||
| } | ||
|
|
@@ -347,12 +346,21 @@ func (d *ConfigDB) SetPortMtu(ctx context.Context, interfaceName string, val str | |
| return d.c.HSet(ctx, key, Val{mtu: val}) | ||
| } | ||
|
|
||
| func (d *ConfigDB) SetAdminStatusUp(ctx context.Context, interfaceName string, up bool) error { | ||
| func (d *ConfigDB) GetAdminStatus(ctx context.Context, interfaceName string) (types.PortStatus, error) { | ||
| key := Key{portTable, interfaceName} | ||
|
|
||
| status := adminStatusUp | ||
| if !up { | ||
| status = adminStatusDown | ||
| status, err := d.c.HGet(ctx, key, adminStatusField) | ||
| if err != nil { | ||
| return "", nil | ||
| } | ||
|
|
||
| return types.PortStatus(status), nil | ||
| } | ||
|
|
||
| func (d *ConfigDB) SetAdminStatus(ctx context.Context, interfaceName string, adminStatus types.PortStatus) error { | ||
| if adminStatus != types.PortStatusDown && adminStatus != types.PortStatusUp { | ||
| return nil | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe return an error? |
||
| } | ||
| return d.c.HSet(ctx, key, Val{adminStatus: status}) | ||
| key := Key{portTable, interfaceName} | ||
| return d.c.HSet(ctx, key, Val{adminStatusField: string(adminStatus)}) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.