Skip to content
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

port settings update as transaction #6001

Merged
merged 1 commit into from
Jul 5, 2024
Merged

port settings update as transaction #6001

merged 1 commit into from
Jul 5, 2024

Conversation

rcgoodfellow
Copy link
Contributor

There is a fair amount of code churn here, but it's mostly just moving things around. I factored the clousures that underpin the port settings create and port settings delete methods out into independent functions. Then, I added a new top-level datastore function that performs a port settings update as a client-side database transaction using the factored-out delete and create functions.

@rcgoodfellow
Copy link
Contributor Author

rcgoodfellow commented Jul 4, 2024

With this PR my testing that surfaced #6000 no longer presents an issue.

Baseline configuration

ry@masaka:~$ oxide net port config
switch1/qsfp0
=============
Autoneg  Fec   Speed
false    None  Speed100G

Address          Lot
169.254.20.2/30  initial-infra
169.254.40.2/30  initial-infra

BGP Peer      Export       Import       Communities  Connect Retry  Delay Open  Enforce First AS  Hold Time  Idle Hold Time  Keepalive  Local Pref  Md5 Auth  Min TTL  MED   Remote ASN  VLAN
169.254.20.1  NoFiltering  NoFiltering  []           3              3           false             6          0               2          None        None      None     None  None        Some(200)
169.254.40.1  NoFiltering  NoFiltering  []           3              3           false             6          0               2          None        None      None     None  None        Some(400)

switch0/qsfp0
=============
Autoneg  Fec   Speed
false    None  Speed100G

Address          Lot
169.254.10.2/30  initial-infra
169.254.30.2/30  initial-infra

BGP Peer      Export       Import       Communities  Connect Retry  Delay Open  Enforce First AS  Hold Time  Idle Hold Time  Keepalive  Local Pref  Md5 Auth  Min TTL  MED   Remote ASN  VLAN
169.254.10.1  NoFiltering  NoFiltering  []           3              3           false             6          0               2          None        None      None     None  None        Some(100)
169.254.30.1  NoFiltering  NoFiltering  []           3              3           false             6          0               2          None        None      None     None  None        Some(300)

Send a request that will cause an address lot allocation failure.

Preivously this would result in deleting the switch port settings and leaving a dangling reference for the specified port.

ry@masaka:~$ oxide net addr add 3d4fd291-379b-4ed4-b526-1850223bc4b1 switch0 qsfp0 169.254.99.1/30 initial-infra 447
Error Response: status: 400 Bad Request; headers: {"content-type": "application/json", "x-request-id": "cb47a0d6-a539-4bd4-82dc-e0ad574e19d7", "content-length": "127", "date": "Thu, 04 Jul 2024 20:16:22 GMT"}; value: Error { error_code: Some("InvalidRequest"), message: "address not in lot", request_id: "cb47a0d6-a539-4bd4-82dc-e0ad574e19d7" }

Try again with an address within the lot

This time the allocation succeeds and we can see the address add operation had the desired result in the follow on oxide net port config output. Prior to this PR, this would fail with an error complaining about the port settings id not being found.

ry@masaka:~$ oxide net addr add 3d4fd291-379b-4ed4-b526-1850223bc4b1 switch0 qsfp0 169.254.47.2/30 initial-infra 447
ry@masaka:~$ oxide net port config
switch1/qsfp0
=============
Autoneg  Fec   Speed
false    None  Speed100G

Address          Lot
169.254.20.2/30  initial-infra
169.254.40.2/30  initial-infra
169.254.47.2/30  initial-infra

BGP Peer      Export       Import       Communities  Connect Retry  Delay Open  Enforce First AS  Hold Time  Idle Hold Time  Keepalive  Local Pref  Md5 Auth  Min TTL  MED   Remote ASN  VLAN
169.254.20.1  NoFiltering  NoFiltering  []           3              3           false             6          3               2          None        None      None     None  None        Some(200)
169.254.40.1  NoFiltering  NoFiltering  []           3              3           false             6          3               2          None        None      None     None  None        Some(400)

switch0/qsfp0
=============
Autoneg  Fec   Speed
false    None  Speed100G

Address          Lot
169.254.10.2/30  initial-infra
169.254.30.2/30  initial-infra

BGP Peer      Export       Import       Communities  Connect Retry  Delay Open  Enforce First AS  Hold Time  Idle Hold Time  Keepalive  Local Pref  Md5 Auth  Min TTL  MED   Remote ASN  VLAN
169.254.10.1  NoFiltering  NoFiltering  []           3              3           false             6          0               2          None        None      None     None  None        Some(100)
169.254.30.1  NoFiltering  NoFiltering  []           3              3           false             6          0               2          None        None      None     None  None        Some(300)

Nudge this a different way by providing a bad address lot name

ry@masaka:~$ oxide net addr add 3d4fd291-379b-4ed4-b526-1850223bc4b1 switch0 qsfp0 169.254.47.3/30 bad-name 447
Error Response: status: 400 Bad Request; headers: {"content-type": "application/json", "x-request-id": "aa106582-6ee7-46bf-b718-d522fddb17db", "content-length": "129", "date": "Thu, 04 Jul 2024 20:18:04 GMT"}; value: Error { error_code: Some("InvalidRequest"), message: "AddressLot not found", request_id: "aa106582-6ee7-46bf-b718-d522fddb17db" }

Everything still fine once we fix the address lot name

ry@masaka:~$ oxide net addr add 3d4fd291-379b-4ed4-b526-1850223bc4b1 switch0 qsfp0 169.254.47.3/30 initial-infra 447
ry@masaka:~$ oxide net port config
switch1/qsfp0
=============
Autoneg  Fec   Speed
false    None  Speed100G

Address          Lot
169.254.20.2/30  initial-infra
169.254.40.2/30  initial-infra
169.254.47.2/30  initial-infra
169.254.47.3/30  initial-infra

BGP Peer      Export       Import       Communities  Connect Retry  Delay Open  Enforce First AS  Hold Time  Idle Hold Time  Keepalive  Local Pref  Md5 Auth  Min TTL  MED   Remote ASN  VLAN
169.254.20.1  NoFiltering  NoFiltering  []           3              3           false             6          3               2          None        None      None     None  None        Some(200)
169.254.40.1  NoFiltering  NoFiltering  []           3              3           false             6          3               2          None        None      None     None  None        Some(400)

switch0/qsfp0
=============
Autoneg  Fec   Speed
false    None  Speed100G

Address          Lot
169.254.10.2/30  initial-infra
169.254.30.2/30  initial-infra

BGP Peer      Export       Import       Communities  Connect Retry  Delay Open  Enforce First AS  Hold Time  Idle Hold Time  Keepalive  Local Pref  Md5 Auth  Min TTL  MED   Remote ASN  VLAN
169.254.10.1  NoFiltering  NoFiltering  []           3              3           false             6          0               2          None        None      None     None  None        Some(100)
169.254.30.1  NoFiltering  NoFiltering  []           3              3           false             6          0               2          None        None      None     None  None        Some(300)

@rcgoodfellow rcgoodfellow marked this pull request as ready for review July 4, 2024 20:24
@rcgoodfellow
Copy link
Contributor Author

The oxide CLI that is used in the demonstration above is available here

@rcgoodfellow rcgoodfellow merged commit c6f7956 into main Jul 5, 2024
19 checks passed
@rcgoodfellow rcgoodfellow deleted the issue-6000 branch July 5, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in switch port settings update can cause port settings corruption
2 participants