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

Read patch_mode in resourceLinuxVirtualMachineRead #14042

Merged
merged 8 commits into from
Nov 25, 2021

Conversation

atombrella
Copy link
Contributor

No description provided.

@atombrella
Copy link
Contributor Author

Should have been included in #13866

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @atombrella thanks for updating this! Looks like there are some test failures relating to this new property currently:

------- Stdout: -------
=== RUN   TestAccLinuxVirtualMachine_authSSH
=== PAUSE TestAccLinuxVirtualMachine_authSSH
=== CONT  TestAccLinuxVirtualMachine_authSSH
testcase.go:109: Step 1/2 error: After applying this test step, the plan was not empty.
stdout:
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# azurerm_linux_virtual_machine.test will be updated in-place
~ resource "azurerm_linux_virtual_machine" "test" {
id                              = "/subscriptions/*******/resourceGroups/acctestRG-211105164807101935/providers/Microsoft.Compute/virtualMachines/acctestVM-211105164807101935"
name                            = "acctestVM-211105164807101935"
- patch_mode                      = "ImageDefault" -> null
# (18 unchanged attributes hidden)
# (3 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccLinuxVirtualMachine_authSSH (289.01s)
FAIL

@atombrella
Copy link
Contributor Author

Hmm, maybe this should have had Default: string(compute.LinuxVMGuestPatchModeImageDefault),` under the property?

@katbyte katbyte modified the milestones: v2.85.0, v2.86.0 Nov 12, 2021
@catriona-m
Copy link
Member

Hmm, maybe this should have had Default: string(compute.LinuxVMGuestPatchModeImageDefault),` under the property?

This change plus the linting correction should fix the tests! 😄

@atombrella
Copy link
Contributor Author

@catriona-m @katbyte I updated the PR. Hopefully it can be merged now 🎉

@catriona-m
Copy link
Member

HI @atombrella, thank you for making the requested changes, but unfortunately it now looks like the test is failing for a different reason:

------- Stdout: -------
=== RUN   TestAccLinuxVirtualMachine_linuxPatchModeSetting
=== PAUSE TestAccLinuxVirtualMachine_linuxPatchModeSetting
=== CONT  TestAccLinuxVirtualMachine_linuxPatchModeSetting
testcase.go:110: Step 1/3 error: Error running apply: exit status 1
Error: creating Linux Virtual Machine "acctestVM-211117113608397069" (Resource Group "acctestRG-211117113608397069"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=404 -- Original Error: Code="PlatformImageNotFound" Message="The platform image 'Canonical:UbuntuServer:20.04-LTS:latest' is not available. Verify that all fields in the storage profile are correct. For more details about storage profile information, please refer to https://aka.ms/storageprofile" Target="imageReference"
with azurerm_linux_virtual_machine.test,
on terraform_plugin_test.tf line 43, in resource "azurerm_linux_virtual_machine" "test":
43: resource "azurerm_linux_virtual_machine" "test" {
--- FAIL: TestAccLinuxVirtualMachine_linuxPatchModeSetting (234.66s)
FAIL

@katbyte katbyte modified the milestones: v2.86.0, v2.87.0 Nov 19, 2021
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @atombrella

Thanks for pushing those changes - taking a look through here we also need to ensure that this field has a value set into the state at all times and that this default value is documented, but if we can fix those up then we should be able to take another look

Thanks!

@atombrella
Copy link
Contributor Author

@tombuildsstuff Thanks. I updated it, so the linting passes now. I haven't yet set up my environment to be able to run the acceptance tests.

@atombrella
Copy link
Contributor Author

I've updated it a bit. Without the 16.04 change, the test wouldn't run (now I can run the acceptance tests locally). I think I'm a bit stuck with this PR :/

==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/compute -run=TestAccLinuxVirtualMachine_linuxPatchModeSetting -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccLinuxVirtualMachine_linuxPatchModeSetting
=== PAUSE TestAccLinuxVirtualMachine_linuxPatchModeSetting
=== CONT  TestAccLinuxVirtualMachine_linuxPatchModeSetting
    testcase.go:110: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
        
        (map[string]string) {
        }
        
        
        (map[string]string) (len=1) {
         (string) (len=14) "admin_password": (string) (len=13) "password1234!"
        }
--- FAIL: TestAccLinuxVirtualMachine_linuxPatchModeSetting (306.61s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-azurerm/internal/services/compute	306.628s
FAIL
make: *** [GNUmakefile:105: acctests] Error 1

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @atombrella! Looking at this again it seems the test may be resolved by just removing admin_password from the linuxPatchModeSetting test config altogether 😄 then we can look at merging this.

@atombrella
Copy link
Contributor Author

➜ make acctests SERVICE='compute' TESTARGS='-run=TestAccLinuxVirtualMachine_linuxPatchModeSetting' TESTTIMEOUT='60m'

==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/compute -run=TestAccLinuxVirtualMachine_linuxPatchModeSetting -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccLinuxVirtualMachine_linuxPatchModeSetting
=== PAUSE TestAccLinuxVirtualMachine_linuxPatchModeSetting
=== CONT  TestAccLinuxVirtualMachine_linuxPatchModeSetting
--- PASS: TestAccLinuxVirtualMachine_linuxPatchModeSetting (319.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-azurerm/internal/services/compute	319.027s 

Without the nil-changes, the test will fail with:

➜ make acctests SERVICE='compute' TESTARGS='-run=TestAccLinuxVirtualMachine_linuxPatchModeSetting' TESTTIMEOUT='60m'

==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/compute -run=TestAccLinuxVirtualMachine_linuxPatchModeSetting -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccLinuxVirtualMachine_linuxPatchModeSetting
=== PAUSE TestAccLinuxVirtualMachine_linuxPatchModeSetting
=== CONT  TestAccLinuxVirtualMachine_linuxPatchModeSetting
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x4498300]

goroutine 1766 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/compute.resourceLinuxVirtualMachineUpdate(0xc00336ac80, {0x5732ae0, 0xc003016700})
	/home/mads/git/terraform-provider-azurerm/internal/services/compute/linux_virtual_machine_resource.go:972 +0x16e0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc003e30db0, {0x692ab28, 0xc001c4e800}, 0x24, {0x5732ae0, 0xc003016700})
	/home/mads/git/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource.go:352 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0012536c0, {0x692ab28, 0xc001c4e800}, 0xc001c6bd40, 0xc00336ab00, {0x5732ae0, 0xc003016700})
	/home/mads/git/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource.go:464 +0x6ba
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0011c43f0, {0x692ab28, 0xc001c4e800}, 0xc0032eb770)
	/home/mads/git/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/grpc_provider.go:977 +0xd8a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc002810200, {0x692abd0, 0xc00116bb60}, 0xc001c271c5)
	/home/mads/git/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:332 +0x6c
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x5c7ba00, 0xc002810200}, {0x692abd0, 0xc00116bb60}, 0xc00004ea20, 0x0)
	/home/mads/git/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000381dc0, {0x697b680, 0xc003934300}, 0xc0025ee240, 0xc001707740, 0xaf5c040, 0x0)
	/home/mads/git/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1292 +0xc6f
google.golang.org/grpc.(*Server).handleStream(0xc000381dc0, {0x697b680, 0xc003934300}, 0xc0025ee240, 0x0)
	/home/mads/git/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1617 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	/home/mads/git/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:940 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/home/mads/git/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:938 +0x294
FAIL	github.com/hashicorp/terraform-provider-azurerm/internal/services/compute	143.025s
FAIL
make: *** [GNUmakefile:105: acctests] Error 1

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @atombrella, LGTM! 🚀

@catriona-m catriona-m merged commit 49d15b5 into hashicorp:main Nov 25, 2021
catriona-m added a commit that referenced this pull request Nov 25, 2021
@atombrella atombrella deleted the patch_mode_read branch November 25, 2021 11:54
@github-actions
Copy link

This functionality has been released in v2.87.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants