Bug #29
TimeWithZone with String failed
| Status: | Closed | Start: | 09/22/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assigned to: | % Done: | 100% |
||
| Category: | Importers | |||
| Target version: | 0.1-2 | |||
| Backlog: | Difficulity: | |||
| Votes: | 0 |
Description
Getting the below on the second run of the script with a new host. Changing /var/www/html/foreman/app/models/host.rb:177
--- if last_compile.nil? or (last_compile + 1.minute < facts.values[:_timestamp])
+++ if last_compile.nil? or ((last_compile + 1.minute).to_s < facts.values[:_timestamp])
Fixes the issue.
- rake puppet:import:hosts_and_facts RAILS_ENV=production --trace
(in /var/www/html/foreman)- Invoke puppet:import:hosts_and_facts (first_time)
- Invoke environment (first_time)
- Execute environment
- Execute puppet:import:hosts_and_facts
Importing from /var/lib/puppet/yaml/facts
Importing localhost
Tue Sep 22 17:23:01 +0100 2009
rake aborted!
comparison of ActiveSupport::TimeWithZone with String failed
/var/www/html/foreman/app/models/host.rb:178:in `<'
/var/www/html/foreman/app/models/host.rb:178:in `importFacts'
/var/www/html/foreman/app/models/host.rb:167:in `importHostAndFacts'
/var/www/html/foreman/lib/tasks/puppet.rake:34
/var/www/html/foreman/lib/tasks/puppet.rake:31:in `each'
/var/www/html/foreman/lib/tasks/puppet.rake:31
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:238:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Associated revisions
History
Updated by Ohad Levy over 2 years ago
- Category set to Importers
- Status changed from New to Assigned
- Assigned to set to Ohad Levy
- Priority changed from High to Normal
- Target version set to 0.1-2
strange enough, this doesnt happen in my setup, as the facts.values[:_timestamp] is a datetime object.
which version of Puppet are you using?
Does it happen to you also when you use the http importer? Puppet_Facts
Updated by Matt Moran over 2 years ago
I'm running puppet 0.25, maybe this is the issue? Probably some ruby beforehand to check what type the values are before doing the compare? I haven't tried the http importer yet.
Updated by Ohad Levy over 2 years ago
Matt Moran wrote:
I'm running puppet 0.25, maybe this is the issue? Probably some ruby beforehand to check what type the values are before doing the compare? I haven't tried the http importer yet.
no, I've tested with 0.25 and 0.24 :(
I'll appreciate it if you can give the http importer a try, nevertheless, I don't expect a big difference.
I'll try to see if your patch breaks any other tests before committing it.
Updated by Ohad Levy over 2 years ago
- Status changed from Assigned to Feedback
- Assigned to changed from Ohad Levy to Matt Moran
could you test if the following diff is working for you?
diff --git a/app/models/host.rb b/app/models/host.rb
index 0996274..4502808 100644
--- a/app/models/host.rb
+++ b/app/models/host.rb
@@ -176,9 +176,10 @@ class Host < Puppet::Rails::Host
# we are not importing facts for hosts in build state (e.g. waiting for a re-installation)
raise "Host is pending for Build" if build
-
- if last_compile.nil? or (last_compile + 1.minute < facts.values[:_timestamp])
- self.last_compile = facts.values[:_timestamp]
+ time = facts.values[:_timestamp]
+ time = time.to_time if time.is_a?(String)
+ if last_compile.nil? or (last_compile + 1.minute < time)
+ self.last_compile = time
begin
# save all other facts
if self.respond_to?("merge_facts")
The main reason I'm changing your patch is that I dont want it to be stored as a string.
Thanks
Updated by Matt Moran over 2 years ago
- Status changed from Feedback to Closed
- % Done changed from 0 to 100
Works for me.
