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

"vnctl interface add" should be rolled back on errors #524

Open
miz-axsh opened this issue Feb 16, 2017 · 0 comments
Open

"vnctl interface add" should be rolled back on errors #524

miz-axsh opened this issue Feb 16, 2017 · 0 comments

Comments

@miz-axsh
Copy link
Member

vnctl interface add command with duplicated port-name parameter inserts incomplete data into the database. The series of INSERT statements should be done in one transaction, and should be rolled back on errors.

Example:

# vnctl interfaces add \
        --uuid=if-inst1x \
        --mode=vif \
        --owner-datapath-uuid=dp-dp01 \
        --mac-address 10:54:ff:00:00:01 \
        --network-uuid=nw-test1 \
        --ipv4-address=10.100.0.10 \
        --port-name=inst1  # ← inst1

# vnctl interfaces add \
        --uuid=if-inst2x \
        --mode=vif \
        --owner-datapath-uuid=dp-dp01 \
        --mac-address 10:54:ff:00:00:02 \
        --network-uuid=nw-test1 \
        --ipv4-address=10.100.0.11 \
        --port-name=inst1  # ← mistake: violates uniqueness
---
:error: Sequel::UniqueConstraintViolation
:message: 'Mysql2::Error: Duplicate entry ''inst1-1-1-0'' for key ''port_name'''
:code: 500

got an error, because port-name is duplicated.

mysql> SELECT uuid FROM interfaces;
+--------+
| uuid   |
+--------+
| inst1x |
| inst2x |
+--------+
mysql> SELECT port_name FROM interface_ports;
+-----------+
| port_name |
+-----------+
| inst1     |
+-----------+

in spite of the error, new record was inserted into the interfaces table.

# vnctl interfaces add \
        --uuid=if-inst2x \
        --mode=vif \
        --owner-datapath-uuid=dp-dp01 \
        --mac-address 10:54:ff:00:00:02 \
        --network-uuid=nw-test1 \
        --ipv4-address=10.100.0.11 \
        --port-name=inst2  # now corrected
---
:error: Vnet::Endpoints::Errors::DuplicateUUID
:message: if-inst2x
:code: '102'

tried again with corrected port-name, still get error because of the inserted record.

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

No branches or pull requests

1 participant