Skip to content

Commit

Permalink
Set EmsEvent ems_ref to event's uid, to avoid same-second collision
Browse files Browse the repository at this point in the history
EmsEvent.create_event drops "duplicate" events, determined by
(event_type, timestamp, chain_id, ems_id, ems_ref).
Container events had no ems_ref (and no chain_id), meaning events of same
type in same second collided and only one EmsEvent was created.
The lost events weren't handled by Automate / Policy.

Using k8s event's uid, not involvedObject's uid which still wouldn't
be unique (for repeating events on same object).

https://bugzilla.redhat.com/show_bug.cgi?id=1583832
  • Loading branch information
cben committed Jun 22, 2018
1 parent dd3a7ee commit 6d1cb2c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def extract_event_data(event)
:namespace => event.object.involvedObject.namespace,
:reason => event.object.reason,
:message => event.object.message,
:uid => event.object.involvedObject.uid
:uid => event.object.involvedObject.uid,
:event_uid => event.object.metadata.uid,
}

unless event.object.involvedObject.fieldPath.nil?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def self.event_to_hash(event, ems_id = nil)
:container_namespace => event[:container_namespace],
:container_name => event[:container_name],
:full_data => event,
:ems_id => ems_id
:ems_id => ems_id,
:ems_ref => event[:event_uid],
}

event_hash[ems_ref_key] = event[:uid]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def initialize(ems = nil)
:container_name => 'heapster',
:container_group_name => 'heapster-aas69',
:container_namespace => 'openshift-infra',
:event_type => 'POD_KILLING'
:event_type => 'POD_KILLING',
:event_uid => 'fa735ca9-4f7d-11e6-b177-525400c7c086',
}
event = array_recursive_ostruct(:object => kubernetes_event)
expect(test_class.new.extract_event_data(event)).to eq(expected_data)
Expand Down Expand Up @@ -162,7 +163,8 @@ def initialize(ems = nil)
:uid => '7599d451-4c1c-11e6-89dd-525400c7c086',
:container_replicator_name => 'mysql-1',
:container_namespace => 'proj',
:event_type => 'REPLICATOR_SUCCESSFULCREATE'
:event_type => 'REPLICATOR_SUCCESSFULCREATE',
:event_uid => '4c513e6d-525d-11e6-8564-525400c7c086',
}
event = array_recursive_ostruct(:object => kubernetes_event)
expect(test_class.new.extract_event_data(event)).to eq(expected_data)
Expand Down Expand Up @@ -213,7 +215,8 @@ def initialize(ems = nil)
'c75d2b66-6d5b-49e0-b906-1d8abaf3e73b',
:uid => 'd30a880d-dfa7-11e5-af89-525400c7c086',
:container_node_name => 'vm-test-03.example.com',
:event_type => 'NODE_REBOOTED'
:event_type => 'NODE_REBOOTED',
:event_uid => 'a4b92ae1-5251-11e6-8564-525400c7c086',
}
end

Expand Down

0 comments on commit 6d1cb2c

Please sign in to comment.