From d6b0d62556648c236060d999685cf81e49135343 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Mon, 27 Sep 2021 17:04:31 -0700 Subject: [PATCH 1/2] addon token adapter image tag --- source/plugins/ruby/in_containerinventory.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/plugins/ruby/in_containerinventory.rb b/source/plugins/ruby/in_containerinventory.rb index 9fcb7ab90..37912079c 100644 --- a/source/plugins/ruby/in_containerinventory.rb +++ b/source/plugins/ruby/in_containerinventory.rb @@ -57,6 +57,7 @@ def enumerate containerInventory = Array.new eventStream = Fluent::MultiEventStream.new hostName = "" + addonTokenAdapterImageTag = "" $log.info("in_container_inventory::enumerate : Begin processing @ #{Time.now.utc.iso8601}") if ExtensionUtils.isAADMSIAuthMode() $log.info("in_container_inventory::enumerate: AAD AUTH MSI MODE") @@ -82,6 +83,15 @@ def enumerate if hostName.empty? && !containerRecord["Computer"].empty? hostName = containerRecord["Computer"] end + if addonTokenAdapterImageTag.empty? && ExtensionUtils.isAADMSIAuthMode() + if !containerRecord["ElementName"].nil? && !containerRecord["ElementName"].empty? && + containerRecord["ElementName"].include?("kube-system") && + containerRecord["ElementName"].include?("addon-token-adapter_omsagent") + if !containerRecord["ImageTag"].nil? && !containerRecord["ImageTag"].empty? + addonTokenAdapterImageTag = containerRecord["ImageTag"] + end + end + end containerIds.push containerRecord["InstanceID"] containerInventory.push containerRecord end @@ -117,6 +127,9 @@ def enumerate telemetryProperties = {} telemetryProperties["Computer"] = hostName telemetryProperties["ContainerCount"] = containerInventory.length + if !addonTokenAdapterImageTag.empty? + telemetryProperties["addon-token-adapter"] = addonTokenAdapterImageTag + end ApplicationInsightsUtility.sendTelemetry(@@PluginName, telemetryProperties) end rescue => errorStr From 821748068d15f0b4975419bac187b32ac0c564ca Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Mon, 27 Sep 2021 17:32:36 -0700 Subject: [PATCH 2/2] addon token adapter image tag --- source/plugins/ruby/ApplicationInsightsUtility.rb | 3 +++ source/plugins/ruby/in_containerinventory.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/plugins/ruby/ApplicationInsightsUtility.rb b/source/plugins/ruby/ApplicationInsightsUtility.rb index eaa1d903d..7691304a6 100644 --- a/source/plugins/ruby/ApplicationInsightsUtility.rb +++ b/source/plugins/ruby/ApplicationInsightsUtility.rb @@ -243,6 +243,9 @@ def sendTelemetry(pluginName, properties) getContainerRuntimeInfo() end @@CustomProperties["Computer"] = properties["Computer"] + if !properties["addonTokenAdapterImageTag"].nil? && !properties["addonTokenAdapterImageTag"].empty? + @@CustomProperties["addonTokenAdapterImageTag"] = properties["addonTokenAdapterImageTag"] + end sendHeartBeatEvent(pluginName) sendLastProcessedContainerInventoryCountMetric(pluginName, properties) rescue => errorStr diff --git a/source/plugins/ruby/in_containerinventory.rb b/source/plugins/ruby/in_containerinventory.rb index 37912079c..f52ed4026 100644 --- a/source/plugins/ruby/in_containerinventory.rb +++ b/source/plugins/ruby/in_containerinventory.rb @@ -128,7 +128,7 @@ def enumerate telemetryProperties["Computer"] = hostName telemetryProperties["ContainerCount"] = containerInventory.length if !addonTokenAdapterImageTag.empty? - telemetryProperties["addon-token-adapter"] = addonTokenAdapterImageTag + telemetryProperties["addonTokenAdapterImageTag"] = addonTokenAdapterImageTag end ApplicationInsightsUtility.sendTelemetry(@@PluginName, telemetryProperties) end