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

(PDB-5227) POC don't store report if resource event has oversized data #3553

Draft
wants to merge 1 commit into
base: 6.x
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion puppet/lib/puppet/reports/puppetdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def process
profile("report#process", [:puppetdb, :report, :process]) do
current_time = Time.now
submit_command(self.host, CommandStoreReport, 8, current_time.utc) do
report_to_hash(current_time)
begin
report_to_hash(current_time)
rescue OversizedIndexException => e
puts e.resource
end
end
end

Expand Down Expand Up @@ -183,6 +187,14 @@ def build_events_list(events)
end
end

class OversizedIndexException < StandardError
attr_reader :resource
def initialize(msg="Default message", resource="")
@resource = resource
super(msg)
end
end

# Convert an instance of `Puppet::Resource::Status` to a hash
# suitable for sending over the wire to PuppetDB
#
Expand All @@ -199,6 +211,7 @@ def resource_status_to_hash(resource_status)
end

if index_size > 2704
raise OversizedIndexException.new("error!", resource_status)
Puppet.warning("resource_event on #{self.host} could not be saved. Values (resource timestamp + title + type) are larger \
than index total size of 2704. Caused by Resource type: \"#{resource_status.resource_type}\" with title: \
\"#{resource_status.title.to_s}\" in #{resource_status.file}:#{resource_status.line}")
Expand Down