Creating a machine with an existing IPMI IP results in db contraint error

Bug #1884157 reported by Kit Randel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Triaged
Low
Unassigned
3.3
Triaged
Low
Unassigned

Bug Description

Creating a machine (from /r/machines/add) with IPMI power and a `power_address` already in use, results in a DB constraint error. Ideally we should return a user readable error that doesn't expose details of the db schema.

Error:duplicate key value violates unique constraint "maasserver_bmc_power_type_parameters_idx" DETAIL: Key (power_type, power_parameters)=(ipmi, {"power_pass": "", "power_user": "", "power_driver": "LAN_2_0", "power_address": "193.168.58.5", "power_boot_type": "auto"}) already exists.

Tags: sts
Kit Randel (blr)
description: updated
Revision history for this message
Lee Trager (ltrager) wrote :

Each IPMI BMC maps to a single machine. Its not possible to have one IP address for multiple machines as this would result in one power command effecting multiple machines.

If there is an edge case I'm missing could you please explain?

Changed in maas:
status: New → Incomplete
Revision history for this message
Kit Randel (blr) wrote :

Oh, sorry I should have been more explicit, it's not that fact that there's an error, only that we return the db constraint error to the UI. It would be better if we didn't reveal details about the schema etc in the UI, and provided something friendlier.

description: updated
Revision history for this message
Kit Randel (blr) wrote :

Have updated the description to make it clearer, apologies Lee.

Lee Trager (ltrager)
Changed in maas:
status: Incomplete → Triaged
Revision history for this message
Jerzy Husakowski (jhusakowski) wrote :

The error should not be returned to the UI, the issue is largely cosmetic.

Changed in maas:
importance: Undecided → Low
milestone: none → 3.3.0
Changed in maas:
milestone: 3.3.0 → 3.4.0
Revision history for this message
Roy Zuo (roylez) wrote :

Why this unique constraint is introduced in 3.3? It is breaking some users' use case. Like the following, a 3.2 maas had no problem dealing with duplicated IPMI IP, and then when it is migrated to 3.3, db migration crashes.

Applying auth.0006_default_auto_field... OK
Applying maasserver.0277_replace_nullbooleanfield... OK
Applying maasserver.0278_generic_jsonfield... OK
Applying maasserver.0279_store_vpd_metadata_for_nodedevice... OK
Applying maasserver.0280_set_parent_for_existing_vms... OK
Applying maasserver.0281_secret_model... OK
Applying maasserver.0282_rpc_shared_secret_to_secret... OK
Applying maasserver.0283_migrate_tls_secrets... OK
Applying maasserver.0284_migrate_more_global_secrets... OK
Applying maasserver.0285_migrate_external_auth_secrets... OK
Applying maasserver.0286_node_deploy_metadata... OK
Applying maasserver.0287_add_controller_info_vault_flag... OK
Applying maasserver.0288_rootkey_material_secret... OK
Applying maasserver.0289_vault_secret... OK
Applying maasserver.0290_migrate_node_power_parameters...Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "maasserver_bmc_power_type_parameters_idx"
DETAIL: Key (power_type, md5(power_parameters::text))=(ipmi, fc8ed3c5711cc12878b8bf8360674799) already exists.

tags: added: sts
Revision history for this message
Trent Lloyd (lathiat) wrote :

The above error from comment #5 is actually caused by having duplicate IPMI BMCs where the IP+username is the same but the password is different. I have filed a new bug for this case:
https://bugs.launchpad.net/maas/+bug/2025026

I did note the following in that bug relevant to this bug

> While it makes sense to avoid duplicate IPMI IP/Username/Password combinations, the current unique constraint also does not really achieve that properly since any differing config value in power_parameters would cause the Unique constraint to pass. So I also wonder if this particular Unique constraint is the best enforcement mechanism.

Alberto Donato (ack)
Changed in maas:
milestone: 3.4.0 → 3.4.x
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.