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

Use Update (PUT) not Patch when modifying spec and status #1674

Merged
merged 4 commits into from
Aug 3, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hack/generated/controllers/crd_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ func Test_Disk_CRUD(t *testing.T) {
armId := *disk.Status.Id

// Perform a simple patch.
patcher := tc.NewResourcePatcher(disk)
old := disk.DeepCopy()
networkAccessPolicy := compute.DiskPropertiesNetworkAccessPolicyDenyAll
disk.Spec.NetworkAccessPolicy = &networkAccessPolicy
patcher.Patch(disk)
tc.Patch(old, disk)
theunrepentantgeek marked this conversation as resolved.
Show resolved Hide resolved

objectKey := client.ObjectKeyFromObject(disk)

Expand Down
5 changes: 2 additions & 3 deletions hack/generated/controllers/crd_networking_publicip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ func Test_PublicIP_CRUD(t *testing.T) {
armId := *publicIPAddress.Status.Id

// Perform a simple patch
patcher := tc.NewResourcePatcher(publicIPAddress)

old := publicIPAddress.DeepCopy()
idleTimeoutInMinutes := 7
publicIPAddress.Spec.IdleTimeoutInMinutes = &idleTimeoutInMinutes
patcher.Patch(publicIPAddress)
tc.Patch(old, publicIPAddress)

objectKey := client.ObjectKeyFromObject(publicIPAddress)

Expand Down
5 changes: 2 additions & 3 deletions hack/generated/controllers/crd_resourcegroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ func Test_ResourceGroup_CRUD(t *testing.T) {
armId := rg.Status.ID

// Update the tags
patcher := tc.NewResourcePatcher(rg)

old := rg.DeepCopy()
rg.Spec.Tags["tag1"] = "value1"
patcher.Patch(rg)
tc.Patch(old, rg)

objectKey := client.ObjectKeyFromObject(rg)

Expand Down
4 changes: 2 additions & 2 deletions hack/generated/controllers/crd_vmss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func Test_VMSS_CRUD(t *testing.T) {
armId := *vmss.Status.Id

// Perform a simple patch to add a basic custom script extension
patcher := tc.NewResourcePatcher(vmss)
old := vmss.DeepCopy()
extensionName := "mycustomextension"
vmss.Spec.VirtualMachineProfile.ExtensionProfile = &compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_ExtensionProfile{
Extensions: []compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_ExtensionProfile_Extensions{
Expand All @@ -215,7 +215,7 @@ func Test_VMSS_CRUD(t *testing.T) {
},
},
}
patcher.Patch(vmss)
tc.Patch(old, vmss)

objectKey := client.ObjectKeyFromObject(vmss)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ func Test_DeploymentAccepted_LongRunningOperationFails_SucceedsAfterUpdate(t *te
tc.CreateResourceAndWaitForFailure(acct)

// Remove the bad property and ensure we can successfully provision
patcher := tc.NewResourcePatcher(acct)
old := acct.DeepCopy()
acct.Spec.KeyPolicy = nil
tc.PatchResourceAndWaitAfter(acct, patcher, armclient.FailedProvisioningState)
tc.PatchResourceAndWaitAfter(old, acct, armclient.FailedProvisioningState)

// Ensure that the old failure information was cleared away
objectKey := client.ObjectKeyFromObject(acct)
Expand Down Expand Up @@ -172,9 +172,9 @@ func Test_DeploymentRejected_SucceedsAfterUpdate(t *testing.T) {
tc.CreateResourceAndWaitForFailure(vmss)

// Now fix the image reference and the VMSS should successfully deploy
patcher := tc.NewResourcePatcher(vmss)
old := vmss.DeepCopy()
vmss.Spec.VirtualMachineProfile.StorageProfile.ImageReference = originalImgRef
tc.PatchResourceAndWaitAfter(vmss, patcher, armclient.FailedProvisioningState)
tc.PatchResourceAndWaitAfter(old, vmss, armclient.FailedProvisioningState)

// Ensure that the old failure information was cleared away
objectKey := client.ObjectKeyFromObject(vmss)
Expand Down
4 changes: 2 additions & 2 deletions hack/generated/controllers/edge_case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ func Test_CreateStorageAccountThatAlreadyExists_ReconcilesSuccessfully(t *testin
tc.CreateResourcesAndWait(acct)

// Patch the account to remove the finalizer
patcher := tc.NewResourcePatcher(acct)
old := acct.DeepCopy()
controllerutil.RemoveFinalizer(acct, "generated.infra.azure.com/finalizer")
patcher.Patch(acct)
tc.Patch(old, acct)

// Delete the account
tc.DeleteResourceAndWait(acct)
Expand Down
4 changes: 2 additions & 2 deletions hack/generated/controllers/recordings/Test_CosmosDB_CRUD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ interactions:
- application/json
Test-Request-Attempt:
- "0"
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-dnhfns/providers/Microsoft.Resources/deployments/k8s_f9f7e648-5320-5c32-8775-febefed1fa3a?api-version=2019-10-01
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-dnhfns/providers/Microsoft.Resources/deployments/k8s_f9f7e648-5320-5c32-8775-febefed1fa3a?api-version=2019-10-01
theunrepentantgeek marked this conversation as resolved.
Show resolved Hide resolved
method: PUT
response:
body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-dnhfns/providers/Microsoft.Resources/deployments/k8s_f9f7e648-5320-5c32-8775-febefed1fa3a","name":"k8s_f9f7e648-5320-5c32-8775-febefed1fa3a","type":"Microsoft.Resources/deployments","properties":{"templateHash":"10782151782485691123","mode":"Incremental","debugSetting":{"detailLevel":"RequestContent,
ResponseContent"},"provisioningState":"Accepted","timestamp":"2001-02-03T04:05:06Z","duration":"PT0.1823935S","correlationId":"6b2db4ab-5dc3-4df0-99a6-b79b6a30b5b9","providers":[{"namespace":"Microsoft.DocumentDB","resourceTypes":[{"resourceType":"databaseAccounts","locations":["westus2"]}]}],"dependencies":[]}}'
headers:
Azure-Asyncoperation:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-dnhfns/providers/Microsoft.Resources/deployments/k8s_f9f7e648-5320-5c32-8775-febefed1fa3a/operationStatuses/08585771334810879607?api-version=2019-10-01
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-dnhfns/providers/Microsoft.Resources/deployments/k8s_f9f7e648-5320-5c32-8775-febefed1fa3a/operationStatuses/08585771334810879607?api-version=2019-10-01
Cache-Control:
- no-cache
Content-Length:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ interactions:
- application/json
Test-Request-Attempt:
- "0"
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb?api-version=2019-10-01
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb?api-version=2019-10-01
method: PUT
response:
body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb","name":"k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb","type":"Microsoft.Resources/deployments","properties":{"templateHash":"17073843691618787499","mode":"Incremental","debugSetting":{"detailLevel":"RequestContent,
ResponseContent"},"provisioningState":"Accepted","timestamp":"2001-02-03T04:05:06Z","duration":"PT0.164104S","correlationId":"81f79330-d0c2-45f2-afec-cf43e86f2c1d","providers":[{"namespace":"Microsoft.Storage","resourceTypes":[{"resourceType":"storageAccounts","locations":["westus2"]}]}],"dependencies":[]}}'
headers:
Azure-Asyncoperation:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb/operationStatuses/08585767055865713460?api-version=2019-10-01
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb/operationStatuses/08585767055865713460?api-version=2019-10-01
Cache-Control:
- no-cache
Content-Length:
Expand Down Expand Up @@ -501,14 +501,14 @@ interactions:
- application/json
Test-Request-Attempt:
- "1"
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb?api-version=2019-10-01
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb?api-version=2019-10-01
method: PUT
response:
body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb","name":"k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb","type":"Microsoft.Resources/deployments","properties":{"templateHash":"17073843691618787499","mode":"Incremental","debugSetting":{"detailLevel":"RequestContent,
ResponseContent"},"provisioningState":"Accepted","timestamp":"2001-02-03T04:05:06Z","duration":"PT0.4463163S","correlationId":"78c90fb1-00ee-448b-b5c6-4c31c1dcaccb","providers":[{"namespace":"Microsoft.Storage","resourceTypes":[{"resourceType":"storageAccounts","locations":["westus2"]}]}],"dependencies":[]}}'
headers:
Azure-Asyncoperation:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb/operationStatuses/08585767053833180341?api-version=2019-10-01
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-pmkayp/providers/Microsoft.Resources/deployments/k8s_f9e1e689-9372-5764-8480-98e4ddf3f5cb/operationStatuses/08585767053833180341?api-version=2019-10-01
Cache-Control:
- no-cache
Content-Length:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ interactions:
- application/json
Test-Request-Attempt:
- "0"
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-znqxml/providers/Microsoft.Resources/deployments/k8s_d1825054-dc4c-5f3a-a7ea-8b17759f52e9?api-version=2019-10-01
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-znqxml/providers/Microsoft.Resources/deployments/k8s_d1825054-dc4c-5f3a-a7ea-8b17759f52e9?api-version=2019-10-01
method: PUT
response:
body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-znqxml/providers/Microsoft.Resources/deployments/k8s_d1825054-dc4c-5f3a-a7ea-8b17759f52e9","name":"k8s_d1825054-dc4c-5f3a-a7ea-8b17759f52e9","type":"Microsoft.Resources/deployments","properties":{"templateHash":"4617865276341083827","mode":"Incremental","debugSetting":{"detailLevel":"RequestContent,
ResponseContent"},"provisioningState":"Accepted","timestamp":"2001-02-03T04:05:06Z","duration":"PT0.1794764S","correlationId":"8e615ffe-96c4-4791-8a15-cd764f558d67","providers":[{"namespace":"Microsoft.Storage","resourceTypes":[{"resourceType":"storageAccounts","locations":["westus2"]}]}],"dependencies":[]}}'
headers:
Azure-Asyncoperation:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-znqxml/providers/Microsoft.Resources/deployments/k8s_d1825054-dc4c-5f3a-a7ea-8b17759f52e9/operationStatuses/08585769627628002661?api-version=2019-10-01
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-znqxml/providers/Microsoft.Resources/deployments/k8s_d1825054-dc4c-5f3a-a7ea-8b17759f52e9/operationStatuses/08585769627628002661?api-version=2019-10-01
Cache-Control:
- no-cache
Content-Length:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ interactions:
- application/json
Test-Request-Attempt:
- "0"
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807?api-version=2019-10-01
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807?api-version=2019-10-01
method: PUT
response:
body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807","name":"k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807","type":"Microsoft.Resources/deployments","properties":{"templateHash":"3472035465400640383","mode":"Incremental","debugSetting":{"detailLevel":"RequestContent,
ResponseContent"},"provisioningState":"Accepted","timestamp":"2001-02-03T04:05:06Z","duration":"PT0.1699851S","correlationId":"92eff090-a6c0-4e4d-aad5-030ec455b54b","providers":[{"namespace":"Microsoft.Storage","resourceTypes":[{"resourceType":"storageAccounts","locations":["westus2"]}]}],"dependencies":[]}}'
headers:
Azure-Asyncoperation:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807/operationStatuses/08585766904519191147?api-version=2019-10-01
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807/operationStatuses/08585766904519191147?api-version=2019-10-01
Cache-Control:
- no-cache
Content-Length:
Expand Down Expand Up @@ -307,14 +307,14 @@ interactions:
- application/json
Test-Request-Attempt:
- "1"
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807?api-version=2019-10-01
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807?api-version=2019-10-01
method: PUT
response:
body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807","name":"k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807","type":"Microsoft.Resources/deployments","properties":{"templateHash":"6649788517333747801","mode":"Incremental","debugSetting":{"detailLevel":"RequestContent,
ResponseContent"},"provisioningState":"Accepted","timestamp":"2001-02-03T04:05:06Z","duration":"PT0.1451179S","correlationId":"ef1f6a16-5ef8-4e35-b15f-26053b1134cb","providers":[{"namespace":"Microsoft.Storage","resourceTypes":[{"resourceType":"storageAccounts","locations":["westus2"]}]}],"dependencies":[]}}'
headers:
Azure-Asyncoperation:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807/operationStatuses/08585766904419941738?api-version=2019-10-01
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-kjfnqc/providers/Microsoft.Resources/deployments/k8s_dc846ce2-f2cc-511a-95eb-6aae7e209807/operationStatuses/08585766904419941738?api-version=2019-10-01
Cache-Control:
- no-cache
Content-Length:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ interactions:
- application/json
Test-Request-Attempt:
- "0"
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-gavcvf/providers/Microsoft.Resources/deployments/k8s_45bded34-2991-5374-8651-ddd7842f7955?api-version=2019-10-01
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-gavcvf/providers/Microsoft.Resources/deployments/k8s_45bded34-2991-5374-8651-ddd7842f7955?api-version=2019-10-01
method: PUT
response:
body: '{"error":{"code":"InvalidTemplateDeployment","message":"The template deployment
Expand Down
Loading