Skip to content
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

Added handling of amd64 images on compute disk #12961

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6769.txt
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed perma-diff on `google_compute_disk` for new amd64 images
```
13 changes: 13 additions & 0 deletions google/resource_compute_disk.go
Expand Up @@ -151,6 +151,19 @@ func diskImageEquals(oldImageName, newImageName string) bool {
func diskImageFamilyEquals(imageName, familyName string) bool {
// Handles the case when the image name includes the family name
// e.g. image name: debian-11-bullseye-v20220719, family name: debian-11

// First condition is to check if image contains arm64 because of case like:
// image name: opensuse-leap-15-4-v20220713-arm64, family name: opensuse-leap (should not be evaluated during handling of amd64 cases)
// In second condition, we have to check for amd64 because of cases like:
// image name: ubuntu-2210-kinetic-amd64-v20221022, family name: ubuntu-2210 (should not suppress)
if !strings.Contains(imageName, "-arm64") && strings.Contains(imageName, strings.TrimSuffix(familyName, "-amd64")) {
if strings.Contains(imageName, "-amd64") {
return strings.HasSuffix(familyName, "-amd64")
} else {
return !strings.HasSuffix(familyName, "-amd64")
}
}

// We have to check for arm64 because of cases like:
// image name: opensuse-leap-15-4-v20220713-arm64, family name: opensuse-leap (should not suppress)
if strings.Contains(imageName, strings.TrimSuffix(familyName, "-arm64")) {
Expand Down
31 changes: 31 additions & 0 deletions google/resource_compute_disk_test.go
Expand Up @@ -247,6 +247,37 @@ func TestDiskImageDiffSuppress(t *testing.T) {
New: "debian-11-arm64",
ExpectDiffSuppress: false,
},
// amd images
"matching image ubuntu amd64 self_link": {
Old: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-2210-kinetic-amd64-v20221022",
New: "ubuntu-2210-amd64",
ExpectDiffSuppress: true,
},
"matching image ubuntu-minimal amd64 self_link": {
Old: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-minimal-2210-kinetic-amd64-v20221022",
New: "ubuntu-minimal-2210-amd64",
ExpectDiffSuppress: true,
},
"different architecture image ubuntu amd64 self_link": {
Old: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-2210-kinetic-amd64-v20221022",
New: "ubuntu-2210",
ExpectDiffSuppress: false,
},
"different architecture image ubuntu-minimal amd64 self_link": {
Old: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-minimal-2210-kinetic-amd64-v20221022",
New: "ubuntu-minimal-2210",
ExpectDiffSuppress: false,
},
"different architecture image ubuntu amd64 family": {
Old: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-2210-kinetic-v20221022",
New: "ubuntu-2210-amd64",
ExpectDiffSuppress: false,
},
"different architecture image ubuntu-minimal amd64 family": {
Old: "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-minimal-2210-kinetic-v20221022",
New: "ubuntu-minimal-2210-amd64",
ExpectDiffSuppress: false,
},
}

for tn, tc := range cases {
Expand Down