Skip to content

Commit a111495

Browse files
authored
regression: fix release notes windows pipeline (#6056)
1 parent 0fe6ca9 commit a111495

File tree

4 files changed

+95
-76
lines changed

4 files changed

+95
-76
lines changed

.pipelines/.vsts-vhd-windows-automation.yaml

+50-31
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,53 @@ parameters:
2020
variables:
2121
- group: "AKS Dev Assistant (KV)"
2222

23-
steps:
24-
- template: ./templates/.configure-azdevops-template.yaml
25-
parameters:
26-
ADO_PAT: $(PAT-aksdevassistant)
27-
- template: ./templates/.generate-github-token.yaml
28-
- bash: |
29-
echo "Bumping windows VHD base image version"
30-
/bin/bash vhdbuilder/scripts/windows/automate_version_bump.sh "$GITHUB_TOKEN" "$CHERRY_PICK_COMMIT_ID"
31-
env:
32-
GITHUB_TOKEN: $(GITHUB_TOKEN)
33-
CHERRY_PICK_COMMIT_ID: $(CHERRY_PICK_COMMIT_ID)
34-
displayName: 'Image Version Bumping'
35-
condition: eq('${{ parameters.ImageBump }}', true)
36-
- bash: |
37-
echo "PR for Release Notes"
38-
cd vhdbuilder/release-notes/autonotes
39-
VER=$(go version)
40-
echo "Go version is $VER"
41-
go install .
42-
cd ../../..
43-
echo "go run autonotes to shuffle release note files from Azure Pipelines into the AgentBaker repo structure"
44-
go run vhdbuilder/release-notes/autonotes/main.go --build $BUILD_ID --include 2019-containerd,2022-containerd,2022-containerd-gen2,23H2,23H2-gen2,2025,2025-gen2
45-
echo "run bash to create pull request for the shuffled release note files"
46-
/bin/bash vhdbuilder/scripts/windows/automate_release_notes.sh "$GITHUB_TOKEN" "$BUILD_ID"
47-
env:
48-
GITHUB_TOKEN: $(GITHUB_TOKEN)
49-
BUILD_ID: $(BUILD_ID)
50-
PR_TARGET_BRANCH: ${{ parameters.PRTargetBranch }}
51-
displayName: 'Release Notes'
52-
condition: eq('${{ parameters.ReleaseNotes }}', true)
53-
23+
stages:
24+
- stage: bump_image_version
25+
dependsOn: []
26+
condition: eq('${{ parameters.ImageBump }}', true)
27+
jobs:
28+
- job: bump_image_version
29+
steps:
30+
- template: ./templates/.configure-azdevops-template.yaml
31+
parameters:
32+
ADO_PAT: $(PAT-aksdevassistant)
33+
- template: ./templates/.generate-github-token.yaml
34+
- bash: |
35+
set -ex
36+
echo "Bumping windows VHD base image version"
37+
/bin/bash vhdbuilder/scripts/windows/automate_version_bump.sh "$GITHUB_TOKEN" "$CHERRY_PICK_COMMIT_ID"
38+
env:
39+
GITHUB_TOKEN: $(GITHUB_TOKEN)
40+
CHERRY_PICK_COMMIT_ID: $(CHERRY_PICK_COMMIT_ID)
41+
displayName: 'Image Version Bumping'
42+
43+
- stage: release_notes
44+
dependsOn: []
45+
condition: eq('${{ parameters.ReleaseNotes }}', true)
46+
jobs:
47+
- job: release_notes
48+
steps:
49+
- template: ./templates/.configure-azdevops-template.yaml
50+
parameters:
51+
ADO_PAT: $(PAT-aksdevassistant)
52+
- template: ./templates/.generate-github-token.yaml
53+
- bash: |
54+
set -e
55+
echo "PR for Release Notes"
56+
cd vhdbuilder/release-notes/autonotes
57+
VER=$(go version)
58+
echo "Go version is $VER"
59+
go install .
60+
cd ../../..
61+
echo "go run autonotes to shuffle release note files from Azure Pipelines into the AgentBaker repo structure"
62+
# TODO: enable WS2025 release notes when we enable WS2025. There is a pipeline bug downloading the WS2025 release notes, so that'll have to be fixed too.
63+
# to re-enable, add ",2025,2025-gen2" to the end of the --include below.
64+
go run vhdbuilder/release-notes/autonotes/main.go --build $BUILD_ID --include 2019-containerd,2022-containerd,2022-containerd-gen2,23H2,23H2-gen2
65+
echo "run bash to create pull request for the shuffled release note files"
66+
/bin/bash vhdbuilder/scripts/windows/automate_release_notes.sh "$GITHUB_TOKEN" "$BUILD_ID"
67+
env:
68+
GITHUB_TOKEN: $(GITHUB_TOKEN)
69+
BUILD_ID: $(BUILD_ID)
70+
PR_TARGET_BRANCH: ${{ parameters.PRTargetBranch }}
71+
displayName: 'Release Notes'
72+
condition: eq('${{ parameters.ReleaseNotes }}', true)

e2e/go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module github.com/Azure/agentbaker/e2e
22

3-
go 1.22.2
4-
toolchain go1.23.7
3+
go 1.23.0
4+
5+
toolchain go1.24.1
56

67
require (
78
github.com/Azure/agentbaker v0.20240503.0

vhdbuilder/lister/go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/Azure/agentbaker/vhdbuilder/lister
22

3-
go 1.21.13
3+
go 1.23.0
4+
45
toolchain go1.24.1
56

67
require (

vhdbuilder/release-notes/autonotes/main.go

+40-42
Original file line numberDiff line numberDiff line change
@@ -98,66 +98,65 @@ func run(ctx context.Context, cancel context.CancelFunc, fl *flags) []error {
9898
enforceInclude := len(include) > 0
9999

100100
artifactsToDownload := map[string]string{}
101+
fmt.Printf("\n")
101102
for key, value := range artifactToPath {
102-
fmt.Printf("%s - %s\n", key, value)
103103
if ignore[key] {
104+
fmt.Printf("Ignoring as artifact explicitly excluded \"%s\" with path \"%s\"\n", key, value)
104105
continue
105106
}
106107

107108
if enforceInclude && !include[key] {
109+
fmt.Printf("Ignoring as not artifact not explicitly included \"%s\" with path \"%s\"\n", key, value)
108110
continue
109111
}
110112

111113
artifactsToDownload[key] = value
112114
}
113115

114-
var errc = make(chan error)
115-
var done = make(chan struct{})
116-
116+
fmt.Printf("\n")
117117
for sku, path := range artifactsToDownload {
118-
119-
if strings.Contains(path, "AKSWindows") {
120-
go getReleaseNotesWindows(sku, path, fl, errc, done)
121-
} else {
122-
go getReleaseNotes(sku, path, fl, errc, done)
123-
}
118+
fmt.Printf("Including artifact \"%s\" with path \"%s\"\n", sku, path)
124119
}
125120

126121
var errs []error
127122

128-
for i := 0; i < len(artifactsToDownload); i++ {
129-
select {
130-
case err := <-errc:
131-
errs = append(errs, err)
132-
case <-done:
133-
continue
123+
// In theory, this could be done in parallel using a goroutine.
124+
// In practice, the "az" command breaks if you call it in parallel.
125+
for sku, path := range artifactsToDownload {
126+
if strings.Contains(path, "AKSWindows") {
127+
err := getReleaseNotesWindows(sku, path, fl)
128+
if err != nil {
129+
errs = append(errs, err)
130+
}
131+
} else {
132+
err := getReleaseNotes(sku, path, fl)
133+
if err != nil {
134+
errs = append(errs, err)
135+
}
134136
}
135137
}
136138

137139
return errs
138140
}
139141

140-
func getReleaseNotes(sku, path string, fl *flags, errc chan<- error, done chan<- struct{}) {
141-
defer func() { done <- struct{}{} }()
142+
func getReleaseNotes(sku, path string, fl *flags) error {
142143

143144
// working directory, need one per sku because the file name is
144145
// always "release-notes.txt" so they all overwrite each other.
145146
tmpdir, err := os.MkdirTemp("", "releasenotes")
146147
if err != nil {
147-
errc <- fmt.Errorf("failed to create temp working directory: %w", err)
148+
return fmt.Errorf("failed to create temp working directory: %w", err)
148149
}
149150
defer os.RemoveAll(tmpdir)
150151

151152
artifactsDirOut := filepath.Join(fl.path, path)
152153

153154
if err := os.MkdirAll(filepath.Dir(artifactsDirOut), 0644); err != nil {
154-
errc <- fmt.Errorf("failed to create parent directory %s with error: %s", artifactsDirOut, err)
155-
return
155+
return fmt.Errorf("failed to create parent directory %s with error: %s", artifactsDirOut, err)
156156
}
157157

158158
if err := os.MkdirAll(artifactsDirOut, 0644); err != nil {
159-
errc <- fmt.Errorf("failed to create parent directory %s with error: %s", artifactsDirOut, err)
160-
return
159+
return fmt.Errorf("failed to create parent directory %s with error: %s", artifactsDirOut, err)
161160
}
162161

163162
artifacts := []buildArtifact{
@@ -178,48 +177,47 @@ func getReleaseNotes(sku, path string, fl *flags, errc chan<- error, done chan<-
178177
for _, artifact := range artifacts {
179178
if err := artifact.process(fl, artifactsDirOut, tmpdir); err != nil {
180179
fmt.Printf("processing artifact %s for sku %s", artifact.name, sku)
181-
errc <- fmt.Errorf("failed to process VHD build artifact %s: %w", artifact.name, err)
182-
return
180+
return fmt.Errorf("failed to process VHD build artifact %s: %w", artifact.name, err)
183181
}
184182
}
185-
}
186183

187-
func getReleaseNotesWindows(sku, path string, fl *flags, errc chan<- error, done chan<- struct{}) {
188-
defer func() { done <- struct{}{} }()
184+
return nil
185+
}
189186

187+
func getReleaseNotesWindows(sku, path string, fl *flags) error {
190188
releaseNotesName := fmt.Sprintf("vhd-release-notes-%s", sku)
191189
imageListName := fmt.Sprintf("vhd-image-list-%s", sku)
192190

193191
artifactsDirOut := filepath.Join(fl.path, path)
194-
if err := os.MkdirAll(filepath.Dir(artifactsDirOut), 0644); err != nil {
195-
errc <- fmt.Errorf("failed to create parent directory %s with error: %s", artifactsDirOut, err)
196-
return
192+
parentDirectory := filepath.Dir(artifactsDirOut)
193+
fmt.Printf("\n")
194+
fmt.Printf("Creating parent directory for sku'%s': '%s'\n", sku, parentDirectory)
195+
if err := os.MkdirAll(parentDirectory, 0644); err != nil {
196+
return fmt.Errorf("failed to create parent directory %s with error: %s", artifactsDirOut, err)
197197
}
198198

199+
fmt.Printf("Creating directory for sku '%s': '%s'\n", sku, artifactsDirOut)
199200
if err := os.MkdirAll(artifactsDirOut, 0644); err != nil {
200-
errc <- fmt.Errorf("failed to create parent directory %s with error: %s", artifactsDirOut, err)
201-
return
201+
return fmt.Errorf("failed to create directory %s with error: %s", artifactsDirOut, err)
202202
}
203203

204-
fmt.Printf("downloading releaseNotes '%s' from build '%s'\n", releaseNotesName, fl.build)
204+
fmt.Printf("downloading releaseNotes '%s' from windows build '%s'\n", releaseNotesName, fl.build)
205205

206206
cmd := exec.Command("az", "pipelines", "runs", "artifact", "download", "--run-id", fl.build, "--path", artifactsDirOut, "--artifact-name", releaseNotesName)
207207
if stdout, err := cmd.CombinedOutput(); err != nil {
208-
if err != nil {
209-
errc <- fmt.Errorf("failed to download az devops releaseNotes for sku %s, err: %s, output: %s", sku, err, string(stdout))
210-
}
211-
return
208+
fmt.Printf("Failed downloading releaseNotes '%s' from windows build '%s'\n", releaseNotesName, fl.build)
209+
return fmt.Errorf("failed to download az devops releaseNotes for sku %s, err: %s, output: %s", sku, err, string(stdout))
212210
}
213211

214212
fmt.Printf("downloading imageList '%s' from build '%s'\n", imageListName, fl.build)
215213

216214
cmd = exec.Command("az", "pipelines", "runs", "artifact", "download", "--run-id", fl.build, "--path", artifactsDirOut, "--artifact-name", imageListName)
217215
if stdout, err := cmd.CombinedOutput(); err != nil {
218-
if err != nil {
219-
errc <- fmt.Errorf("failed to download az devops imageList for sku %s, err: %s, output: %s", sku, err, string(stdout))
220-
}
221-
return
216+
fmt.Printf("failed downloading imageList '%s' from windows build '%s'\n", imageListName, fl.build)
217+
return fmt.Errorf("failed to download az devops imageList for sku %s, err: %s, output: %s", sku, err, string(stdout))
222218
}
219+
220+
return nil
223221
}
224222

225223
func stripWhitespace(str string) string {

0 commit comments

Comments
 (0)