Skip to content

Commit

Permalink
Delete invalid nil timestamp event streams
Browse files Browse the repository at this point in the history
Until ManageIQ/manageiq-providers-kubernetes#501 code
lands, openshift events with nil timestamps will be added to event streams.

These are invalid events and really mess up our queries since we timestamp is a lookup
field and expected to use an index which doesn't happen when it's nil.
  • Loading branch information
jrafanie committed Aug 30, 2023
1 parent 62f0ee6 commit e5f65aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions db/migrate/20230830134742_delete_nil_timestamp_event_streams.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class DeleteNilTimestampEventStreams < ActiveRecord::Migration[6.1]
class EventStream < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
say_with_time("Deleting event_streams with nil timestamp values") do
EventStream.where(:timestamp => nil).delete_all
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require_migration

describe DeleteNilTimestampEventStreams do
let(:event_stream_stub) { migration_stub(:EventStream) }

migration_context :up do
it "removes nil timestamp events, leaving others" do
good = event_stream_stub.create!(:timestamp => Time.now.utc)
event_stream_stub.create!(:timestamp => nil)

migrate

expect(event_stream_stub.pluck(:id, :timestamp).flatten).to eq([good.id, good.timestamp])
end
end
end

0 comments on commit e5f65aa

Please sign in to comment.