[1.9] loading initial data for maasserver: maas-region-admin reports duplicate key error during package install

Bug #1602468 reported by John George
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Invalid
Undecided
Unassigned
1.9
Invalid
Undecided
Unassigned

Bug Description

The following traceback was hit while installing MAAS 1.9

+ sudo add-apt-repository ppa:maas/stable
gpg: keyring `/tmp/tmpnl9hx4ha/secring.gpg' created
gpg: keyring `/tmp/tmpnl9hx4ha/pubring.gpg' created
gpg: requesting key 684D4A1C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpnl9hx4ha/trustdb.gpg: trustdb created
gpg: key 684D4A1C: public key "Launchpad PPA for MAAS" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
+ sudo apt-get update
+ sudo DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
Leaving 'diversion of /etc/init/ureadahead.conf to /etc/init/ureadahead.conf.disabled by cloud-init'
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-3.13.0-91-generic
Updating /boot/grub/menu.lst ... done

+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y maas

Extracting templates from packages: 22%
Extracting templates from packages: 44%
Extracting templates from packages: 66%
Extracting templates from packages: 88%
Extracting templates from packages: 100%

Creating config file /etc/papersize with new version
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Adding group `bind' (GID 112) ...
Done.
Adding system user `bind' (UID 107) ...
Adding new user `bind' (UID 107) with group `bind' ...
Not creating home directory `/var/cache/bind'.
wrote key file "/etc/bind/rndc.key"
#
 * Starting domain name service... bind9
   ...done.

Creating config file /etc/dbconfig-common/config with new version
Generating /etc/default/isc-dhcp-server...
isc-dhcp-server start/running, process 7383
isc-dhcp-server6 stop/pre-start, process 7421
adduser: Warning: The home directory `/var/lib/maas' does not belong to the user you are currently creating.
2016/07/12 23:01:07 kid1| Creating missing swap directories
2016/07/12 23:01:07 kid1| No cache_dir stores are configured.
Skipping profile in /etc/apparmor.d/disable: usr.sbin.squid3
Adding user postgres to group ssl-cert

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Considering dependency proxy for proxy_http:
Enabling module proxy.
Enabling module proxy_http.
To activate the new configuration, you need to run:
  service apache2 restart
Considering dependency proxy for proxy_wstunnel:
Module proxy already enabled
Enabling module proxy_wstunnel.
To activate the new configuration, you need to run:
  service apache2 restart
Enabling module expires.
To activate the new configuration, you need to run:
  service apache2 restart
Enabling module rewrite.
To activate the new configuration, you need to run:
  service apache2 restart
rsyslog stop/waiting
rsyslog start/running, process 9357
 * Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
   ...done.
maas-regiond start/running
invoke-rc.d: initscript bind9, action "restart" failed.
 * Restarting PostgreSQL 9.3 database server
   ...done.
dbconfig-common: writing config to /etc/dbconfig-common/maas-region-controller.conf

Creating config file /etc/dbconfig-common/maas-region-controller.conf with new version
creating postgres user maas: success.
verifying creation of user: success.
creating database maasdb: success.
verifying database maasdb exists: success.
dbconfig-common: flushing administrative password
Syncing...
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table piston_nonce
Creating table piston_consumer
Creating table piston_token
Creating table south_migrationhistory
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

Synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > django.contrib.messages
 > django.contrib.staticfiles
 > piston
 > south

Not synced (use migrations):
 - maasserver
 - metadataserver
(use ./manage.py migrate to migrate these)
Running migrations for maasserver:
 - Migrating forwards to 0191_remove_comma_from_dns_servers.
 > maasserver:0001_initial
 > maasserver:0002_add_token_to_node
 > maasserver:0002_macaddress_unique
 > maasserver:0003_rename_sshkeys
 > maasserver:0004_add_node_error
 > maasserver:0005_sshkey_user_and_key_unique_together
 > maasserver:0006_increase_filestorage_filename_length
 > maasserver:0007_common_info_created_add_time
 > maasserver:0008_node_power_address
 > maasserver:0009_add_nodegroup
 > maasserver:0010_add_node_netboot
 > maasserver:0011_add_dns_zone_serial_sequence
 > maasserver:0012_DHCPLease
 > maasserver:0013_connect_node_node_group
 > maasserver:0014_nodegroup_dhcp_settings_are_optional
 > maasserver:0016_node_nodegroup_not_null
 > maasserver:0017_add_dhcp_key_to_nodegroup
 > maasserver:0018_activate_worker_user
 > maasserver:0019_add_nodegroup_dhcp_interface
 > maasserver:0020_nodegroup_dhcp_interfaces_is_plural
 > maasserver:0021_add_uuid_to_nodegroup
 > maasserver:0022_add_status_to_nodegroup
 > maasserver:0023_add_bootimage_model
 > maasserver:0024_add_nodegroupinterface
 > maasserver:0025_remove_unused_fields_in_nodegroup
 > maasserver:0026_add_node_distro_series
 > maasserver:0027_add_tag_table
 > maasserver:0028_add_node_hardware_details
 > maasserver:0029_zone_sharing
 > maasserver:0030_ip_address_to_generic_ip_address
 > maasserver:0031_node_architecture_field_size
 > maasserver:0032_node_subarch
 > maasserver:0033_component_error
 > maasserver:0034_timestamp_component_error
 > maasserver:0035_add_nodegroup_cluster_name
 > maasserver:0036_populate_nodegroup_cluster_name
 > maasserver:0037_nodegroup_cluster_name_unique
 > maasserver:0038_nodegroupinterface_ip_range_fix
 > maasserver:0039_add_filestorage_content
 > maasserver:0039_add_nodegroup_to_bootimage
 > maasserver:0040_make_filestorage_data_not_null
 > maasserver:0041_remove_filestorage_data
 > maasserver:0042_fix_039_conflict
 > maasserver:0043_unique_hostname_preparation
 > maasserver:0044_node_hostname_unique
 > maasserver:0045_add_tag_kernel_opts
 > maasserver:0046_add_nodegroup_maas_url
 > maasserver:0047_add_owner_to_filestorage
 > maasserver:0048_add_key_to_filestorage
 > maasserver:0049_filestorage_key_unique
 > maasserver:0050_shared_to_per_tenant_storage
 > maasserver:0051_bigger_distro_series_name
 > maasserver:0052_add_node_storage
 > maasserver:0053_node_routers
 > maasserver:0054_download_progress
 > maasserver:0055_nullable_bytes_downloaded
 > maasserver:0056_netboot_off_for_allocated_nodes
 > maasserver:0057_remove_hardware_details
 > maasserver:0058_add_agent_name_to_node
 > maasserver:0059_dhcp_detection_model
 > metadataserver:0001_initial
 > metadataserver:0002_add_nodecommissionresult
 > metadataserver:0003_populate_hardware_details
 > metadataserver:0004_add_commissioningscript
 > metadataserver:0005_nodecommissionresult_add_timestamp
 > metadataserver:0006_nodecommissionresult_add_status
 > metadataserver:0007_nodecommissionresult_change_name_size
 > metadataserver:0008_rename_lshw_commissioning_output
 > metadataserver:0009_delete_status
 > metadataserver:0010_add_script_result
 > metadataserver:0011_commission_result_binary_data_col
 > metadataserver:0012_commission_result_binary_data_recode
 > metadataserver:0013_commission_result_drop_old_data_col
 > metadataserver:0014_commission_result_rename_data_bin_col
 > metadataserver:0015_rename_nodecommissionresult_add_result_type
 > maasserver:0060_add_zone_object
 > maasserver:0061_add_ref_from_node_to_zone
 > maasserver:0062_add_vlan_model
 > maasserver:0063_create_default_zone
 > maasserver:0064_set_default_zone
 > maasserver:0065_set_default_zone_as_model_default
 > maasserver:0066_rename_vlan_add_link_node_network
 > maasserver:0067_default_commissioning_trusty
 > maasserver:0068_network_description_textfield
 > maasserver:0069_add_mac_network_relation
 > maasserver:0070_drop_network_node_relation
 > maasserver:0071_drop_after_commissioning_action
 > maasserver:0072_remove_ipmi_autodetect
 > maasserver:0073_add_label_to_bootimage
 > maasserver:0074_boot_images_timestamp
 > maasserver:0075_add_boot_resource_models
 > maasserver:0076_add_osystem_to_bootimage
 > maasserver:0077_remove_null_for_bootsourceselection_release
 > maasserver:0078_add_osystem_to_node
 > maasserver:0079_supported_subarches_for_bootimage
 > maasserver:0080_binary_to_editablebinary_in_bootsource
 > maasserver:0081_ipaddress_table_and_static_dhcp_ranges
 > maasserver:0082_cluster_interface_for_macaddress
 > maasserver:0083_add_license_key_to_node
 > maasserver:0084_add_ssl_key_model
 > maasserver:0085_add_user_to_staticipaddress
 > maasserver:0086_add_xinstall_path_and_type_to_bootimage
 > maasserver:0087_add_licensekey_model
 > maasserver:0088_ip_to_custom_field
 > maasserver:0088_z_backport_trunk_0099
 > maasserver:0089_create_nodegroupinterface_name
 > maasserver:0090_initialise_nodegroupinterface_name
 > maasserver:0091_add_boot_type_to_node
 > maasserver:0092_populate_node_boot_type
 > maasserver:0093_add_eventtype_and_event
 > maasserver:0094_add_error_description
 > maasserver:0095_add_event_description
 > maasserver:0096_add_power_state_to_node
 > maasserver:0097_add_largefile_model
 > maasserver:0098_add_bootresource_models
 > maasserver:0099_convert_cluster_interfaces_to_networks
 > maasserver:0100_remove_cluster_from_bootsrouce
 > maasserver:0100_remove_duplicate_bootsource_urls
 > maasserver:0101_make_bootsource_url_unique
 > maasserver:0102_candidate_name
 > maasserver:0103_candidate_names
 > maasserver:0104_add_node_disable_ipv4
 > maasserver:0105_remove_rtype_from_uniqueness_on_boot_resource
 > maasserver:0106_add_os_to_boot_source_selection
 > maasserver:0107_add_default_gateway_to_network
 > maasserver:0108_migrate_allocated_netboot
 > maasserver:0109_networks_dns_servers
 > maasserver:0110_deployed_state_compat
 > maasserver:0111_add_nodegroup_default_disable_ipv4
 > maasserver:0112_remove_boot_image_model
 > maasserver:0113_add_boot_source_cache_model
 > maasserver:0114_add_pxe_mac_to_node
 > maasserver:0115_unique_boot_source_selections
 > maasserver:0116_unique_boot_source_selections
 > maasserver:0117_delete_duplicate_config
 > maasserver:0118_config_key_unique
 > maasserver:0119_migrate_invalid_network_names
 > maasserver:0120_make_macaddress_node_nullable
 > maasserver:0121_recompute_storage_size
 > maasserver:0122_add_eventtype_level_index
 > maasserver:0123_add_physical_block_device_to_node
 > maasserver:0124_add_tags_to_block_device
 > maasserver:0125_add_installable_field_on_node
 > maasserver:0126_replace_storage_field_on_node
 > maasserver:0127_add_node_parent
 > maasserver:0128_add_id_path_to_blockdevice
 > maasserver:0129_add_partition_table_model
 > maasserver:0130_add_partition_model
 > maasserver:0131_add_filesystem_model
 > maasserver:0132_add_filesystem_group_model
 > maasserver:0133_add_virtual_block_device_model
 > maasserver:0134_specify_swap_size
 > maasserver:0135_staticipaddress_hostname
 > maasserver:0136_fix_nodegroup_name
 > maasserver:0137_cluster_status_change_pending_to_disabled
 > maasserver:0138_perf_index_on_node_events
 > maasserver:0139_power_parameters_and_state_updated_field
 > maasserver:0139_z_add_vlan_fabric
 > maasserver:0140_create_default_fabric_vlan
 > maasserver:0141_add_interface
 > maasserver:0142_add_space_subnet
 > maasserver:0143_create_default_space
 > maasserver:0144_add_unique_filesystem_to_block_device_and_partition
 > maasserver:0145_add_nodegroupinterface_subnet_link
 > maasserver:0146_populate_subnets
 > maasserver:0147_add_ip_connections
 > maasserver:0148_remove_path_from_block_device
 > maasserver:0149_add_label_to_filesystem
 > maasserver:0151_add_partition_number_to_partition
 > maasserver:0152_add_hwe_kernel_to_Node
 > maasserver:0153_add_bcache_type
 > maasserver:0154_migrate_arch_kernel_to_min_hwe_kernel
 > maasserver:0155_remove_start_offset_and_partition_number_from_partition
 > maasserver:0156_add_bios_boot_method_to_node
 > maasserver:0157_add_boot_disk_to_node
 > maasserver:0158_remove_unidentified_phyisical_block_devices
 > maasserver:0159_remove_nodegroupinterface_unused_fields
 > maasserver:0160_add_cache_set_model
 > maasserver:0161_create_missing_physical_interfaces
 > maasserver:0162_remove_duplicate_interfaces
 > maasserver:0163_unique_mac_and_name_for_interface
 > maasserver:0164_move_ip_links_to_interface_table
 > maasserver:0165_remove_mac_to_ip_link
 > maasserver:0166_add_node_and_mac_address_to_interface_add_boot_interface_to_node
 > maasserver:0167_move_node_and_mac_to_interfaces_and_link_boot_interface
 > maasserver:0168_remove_mac_link_from_interfaces_and_pxe_mac_from_node
 > maasserver:0169_remove_mac_address_dhcplease_and_networks_model
 > maasserver:0170_add_boot_cluster_ip_to_node
 > maasserver:0171_add_enabled_to_interface_model
 > maasserver:0172_move_ngi_router_ip_to_subnet_gateway_ip
 > maasserver:0173_remove_ngi_router_ip
 > maasserver:0174_add_gateway_links_to_node
 > maasserver:0175_drop_dhcp_alloc_type_addresses
 > maasserver:0176_add_enable_ssh_and_block_poweroff_commissioning_attributes
 > maasserver:0177_add_skip_networking_to_node_model
 > maasserver:0178_add_fannetwork_model
 > maasserver:0179_add_acquired_to_filesystem_model
 > maasserver:0180_add_skip_storage_to_node_model
 > maasserver:0181_initial_storage_layouts
 > maasserver:0182_initial_networking_layout
 > maasserver:0183_remove_required_name_from_vlan_and_fabric
 > maasserver:0184_add_action_to_event
 > maasserver:0185_add_class_type_to_fabric
 > maasserver:0186_space_fabric_names_optional_and_not_unique
 > maasserver:0187_link_missing_subnets
 > maasserver:0188_dli_power_driver_system_id_to_outlet_id
 > maasserver:0189_remove_block_poweroff
 > maasserver:0190_add_mtu_to_vlan_model
 > maasserver:0191_remove_comma_from_dns_servers
 - Loading initial data for maasserver.
Traceback (most recent call last):
  File "/usr/sbin/maas-region-admin", line 68, in <module>
    main()
  File "/usr/sbin/maas-region-admin", line 64, in main
    run()
  File "/usr/sbin/maas-region-admin", line 57, in run
    management.execute_from_command_line()
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 107, in handle
    ignore_ghosts = ignore_ghosts,
  File "/usr/lib/python2.7/dist-packages/south/migration/__init__.py", line 219, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/usr/lib/python2.7/dist-packages/south/migration/migrators.py", line 237, in migrate_many
    self.load_initial_data(target, db=database)
  File "/usr/lib/python2.7/dist-packages/south/migration/migrators.py", line 228, in load_initial_data
    call_command('loaddata', 'initial_data', verbosity=self.verbosity, database=db)
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.7/dist-packages/django/core/management/commands/loaddata.py", line 55, in handle
    self.loaddata(fixture_labels)
  File "/usr/lib/python2.7/dist-packages/django/core/management/commands/loaddata.py", line 84, in loaddata
    self.load_label(fixture_label)
  File "/usr/lib/python2.7/dist-packages/django/core/management/commands/loaddata.py", line 140, in load_label
    obj.save(using=self.using)
  File "/usr/lib/python2.7/dist-packages/django/core/serializers/base.py", line 164, in save
    models.Model.save_base(self.object, using=using, raw=True)
  File "/usr/lib/python2.7/dist-packages/django/db/models/base.py", line 573, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/usr/lib/python2.7/dist-packages/django/db/models/base.py", line 654, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/usr/lib/python2.7/dist-packages/django/db/models/base.py", line 687, in _do_insert
    using=using, raw=raw)
  File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py", line 232, in _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 1511, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 898, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: Problem installing fixture '/usr/lib/python2.7/dist-packages/metadataserver/fixtures/initial_data.yaml': Could not load auth.User(pk=1): duplicate key value violates unique constraint "auth_user_pkey"
DETAIL: Key (id)=(1) already exists.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

This seems like a problem in django actually rather than MAAS. Was this a clean system ?

summary: - loading initial data for maasserver: maas-region-admin reports duplicate
- key error during package install
+ [1.9] loading initial data for maasserver: maas-region-admin reports
+ duplicate key error during package install
Changed in maas:
status: New → Incomplete
milestone: none → 1.9.4
milestone: 1.9.4 → none
status: Incomplete → New
Revision history for this message
Chris Gregan (cgregan) wrote :

It was a clean system as far as it was previously deployed as a MAAS. It was then released and re-deployed.

Revision history for this message
John George (jog) wrote :

We've hit this two more times.

John George (jog)
tags: added: cdo-qa-blocker
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Are we still experiencing such issue?

Changed in maas:
status: New → Incomplete
Revision history for this message
John George (jog) wrote :

Yes, hit it today with ppa:maas/proposed.

Chris Gregan (cgregan)
Changed in maas:
status: Incomplete → Confirmed
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Can you provide the script you are using to run this automated process ? We never (ever) have hit this bug. It seems you may be creating a user before maas has installed successfully.

Changed in maas:
status: Confirmed → Incomplete
Revision history for this message
John George (jog) wrote :

Ah, so if it's related to the timing of when a user is created, we do install the package and then shortly after call 'maas-region-admin createsuperuser ...'

Revision history for this message
John George (jog) wrote :
Revision history for this message
John George (jog) wrote :
Revision history for this message
John George (jog) wrote :

Do you have a suggestion for how the script could check to see if the pkg install scripts are actually complete? I figured dpkg would not return until it was actually done.

Revision history for this message
John George (jog) wrote :

or better yet can the packaging be updated to not return until MAAS is actually ready to use?

Revision history for this message
Andres Rodriguez (andreserl) wrote :

After looking at the scripts, I believe the issue is that you are trying to create a user before MAAS is fully installed. The configure_maas.py script is checking for the 'maas' metapackage. However, it is not really checking for its proper status, because the package should be in 'unpacked' status and not really installed. That said, since it is a metapackage, it will install only dependencies which may mean that maas-region-controller package is already installed.

maas-region-controller package is the one that installs and configures the DB. You script should do better checking:

1. Check for maas-region-controller status:

ubuntu@maas00:~$ dpkg-query --show --showformat='${db:Status-Status}\n' maas-region-controller
installed

2. Ensure that the region and postgresql are actually up and running (by checking the daemons).

Provided that this is CI script, marking this bug as invalid.

Changed in maas:
status: Incomplete → Invalid
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.