-
Notifications
You must be signed in to change notification settings - Fork 115
Gangams/addon token adapter image tag to telemetry #656
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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? && | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also disagree with this approach. Much neater way to do this would be, pass this image as an env variable from yaml. Define a helm variable for sidecar container, and use that for the spec.container.image as well pass the same as env variable to be picked up by our telemetry
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. created a task in next agent release to switch the envvar from yaml. |
||
| containerRecord["ElementName"].include?("kube-system") && | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so if i have a kube-system-2 or my-kube-system namespace with a pod having same container name, we will pick that image ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are chances to pick the wrong telemetry if the namespace contains kube-system and container name and will add strict check for the namespace. |
||
| 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["addonTokenAdapterImageTag"] = addonTokenAdapterImageTag | ||
| end | ||
| ApplicationInsightsUtility.sendTelemetry(@@PluginName, telemetryProperties) | ||
| end | ||
| rescue => errorStr | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aadonTokenAdapterImageTag is a local variable in enumerate which is being intialized to empty, every time, which means this will be evaluated for all containers in MSI mode every minute, until this container is found. This should be a global, that should be set the first time, and then just use it as the container image for the sidecar wont change during our lifetime until we are redeployed/updated/restarted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologize for missing this feedback. I am just noticing when I am looking at the changes for the release notes. Agree, this should be global and will make PR to address this.