Skip to content
Merged
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
12 changes: 4 additions & 8 deletions source/plugins/ruby/kubernetes_container_inventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ def getContainersInfoMap(podItem, isWindows)
return containersInfoMap
end

def obtainContainerEnvironmentVars(containerId)
$log.info("KubernetesContainerInventory::obtainContainerEnvironmentVars @ #{Time.now.utc.iso8601}")
def obtainContainerEnvironmentVars(containerId)
envValueString = ""
begin
isCGroupPidFetchRequired = false
Expand All @@ -207,8 +206,7 @@ def obtainContainerEnvironmentVars(containerId)
end
end

if isCGroupPidFetchRequired
$log.info("KubernetesContainerInventory::obtainContainerEnvironmentVars fetching cGroup parent pid @ #{Time.now.utc.iso8601} for containerId: #{containerId}")
if isCGroupPidFetchRequired
Dir["/hostfs/proc/*/cgroup"].each do |filename|
begin
if File.file?(filename) && File.exist?(filename) && File.foreach(filename).grep(/#{containerId}/).any?
Expand All @@ -231,8 +229,7 @@ def obtainContainerEnvironmentVars(containerId)
end
cGroupPid = @@containerCGroupCache[containerId]
if !cGroupPid.nil? && !cGroupPid.empty?
environFilePath = "/hostfs/proc/#{cGroupPid}/environ"
$log.info("KubernetesContainerInventory::obtainContainerEnvironmentVars cGroupPid: #{cGroupPid} environFilePath: #{environFilePath} for containerId: #{containerId}")
environFilePath = "/hostfs/proc/#{cGroupPid}/environ"
if File.exist?(environFilePath)
# Skip environment variable processing if it contains the flag AZMON_COLLECT_ENV=FALSE
# Check to see if the environment variable collection is disabled for this container.
Expand All @@ -245,8 +242,7 @@ def obtainContainerEnvironmentVars(containerId)
if !envVars.nil? && !envVars.empty?
envVars = envVars.split("\0")
envValueString = envVars.to_json
envValueStringLength = envValueString.length
$log.info("KubernetesContainerInventory::environment vars filename @ #{environFilePath} envVars size @ #{envValueStringLength}")
envValueStringLength = envValueString.length
if envValueStringLength >= 200000
lastIndex = envValueString.rindex("\",")
if !lastIndex.nil?
Expand Down