Project

General

Profile

Bug #2788

adding / removing puppet classes updates the change even if the form is not submitted

Added by Ohad Levy over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Web Interface
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

when I've played with the edit classes (under host for example), I've noticed new audit messages.

further investigation reveals the following:

Started POST "/puppetclasses/422/parameters" for 127.0.0.1 at Sun Jul 14 21:04:36 +0300 2013
Processing by PuppetclassesController#parameters as */*
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"3iZZZZ+73n61+r9eXF1d0KiuAY7F1CkOj58BwRraSjE=", "capabilities"=>"build", "host"=>{"hostgroup_id"=>"1", "environment_id"=>"1", "provision_method"=>"build", "is_owned_by"=>"1-Users", "puppet_proxy_id"=>"7", "comment"=>"", "overwrite"=>"false", "puppetclass_ids"=>["", "383", "422"], "enabled"=>"1", "mac"=>"52:54:00:6d:c3:7a", "ptable_id"=>"14", "managed"=>"t", "subnet_id"=>"1", "interfaces_attributes"=>{"new_interfaces"=>{"mac"=>"", "subnet_id"=>"", "name"=>"", "provider"=>"IPMI", "type"=>"Nic::Managed", "_destroy"=>"false", "domain_id"=>"", "ip"=>""}}, "architecture_id"=>"1", "name"=>"6", "puppet_ca_proxy_id"=>"7", "operatingsystem_id"=>"41", "disk"=>"", "root_pass"=>"[FILTERED]", "domain_id"=>"6", "progress_report_id"=>"[FILTERED]", "ip"=>"10.35.27.9", "medium_id"=>"3"}, "id"=>"422", "host_id"=>"926"}
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 1]]
Setting current user thread-local variable to admin
   (0.2ms)  SELECT COUNT(*) FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location')
Setting current location thread-local variable to none
   (0.1ms)  SELECT id FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location') LIMIT 1
  Puppetclass Load (0.1ms)  SELECT "puppetclasses".* FROM "puppetclasses" WHERE "puppetclasses"."id" = ? ORDER BY puppetclasses.name LIMIT 1  [["id", "422"]]
  Host::Base Load (0.4ms)  SELECT "hosts".* FROM "hosts" WHERE "hosts"."id" = 926 LIMIT 1
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY firstname LIMIT 1  [["id", 1]]
  Puppetclass Load (0.2ms)  SELECT "puppetclasses".* FROM "puppetclasses" WHERE "puppetclasses"."id" IN (383, 422) ORDER BY puppetclasses.name
  Puppetclass Load (0.2ms)  SELECT "puppetclasses".* FROM "puppetclasses" INNER JOIN "host_classes" ON "puppetclasses"."id" = "host_classes"."puppetclass_id" WHERE "host_classes"."host_id" = 926 ORDER BY puppetclasses.name
   (0.1ms)  begin transaction
  HostClass Exists (0.2ms)  SELECT 1 AS one FROM "host_classes" WHERE ("host_classes"."puppetclass_id" = 422 AND "host_classes"."host_id" = 926) LIMIT 1
  SQL (0.4ms)  INSERT INTO "host_classes" ("host_id", "puppetclass_id") VALUES (?, ?)  [["host_id", 926], ["puppetclass_id", 422]]
  Host::Managed Load (0.3ms)  SELECT "hosts".* FROM "hosts" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."id" = 926 LIMIT 1
  HostClass Load (0.1ms)  SELECT "host_classes".* FROM "host_classes" WHERE "host_classes"."id" = 245 LIMIT 1
  CACHE (0.0ms)  SELECT "hosts".* FROM "hosts" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."id" = 926 LIMIT 1
  Puppetclass Load (0.1ms)  SELECT "puppetclasses".* FROM "puppetclasses" WHERE "puppetclasses"."id" = 422 ORDER BY puppetclasses.name LIMIT 1
   (0.1ms)  SELECT MAX("audits"."version") AS max_id FROM "audits" WHERE "audits"."auditable_id" = 245 AND "audits"."auditable_type" = 'HostClass'

The host in question was not submitted, however it did get saved to the db via AJAX?

Associated revisions

Revision 0ba99bba (diff)
Added by Joseph Magen over 6 years ago

fixes #2788 - adding / removing puppet classes updates the change even if the form is not submitted

Revision 1ef5ee75 (diff)
Added by Joseph Magen over 6 years ago

fixes #2788 - changes to fixtures and tests in preparation for testing adding/removing puppetclasses

Revision 63450d30 (diff)
Added by Joseph Magen over 6 years ago

fixes #2788 - adding / removing puppet classes updates the change even if the form is not submitted

(cherry picked from commit 0ba99bba2c7496fd44822dd5f2e6b4ccda19177b)

Revision afd23f98 (diff)
Added by Joseph Magen over 6 years ago

fixes #2788 - changes to fixtures and tests in preparation for testing adding/removing puppetclasses

(cherry picked from commit 1ef5ee75d794f024c75d6be96ac04ff398118e26)

Conflicts:
test/fixtures/lookup_keys.yml

History

#1 Updated by Ohad Levy over 6 years ago

It seems that the problem exists because of https://github.com/theforeman/foreman/blob/develop/app/controllers/puppetclasses_controller.rb#L80

where @host.attributes = form_attributes triggers a update of the HostClass object.

#2 Updated by Joseph Magen over 6 years ago

  • Status changed from New to Assigned
  • Assignee set to Joseph Magen

#3 Updated by Joseph Magen over 6 years ago

  • Status changed from Assigned to Ready For Testing

#4 Updated by Joseph Magen over 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF