While disabling sync plan on Satellite 6, it fails with error "An error occurred saving the Sync Plan: undefined method `iso8601' for nil:NilClass"
Environment
- Red Hat Satellite 6.2
- Sync Plan
Issue
- When setting an existing sync plan to Disabled, it fails with the message:
An error occurred saving the Sync Plan: undefined method `iso8601' for nil:NilClass
-
Cannot disable sync plan.
-
Sync plan throws error when trying to disable.
-
Modifying a Sync Plan fails with error An error occurred saving the Sync Plan: base Start Date and Time can't be blank
2017-12-19 09:30:21 f26fcc55 [app] [I] Started PUT "/katello/api/v2/organizations/1/sync_plans/1" for 192.168.100.1 at 2017-12-19 09:30:21 +0100
2017-12-19 09:30:21 f26fcc55 [app] [I] Processing by Katello::Api::V2::SyncPlansController#update as JSON
2017-12-19 09:30:21 f26fcc55 [app] [I] Parameters: {"id"=>"1", "organization_id"=>"1", "name"=>"Sync test 3", "description"=>nil, "interval"=>"hourly", "next_sync"=>"2017/12/30 15:10:00 CET", "created_at"=>"2017-09-11 15:12:05 +0200", "updated_at"=>"2017-12-19 09:29:51 +0100", "enabled"=>true, "products"=>[{"id"=>141, "cp_id"=>"69", "name"=>"Red Hat Enterprise Linux Server", "label"=>"Red_Hat_Enterprise_Linux_Server", "description"=>nil, "sync_state"=>"Running", "last_sync"=>"2017-12-13 15:25:45 +0100", "last_sync_words"=>"6 days", "repository_count"=>44}], "permissions"=>{"view_sync_plans"=>true, "edit_sync_plans"=>true, "destroy_sync_plans"=>true}, "sync_date"=>"Invalid Date", "syncTime"=>"2017/12/30 15:10:00 CET", "syncDate"=>"2017/12/30 15:10:00 CET", "api_version"=>"v2", "sync_plan"=>{"id"=>"1", "name"=>"Daily Sync test 3", "description"=>nil, "sync_date"=>"Invalid Date", "interval"=>"hourly", "organization_id"=>"1", "created_at"=>"2017-09-11 15:12:05 +0200", "updated_at"=>"2017-12-19 09:29:51 +0100", "enabled"=>true}}
2017-12-19 09:30:22 f26fcc55 [foreman-tasks/action] [E] Validation failed: Start Date and Time can't be blank (ActiveRecord::RecordInvalid)
| /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/validations.rb:57:in `save!'
| /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
| /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/transactions.rb:273:in `block in save!'
| /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
| /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/database_statements.rb:199:in `transaction'
Resolution
- Change the sync plan start date to any point in the future, save the sync plan, then disable the sync plan:
- Log into the Satellite administration web UI as an organization admin
- Click
Content
->Sync Plans
- Click the Sync Plan you wish to disable
- Click the date and choose an appropriate date and time in the future.
- Click the
Save
button. - Click the
Yes
item next toSync Enabled
and uncheck it to disable it. - Click the
Save
button. The Sync Plan is now successfully disabled.
WORKAROUND
- Official fix for this issue would be fixed in Red Hat Satellite 6.3 GA. For temporary workaround follow the below steps on Red Hat Satellite server.
[root@satellite ~]# cd /opt/theforeman/tfm/root/usr/share/gems/gems/katello-*/app/models/katello/
[root@satellite ~]# cp -p sync_plan.rb sync_plan.rb.original
[root@satellite ~]# vi sync_plan.rb
self.sync_date.strftime('%Y/%m/%d %H:%M:%S %Z') -----> change this line as listed below
self.sync_date.strftime('%Y/%m/%d %H:%M:%S %z') -----> Z to be replace with small z
And
next_sync_date.try(:strftime, '%Y/%m/%d %H:%M:%S %Z') -----> change this line as listed below
next_sync_date.try(:strftime, '%Y/%m/%d %H:%M:%S %z') -----> Z to be replace with small z
- After modifying above 2 lines restart
httpd
service
[root@satellite ~]# systemctl restart httpd
- Now try to modify the sync plan, which shouldn't throw any Invalid Date errors.
Root Cause
- Satellite 6.2 web interface won't accept deactivating a sync plan with a start date in the past.
Diagnostic Steps
On Satellite 6.2 web interface, locate a sync plan that is currently active and has a start date in the past. Deactivate it without changing the start date. If it fails, then the start date should be changed to any point in the future.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments