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

Set smart_class_parameter override: false leads to error #1644

Closed
yuqo2450 opened this issue Jul 13, 2023 · 9 comments · Fixed by #1648
Closed

Set smart_class_parameter override: false leads to error #1644

yuqo2450 opened this issue Jul 13, 2023 · 9 comments · Fixed by #1648

Comments

@yuqo2450
Copy link
Contributor

SUMMARY

After setting the override argument of a smart class parameter to true and then reversing it back to false (without changing any other argument) I get an error.

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible [core 2.15.2rc1]
COLLECTION VERSION
theforeman.foreman      3.12.0
KATELLO/FOREMAN VERSION
Foreman 3.2.1
Katello 4.4.2.2
STEPS TO REPRODUCE
- name: Manage SCParams of apply_updates
  theforeman.foreman.smart_class_parameter:
    username: user.name
    password: superSecurePassword
    server_url: "https://foreman.example.com"
    validate_certs: false
    puppetclass_name: yum_cron
    parameter: apply_updates
    state: present
    override: true
    parameter_type: string
    default_value: "somestring"

- name: Manage SCParams of apply_updates
  theforeman.foreman.smart_class_parameter:
    username: user.name
    password: superSecurePassword
    server_url: "https://foreman.example.com"
    validate_certs: false
    puppetclass_name: yum_cron
    parameter: apply_updates
    state: present
    override: false
    parameter_type: "string"
    default_value: "somestring"
EXPECTED RESULTS

Override should be set to false.

ACTUAL RESULTS

Error:

Error while performing update on smart_class_parameters:
500 Server Error: Internal Server Error for url:
https://foreman.example.com/foreman_puppet/api/smart_class_parameters/2274

Checkmode:

--- before
+++ after
@@ -9,10 +9,10 @@
             "merge_default": false,
             "merge_overrides": false,
             "omit": false,
-            "override": true,
+            "override": false,
             "override_value_order": "fqdn\nhostgroup\nos\ndomain",
             "override_values": [],
-            "parameter_type": "string",
+            "parameter_type": "",
             "required": false,
             "validator_type": ""
@evgeni
Copy link
Member

evgeni commented Jul 13, 2023

Is there anything useful in the Foreman log (/var/log/foreman/production.log)?

@yuqo2450
Copy link
Contributor Author

This is the whole log for a single parameter:

2023-07-19T08:20:13 [I|app|2782ce23] Started GET "/api/status" for 10.164.19.139 at 2023-07-19 08:20:13 +0200
2023-07-19T08:20:13 [I|app|2782ce23] Processing by Api::V2::HomeController#status as JSON
2023-07-19T08:20:13 [I|app|2782ce23]   Parameters: {"apiv"=>"v2"}
2023-07-19T08:20:13 [I|app|2782ce23] Authorized user some-user(some-user)
2023-07-19T08:20:13 [I|app|2782ce23]   Rendering api/v2/home/status.json.rabl
2023-07-19T08:20:13 [I|app|2782ce23]   Rendered api/v2/home/status.json.rabl (Duration: 4.9ms | Allocations: 5774)
2023-07-19T08:20:13 [I|app|2782ce23] Completed 200 OK in 112ms (Views: 5.4ms | ActiveRecord: 11.2ms | Allocations: 14127)
2023-07-19T08:20:13 [I|app|ebc0fb84] Started GET "/foreman_puppet/api/smart_class_parameters?search=puppetclass_name%3Dyum_cron+and+parameter%3Dexclude_packages&per_page=4294967296" for 10.164.19.139 at 2023-07-19 08:20:13 +0200
2023-07-19T08:20:13 [I|app|ebc0fb84] Processing by ForemanPuppet::Api::V2::SmartClassParametersController#index as JSON
2023-07-19T08:20:13 [I|app|ebc0fb84]   Parameters: {"search"=>"puppetclass_name=yum_cron and parameter=exclude_packages", "per_page"=>"4294967296", "apiv"=>"v2"}
2023-07-19T08:20:13 [I|app|ebc0fb84]   Rendering /usr/share/gems/gems/foreman_puppet-3.0.7/app/views/foreman_puppet/api/v2/smart_class_parameters/index.json.rabl within api/v2/layouts/index_layout
2023-07-19T08:20:13 [I|app|ebc0fb84]   Rendered /usr/share/gems/gems/foreman_puppet-3.0.7/app/views/foreman_puppet/api/v2/smart_class_parameters/index.json.rabl within api/v2/layouts/index_layout (Duration: 13.0ms | Allocations: 5189)
2023-07-19T08:20:13 [I|app|ebc0fb84] Completed 200 OK in 85ms (Views: 13.5ms | ActiveRecord: 65.4ms | Allocations: 11029)
2023-07-19T08:20:13 [I|app|5e40ddcd] Started GET "/foreman_puppet/api/smart_class_parameters/4407" for ip-address at 2023-07-19 08:20:13 +0200
2023-07-19T08:20:13 [I|app|5e40ddcd] Processing by ForemanPuppet::Api::V2::SmartClassParametersController#show as JSON
2023-07-19T08:20:13 [I|app|5e40ddcd]   Parameters: {"apiv"=>"v2", "id"=>"4407"}
2023-07-19T08:20:13 [I|app|5e40ddcd]   Rendering /usr/share/gems/gems/foreman_puppet-3.0.7/app/views/foreman_puppet/api/v2/smart_class_parameters/show.json.rabl
2023-07-19T08:20:13 [I|app|5e40ddcd]   Rendered /usr/share/gems/gems/foreman_puppet-3.0.7/app/views/foreman_puppet/api/v2/smart_class_parameters/show.json.rabl (Duration: 14.6ms | Allocations: 6968)
2023-07-19T08:20:13 [I|app|5e40ddcd] Completed 200 OK in 25ms (Views: 14.4ms | ActiveRecord: 3.7ms | Allocations: 10766)
2023-07-19T08:20:13 [I|app|22f9fb37] Started PUT "/foreman_puppet/api/smart_class_parameters/4407" for ip-address at 2023-07-19 08:20:13 +0200
2023-07-19T08:20:13 [I|app|22f9fb37] Processing by ForemanPuppet::Api::V2::SmartClassParametersController#update as JSON
2023-07-19T08:20:13 [I|app|22f9fb37]   Parameters: {"smart_class_parameter"=>{"override"=>false, "default_value"=>"[FILTERED]", "parameter_type"=>""}, "apiv"=>"v2", "id"=>"4407"}
2023-07-19T08:20:13 [W|app|22f9fb37] Action failed
2023-07-19T08:20:13 [I|app|22f9fb37] Backtrace for 'Action failed' error (ActiveRecord::RecordInvalid): Validation failed: Override must be true to edit the parameter
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:80:in `raise_validation_error'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:53:in `save!'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in `block in save!'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:278:in `transaction'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in `save!'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/suppressor.rb:48:in `save!'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/persistence.rb:635:in `block in update!'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/persistence.rb:633:in `update!'
 22f9fb37 | /usr/share/gems/gems/foreman_puppet-3.0.7/app/controllers/foreman_puppet/api/v2/smart_class_parameters_controller.rb:64:in `update'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/abstract_controller/base.rb:195:in `process_action'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:112:in `block in run_callbacks'
 22f9fb37 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 22f9fb37 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 22f9fb37 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 22f9fb37 | /usr/share/gems/gems/audited-4.9.0/lib/audited/sweeper.rb:14:in `around'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 22f9fb37 | /usr/share/gems/gems/audited-4.9.0/lib/audited/sweeper.rb:14:in `around'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:139:in `run_callbacks'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/abstract_controller/callbacks.rb:41:in `process_action'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/rescue.rb:22:in `process_action'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/notifications.rb:180:in `block in instrument'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/notifications.rb:180:in `instrument'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
 22f9fb37 | /usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/abstract_controller/base.rb:136:in `process'
 22f9fb37 | /usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/rendering.rb:39:in `process'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal.rb:190:in `dispatch'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal.rb:254:in `dispatch'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/routing/mapper.rb:48:in `serve'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/journey/router.rb:49:in `block in serve'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/journey/router.rb:32:in `each'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/journey/router.rb:32:in `serve'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/routing/route_set.rb:834:in `call'
 22f9fb37 | /usr/share/gems/gems/railties-6.0.3.7/lib/rails/engine.rb:527:in `call'
 22f9fb37 | /usr/share/gems/gems/railties-6.0.3.7/lib/rails/railtie.rb:190:in `public_send'
 22f9fb37 | /usr/share/gems/gems/railties-6.0.3.7/lib/rails/railtie.rb:190:in `method_missing'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/routing/mapper.rb:48:in `serve'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/journey/router.rb:49:in `block in serve'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/journey/router.rb:32:in `each'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/journey/router.rb:32:in `serve'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/routing/route_set.rb:834:in `call'
 22f9fb37 | /usr/share/gems/gems/katello-4.4.2.2/lib/katello/middleware/organization_created_enforcer.rb:18:in `call'
 22f9fb37 | /usr/share/gems/gems/katello-4.4.2.2/lib/katello/middleware/event_daemon.rb:10:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/apipie-dsl-2.4.0/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 22f9fb37 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/static_dispatcher.rb:66:in `call'
 22f9fb37 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/extractor/recorder.rb:137:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 22f9fb37 | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 22f9fb37 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 22f9fb37 | /usr/share/foreman/lib/foreman/middleware/catch_json_parse_errors.rb:9:in `call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb:15:in `call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/etag.rb:27:in `call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/conditional_get.rb:40:in `call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
 22f9fb37 | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/cookies.rb:648:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:101:in `run_callbacks'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 22f9fb37 | /usr/share/gems/gems/railties-6.0.3.7/lib/rails/rack/logger.rb:37:in `call_app'
 22f9fb37 | /usr/share/gems/gems/railties-6.0.3.7/lib/rails/rack/logger.rb:28:in `call'
 22f9fb37 | /usr/share/gems/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 22f9fb37 | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/request_id.rb:27:in `call'
 22f9fb37 | /usr/share/gems/gems/katello-4.4.2.2/lib/katello/prevent_json_parsing.rb:12:in `call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
 22f9fb37 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/executor.rb:14:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
 22f9fb37 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_dispatch/middleware/host_authorization.rb:76:in `call'
 22f9fb37 | /usr/share/gems/gems/secure_headers-6.3.0/lib/secure_headers/middleware.rb:11:in `call'
 22f9fb37 | /usr/share/gems/gems/railties-6.0.3.7/lib/rails/engine.rb:527:in `call'
 22f9fb37 | /usr/share/gems/gems/railties-6.0.3.7/lib/rails/railtie.rb:190:in `public_send'
 22f9fb37 | /usr/share/gems/gems/railties-6.0.3.7/lib/rails/railtie.rb:190:in `method_missing'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:74:in `block in call'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `each'
 22f9fb37 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `call'
 22f9fb37 | /usr/share/gems/gems/puma-5.5.2/lib/puma/configuration.rb:249:in `call'
 22f9fb37 | /usr/share/gems/gems/puma-5.5.2/lib/puma/request.rb:77:in `block in handle_request'
 22f9fb37 | /usr/share/gems/gems/puma-5.5.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
 22f9fb37 | /usr/share/gems/gems/puma-5.5.2/lib/puma/request.rb:76:in `handle_request'
 22f9fb37 | /usr/share/gems/gems/puma-5.5.2/lib/puma/server.rb:447:in `process_client'
 22f9fb37 | /usr/share/gems/gems/puma-5.5.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
 22f9fb37 | /usr/share/gems/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2023-07-19T08:20:13 [I|app|22f9fb37]   Rendering api/v2/errors/standard_error.json.rabl within api/v2/layouts/error_layout
2023-07-19T08:20:13 [I|app|22f9fb37]   Rendered api/v2/errors/standard_error.json.rabl within api/v2/layouts/error_layout (Duration: 1.1ms | Allocations: 1687)
2023-07-19T08:20:13 [I|app|22f9fb37] Completed 500 Internal Server Error in 17ms (Views: 2.8ms | ActiveRecord: 2.4ms | Allocations: 10939)

Hope it helps!

@evgeni
Copy link
Member

evgeni commented Jul 19, 2023

The relevant line is:

(ActiveRecord::RecordInvalid): Validation failed: Override must be true to edit the parameter

While I think this should be better visible in the error returned via HTTP, I think you can't set override false in this context.

@yuqo2450
Copy link
Contributor Author

Oh now I see I forgot to post the relevant output in the error. MB!

My question then is how can I undo a parameter override?
I am not trying to change anything except the override attribute and still get a change. In the GUI I can set override to false and it works. I wanna do the same thing with this Ansible module.

@evgeni
Copy link
Member

evgeni commented Jul 19, 2023

I gotta try this out myself when back in the office, I agree that you should be able, just no idea why it refuses to.

Maybe because it thinks it's a good idea to change the type and that is considered an override worthy change? (But your playbook doesn't mention that change, just the diff, weird)

@yuqo2450
Copy link
Contributor Author

yuqo2450 commented Jul 19, 2023

I found this in the source code. Maybe this is helpful:

# When override is set to false, foreman API don't accept parameter_type and all 'override options' have to be set to false if present
        if not module_params.get('override', False):
            module_params['parameter_type'] = ''

It seems when override is false the parameter type is set to empty string. It might be better to set it to None or remove it completely from the entity?

@evgeni
Copy link
Member

evgeni commented Jul 19, 2023

Yeah, probably worth a try to use None here

@yuqo2450
Copy link
Contributor Author

This seems to be the solution.

Changing the value here from empty string to None changes the override attribute of the parameter back to false.

Would be amazing if you could test it your own and maybe implement it asap?

@evgeni
Copy link
Member

evgeni commented Jul 19, 2023

I'm back in the office next week, and will have a look then

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

Successfully merging a pull request may close this issue.

2 participants