Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions source/code/plugin/in_containerinventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def enumerate
container = ContainerInventoryState.readContainerState(deletedContainer)
if !container.nil?
container.each { |k, v| container[k] = v }
container["State"] = "Deleted"
@@containerCGroupCache.delete(container["InstanceID"])
container["State"] = "Deleted"
KubernetesContainerInventory.deleteCGroupCacheEntryForDeletedContainer(container["InstanceID"])
containerInventory.push container
end
end
Expand Down
22 changes: 22 additions & 0 deletions source/code/plugin/kubernetes_container_inventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class KubernetesContainerInventory
require "yajl/json_gem"
require "time"
require_relative "omslog"
require_relative "ApplicationInsightsUtility"

# cache the container and cgroup parent process
@@containerCGroupCache = Hash.new

Expand Down Expand Up @@ -116,6 +118,8 @@ def getContainerInventoryRecords(podItem, batchTime, clusterCollectEnvironmentVa
end
rescue => error
@log.warn("KubernetesContainerInventory::getContainerInventoryRecords : Get Container Inventory Records failed: #{error}")
$log.debug_backtrace(error.backtrace)
ApplicationInsightsUtility.sendExceptionTelemetry(error)
end
return containerInventoryRecords
end
Expand Down Expand Up @@ -157,6 +161,8 @@ def getContainersInfoMap(podItem, isWindows)
end
rescue => error
@log.warn("KubernetesContainerInventory::getContainersInfoMap : Get Container Info Maps failed: #{error}")
$log.debug_backtrace(error.backtrace)
ApplicationInsightsUtility.sendExceptionTelemetry(error)
end
return containersInfoMap
end
Expand Down Expand Up @@ -215,6 +221,8 @@ def obtainContainerEnvironmentVars(containerId)
end
rescue => error
@log.warn("KubernetesContainerInventory::obtainContainerEnvironmentVars: obtain Container Environment vars failed: #{error} for containerId: #{containerId}")
$log.debug_backtrace(error.backtrace)
ApplicationInsightsUtility.sendExceptionTelemetry(error)
end
return envValueString
end
Expand Down Expand Up @@ -292,8 +300,22 @@ def obtainWindowsContainerEnvironmentVars(pod, container)
end
rescue => error
@log.warn("KubernetesContainerInventory::obtainWindowsContainerEnvironmentVars: parsing of EnvVars failed: #{error}")
$log.debug_backtrace(error.backtrace)
ApplicationInsightsUtility.sendExceptionTelemetry(error)
end
return envValueString
end

def deleteCGroupCacheEntryForDeletedContainer(containerId)
begin
if !containerId.nil? && !containerId.empty? && !@@containerCGroupCache.nil? && @@containerCGroupCache.length > 0 && @@containerCGroupCache.key?(containerId)
@@containerCGroupCache.delete(containerId)
end
rescue => error
@log.warn("KubernetesContainerInventory::deleteCGroupCacheEntryForDeletedContainer: deleting of cache entry failed: #{error}")
$log.debug_backtrace(error.backtrace)
ApplicationInsightsUtility.sendExceptionTelemetry(error)
end
end
end
end