Skip to content

Commit 5425b41

Browse files
authored
chore: fix azp telemetry injection (#594)
# Description AZP didn't pass build pipeline vars to makefile recipes ## Related Issue If this pull request is related to any issue, please mention it here. Additionally, make sure that the issue is assigned to you before submitting this pull request. ## Checklist - [ ] I have read the [contributing documentation](https://retina.sh/docs/contributing). - [ ] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [ ] I have correctly attributed the author(s) of the code. - [ ] I have tested the changes locally. - [ ] I have followed the project's style guidelines. - [ ] I have updated the documentation, if necessary. - [ ] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed Please add any relevant screenshots or GIFs to showcase the changes made. ## Additional Notes Add any additional notes or context about the pull request here. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project.
1 parent 7309cf6 commit 5425b41

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

.pipelines/cg-pipeline.yaml

+6-18
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@ stages:
2626
else
2727
echo "##vso[task.setvariable variable=Tag;isOutput=true]$(make version)"
2828
fi
29-
30-
if [[ -z $(git status -s) ]]; then
31-
if [[ -n $(git describe --exact-match --tags HEAD 2>/dev/null) ]]; then
32-
echo "the current folder is clean and has a tag."
33-
echo "##vso[task.setvariable variable=ApplicationInsightsID;isOutput=true]$(PROD_AI)"
34-
else
35-
echo "the current folder is clean but does not have a tag."
36-
echo "##vso[task.setvariable variable=ApplicationInsightsID;isOutput=true]$(TEST_AI)"
37-
fi
38-
else
39-
echo "the current folder is not clean."
40-
echo "##vso[task.setvariable variable=ApplicationInsightsID;isOutput=true]$(TEST_AI)"
41-
fi
4229
name: "EnvironmentalVariables"
4330
displayName: "Set environmental variables"
4431
condition: always()
@@ -76,10 +63,12 @@ stages:
7663
set -euo pipefail
7764
echo "VERSION=$(make version)"
7865
export VERSION=$(make version)
66+
export APP_INSIGHTS_ID=$(APP_INSIGHTS_ID)
7967
mkdir -p ./output/images/$(platform)/$(arch)/$(year)
8068
make retina-image \
8169
AGENT_TARGETS=$(target) \
8270
TAG=$(make version) \
71+
APP_INSIGHTS_ID=$(APP_INSIGHTS_ID) \
8372
IMAGE_NAMESPACE=retina \
8473
PLATFORM=$(platform)/$(arch) \
8574
IMAGE_REGISTRY=ghcr.io/microsoft \
@@ -118,6 +107,7 @@ stages:
118107
mkdir -p ./output/images/$(platform)/$(arch)/$(year)
119108
make retina-operator-image \
120109
TAG=$(make version) \
110+
APP_INSIGHTS_ID=$(APP_INSIGHTS_ID) \
121111
IMAGE_NAMESPACE=retina \
122112
PLATFORM=$(platform)/$(arch) \
123113
IMAGE_REGISTRY=ghcr.io/microsoft \
@@ -143,16 +133,14 @@ stages:
143133
- checkout: self
144134
fetchTags: true
145135

146-
147-
148136
- task: DownloadPipelineArtifact@2
149137
inputs:
150-
buildType: 'specific'
138+
buildType: "specific"
151139
project: $(BUILDER_ADO_PROECT)
152140
definition: $(BUILDER_ADO_DEFINITION_ID) # Replace with your build definition ID
153141
buildId: $(BUILDER_ADO_BUILD_ID)
154142
artifactName: $(BUILDER_ADO_ARTIFACTE_NAME) # Replace with your artifact name
155-
itemPattern: '**/*builder*.tar'
143+
itemPattern: "**/*builder*.tar"
156144
downloadPath: '$(Pipeline.Workspace)\artifacts'
157145

158146
- task: PowerShell@2
@@ -173,7 +161,7 @@ stages:
173161
targetType: "inline"
174162
script: |
175163
Import-Module -Name "$(Build.SourcesDirectory)\windows\docker\DockerBuildModule.psm1" -Force
176-
Build-RetinaAgentImage -fullBuilderImageName $(WINDOWS_BUILDER_IMAGE) -registry $(BUILD_REGISTRY) -appInsightsID $(PROD_AI)
164+
Build-RetinaAgentImage -fullBuilderImageName $(WINDOWS_BUILDER_IMAGE) -registry $(BUILD_REGISTRY) -appInsightsID $(APP_INSIGHTS_ID)
177165
Save-Image -imageName retina-agent -registry $(BUILD_REGISTRY)
178166
179167
- task: PublishBuildArtifacts@1

cmd/legacy/daemon.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ func (d *Daemon) Start() error {
124124
mainLogger.Info(zap.String("data aggregation level", daemonConfig.DataAggregationLevel.String()))
125125

126126
var tel telemetry.Telemetry
127-
if daemonConfig.EnableTelemetry && buildinfo.ApplicationInsightsID != "" {
127+
if daemonConfig.EnableTelemetry {
128+
if buildinfo.ApplicationInsightsID == "" {
129+
panic("telemetry enabled, but ApplicationInsightsID is empty")
130+
}
128131
mainLogger.Info("telemetry enabled", zap.String("applicationInsightsID", buildinfo.ApplicationInsightsID))
129132
tel = telemetry.NewAppInsightsTelemetryClient("retina-agent", map[string]string{
130133
"version": buildinfo.Version,

0 commit comments

Comments
 (0)