Bug 970743

Summary: Foreman subnet network field entry throws Postgres error if IP too long
Product: Red Hat Satellite Reporter: Mike McCune <mmccune>
Component: ProvisioningAssignee: jmagen <jmagen>
Status: CLOSED CURRENTRELEASE QA Contact: Katello QA List <katello-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: NightlyCC: bkearney, cwelton, dcleal, omaciel, skottler
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/2285
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-18 21:22:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mike McCune 2013-06-04 18:30:39 UTC
When creating a subnet in Foreman I mistakenly entered:

https://<foremanhost>/foreman/subnets/new

192.168.100.0/24 into the network name.  This generated:

PGError: ERROR: value too long for type character varying(15) : INSERT INTO "subnets" ("created_at", "dhcp_id", "dns_id", "dns_primary", "dns_secondary", "from", "gateway", "mask", "name", "network", "priority", "tftp_id", "to", "updated_at", "vlanid") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) RETURNING "id"

we should put some length validation on the network to make sure users don't mistakenly put in a bad network address.

Comment 1 Og Maciel 2013-06-04 18:33:45 UTC
Rolling back due to a problem: [Create DHCP Settings for mmccune.idm	 10	 failed	 [#<Host::Managed id: nil, name: "mmccune.idm", ip: "192.168.110.102", environment: nil, last_compile: nil, last_freshcheck: nil, last_report: nil, updated_at: nil, source_file_id: nil, created_at: nil, mac: "52:54:00:cf:23:2a", root_pass: nil, serial: nil, puppet_status: 0, domain_id: 6, architecture_id: 1, operatingsystem_id: 1, environment_id: 7, subnet_id: 8, ptable_id: 1, medium_id: 6, build: true, comment: "", disk: "", installed_at: nil, model_id: nil, hostgroup_id: 6, owner_id: 1, owner_type: "User", enabled: true, puppet_ca_proxy_id: 1, managed: true, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: 2, puppet_proxy_id: 2, certname: nil, image_id: nil, organization_id: 2, location_id: nil, type: "Host::Managed">, :set_dhcp]]
Failed to save: Create DHCP Settings for mmccune.idm task failed with the following error: 400 Bad Request
  Rendered hosts/_progress.erb (0.1ms)
  Rendered puppetclasses/_selectedClasses.html.erb (0.0ms)
  Rendered puppetclasses/_classes.html.erb (1.9ms)
  Rendered puppetclasses/_class_selection.html.erb (9.4ms)
  Rendered hosts/_compute.html.erb (0.7ms)
  Rendered common/_domain.html.erb (6.5ms)
  Rendered hosts/_interfaces.html.erb (8.7ms)
  Rendered common/os_selection/_architecture.html.erb (2.7ms)
  Rendered common/os_selection/_operatingsystem.html.erb (4.7ms)
  Rendered hosts/_operating_system.erb (12.4ms)
  Rendered hosts/_unattended.html.erb (35.1ms)
  Rendered puppetclasses/_class_parameters.html.erb (0.0ms)
  Rendered puppetclasses/_classes_parameters.html.erb (4.3ms)
  Rendered common_parameters/_inherited_parameters.erb (3.8ms)
  Rendered common_parameters/_puppetclass_parameter.erb (2.7ms)
  Rendered common_parameters/_puppetclasses_parameters.erb (4.1ms)
  Rendered common_parameters/_parameter.erb (1.1ms)
  Rendered common_parameters/_parameters.erb (2.0ms)
  Rendered hosts/_form.html.erb (93.1ms)
  Rendered hosts/new.html.erb within layouts/application (93.5ms)
  Rendered home/_user_dropdown.html.erb (1.0ms)
Read fragment views/tabs_and_title_records-1 (0.1ms)
  Rendered home/_topbar.html.erb (1.5ms)
Completed 200 OK in 334ms (Views: 86.2ms | ActiveRecord: 30.9ms)

Comment 2 Dominic Cleal 2013-06-04 18:36:53 UTC
(In reply to Og Maciel from comment #1)
> Rolling back due to a problem: [Create DHCP Settings for mmccune.idm	 10	
> failed	 [#<Host::Managed id: nil, name: "mmccune.idm", ip:
> "192.168.110.102", environment: nil, last_compile: nil, last_freshcheck:
> nil, last_report: nil, updated_at: nil, source_file_id: nil, created_at:
> nil, mac: "52:54:00:cf:23:2a", root_pass: nil, serial: nil, puppet_status:
> 0, domain_id: 6, architecture_id: 1, operatingsystem_id: 1, environment_id:
> 7, subnet_id: 8, ptable_id: 1, medium_id: 6, build: true, comment: "", disk:
> "", installed_at: nil, model_id: nil, hostgroup_id: 6, owner_id: 1,
> owner_type: "User", enabled: true, puppet_ca_proxy_id: 1, managed: true,
> use_image: nil, image_file: nil, uuid: nil, compute_resource_id: 2,
> puppet_proxy_id: 2, certname: nil, image_id: nil, organization_id: 2,
> location_id: nil, type: "Host::Managed">, :set_dhcp]]
> Failed to save: Create DHCP Settings for mmccune.idm task failed with the
> following error: 400 Bad Request

This is unrelated to the subnet network field in the description, it's an error from the proxy (the "400 Bad Request" is the HTTP response from it).

Comment 3 Dominic Cleal 2013-06-04 18:39:01 UTC
Validation is being added via upstream #2285, which will provide a better error message.

http://projects.theforeman.org/issues/2285
https://github.com/theforeman/foreman/pull/687

Comment 4 Dominic Cleal 2013-06-05 08:46:56 UTC
Fixed upstream via:

1.2-stable: 3d0287be8aa8dcc930431fbaf1a7514fc5dc7f52
develop: 31aa5db511a6decf800e68a2b6f6eb3dbf0ae29c

Comment 5 Brad Buckingham 2013-06-06 21:58:27 UTC
Mass move to ON_QA

Comment 6 Corey Welton 2013-06-07 16:01:21 UTC
This seems to be ok now. The initial report wasn't clear whether the subnet was entered in the Name or Address field, but I have tried both and items are correctly validated.  QE Verified.

* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.8.9-1.el6_4.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.8.9-1.el6_4.noarch
* candlepin-tomcat6-0.8.9-1.el6_4.noarch
* elasticsearch-0.19.9-8.el6sat.noarch
* foreman-1.1.10004-1.noarch
* foreman-compute-1.1.10004-1.noarch
* foreman-installer-puppet-concat-0-2.d776701.git.0.21ef926.el6sat.noarch
* foreman-installer-puppet-dhcp-0-5.3a4a13c.el6sat.noarch
* foreman-installer-puppet-dns-0-7.fcae203.el6sat.noarch
* foreman-installer-puppet-foreman-0-6.568c5c4.el6sat.noarch
* foreman-installer-puppet-foreman_proxy-0-8.bd1e35d.el6sat.noarch
* foreman-installer-puppet-puppet-0-3.ab46748.el6sat.noarch
* foreman-installer-puppet-tftp-0-5.ea6c5e5.el6sat.noarch
* foreman-installer-puppet-xinetd-0-50a267b8.git.0.44aca6a.el6sat.noarch
* foreman-libvirt-1.1.10004-1.noarch
* foreman-postgresql-1.1.10004-1.noarch
* foreman-proxy-1.1.10003-1.el6sat.noarch
* foreman-proxy-installer-1.0.1-8.f5ae2cd.el6sat.noarch
* katello-1.4.2-10.el6sat.noarch
* katello-all-1.4.2-10.el6sat.noarch
* katello-candlepin-cert-key-pair-1.0-1.noarch
* katello-certs-tools-1.4.2-2.el6sat.noarch
* katello-cli-1.4.2-7.el6sat.noarch
* katello-cli-common-1.4.2-7.el6sat.noarch
* katello-common-1.4.2-10.el6sat.noarch
* katello-configure-1.4.3-14.el6sat.noarch
* katello-configure-foreman-1.4.3-14.el6sat.noarch
* katello-foreman-all-1.4.2-10.el6sat.noarch
* katello-glue-candlepin-1.4.2-10.el6sat.noarch
* katello-glue-elasticsearch-1.4.2-10.el6sat.noarch
* katello-glue-pulp-1.4.2-10.el6sat.noarch
* katello-qpid-broker-key-pair-1.0-1.noarch
* katello-qpid-client-key-pair-1.0-1.noarch
* katello-selinux-1.4.3-3.el6sat.noarch
* openldap-2.4.23-31.el6.x86_64
* openldap-devel-2.4.23-31.el6.x86_64
* pulp-rpm-plugins-2.1.1-1.el6sat.noarch
* pulp-selinux-2.1.1-1.el6sat.noarch
* pulp-server-2.1.1-1.el6sat.noarch
* python-ldap-2.3.10-1.el6.x86_64
* ruby193-rubygem-ldap_fluff-0.2.2-1.el6sat.noarch
* ruby193-rubygem-net-ldap-0.3.1-2.el6sat.noarch
* signo-0.0.16-1.el6sat.noarch
* signo-katello-0.0.16-1.el6sat.noarch

Comment 7 Corey Welton 2013-06-07 16:02:21 UTC
(also tried the netmask field, just in case)

Comment 8 Mike McCune 2013-07-18 21:22:55 UTC
mass move to CLOSED:CURRENTRELEASE since MDP1 has been released.