Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
689df05
Add new DeleteAction for when Azure deletion is not possible
theunrepentantgeek Oct 16, 2025
2dc13f9
Support DeletionNotSupported in condition
theunrepentantgeek Oct 16, 2025
3f18ff3
Implement handling when delete is not permitted
theunrepentantgeek Oct 16, 2025
cd8cada
Add detatch annotation
theunrepentantgeek Oct 20, 2025
8122ea6
Add annotation to sample
theunrepentantgeek Oct 20, 2025
46d10ec
Add comments
theunrepentantgeek Oct 20, 2025
7d1a321
Add annotations for postgres samples
theunrepentantgeek Oct 20, 2025
ca1ab33
Fix MariaDB samples
theunrepentantgeek Oct 21, 2025
39a5597
Move addAnnotation helper onto TestContext
theunrepentantgeek Oct 21, 2025
9b81866
Update comment
theunrepentantgeek Oct 21, 2025
23e7eca
Fix MariaDB test
theunrepentantgeek Oct 21, 2025
cd52d64
Update samples
theunrepentantgeek Oct 22, 2025
a2c8196
Fix test
theunrepentantgeek Oct 22, 2025
d4a1b4b
Fix samples
theunrepentantgeek Oct 22, 2025
8f62941
Update more tests
theunrepentantgeek Oct 23, 2025
97c4e27
Update samples
theunrepentantgeek Oct 24, 2025
3f3e991
Update CRUD tests
theunrepentantgeek Oct 24, 2025
df5f34a
Fix test
theunrepentantgeek Oct 24, 2025
69f2176
Update tests
theunrepentantgeek Oct 28, 2025
c1c2a7e
Update samples
theunrepentantgeek Oct 29, 2025
328dc82
Update more tests
theunrepentantgeek Oct 29, 2025
2e9d63a
Fix more tests
theunrepentantgeek Oct 29, 2025
0876a21
Rename tests
theunrepentantgeek Oct 29, 2025
059dd69
Fix more tests
theunrepentantgeek Oct 29, 2025
67dfa04
Update tests
theunrepentantgeek Oct 30, 2025
4f0e78d
Tweak test
theunrepentantgeek Oct 30, 2025
fc39fd8
Fix test
theunrepentantgeek Nov 2, 2025
7b843df
Fix another test
theunrepentantgeek Nov 3, 2025
b346274
Fix test
theunrepentantgeek Nov 4, 2025
689c2b3
Update another test
theunrepentantgeek Nov 5, 2025
a4c5049
Fix test
theunrepentantgeek Nov 6, 2025
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
1 change: 1 addition & 0 deletions v2/internal/controllers/crd_eventgrid_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func Test_EventGrid_Domain(t *testing.T) {
Owner: testcommon.AsOwner(acct),
},
}
tc.AddAnnotation(&queueServices.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(queueServices)

Expand Down
3 changes: 3 additions & 0 deletions v2/internal/controllers/crd_eventgrid_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func Topic_Subscription_CRUD(tc *testcommon.KubePerTestContext, rg *resources.Re
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&queueService.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(queueService)

queue := &storage.StorageAccountsQueueServicesQueue{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ func Test_DataProtection_BackupInstance_20231101_CRUD(t *testing.T) {
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&blobService.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

blobContainer := &storage.StorageAccountsBlobServicesContainer{
ObjectMeta: tc.MakeObjectMeta("velero"),
Spec: storage.StorageAccountsBlobServicesContainer_Spec{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ func MySQLFlexibleServer_Configuration_20220101_CRUD(tc *testcommon.KubePerTestC
Value: to.Ptr("20"),
},
}
tc.AddAnnotation(&configuration.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(configuration)
tc.Expect(configuration.Status.Id).ToNot(BeNil())
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ func MySQLFlexibleServer_Configuration_20230630_CRUD(tc *testcommon.KubePerTestC
Value: to.Ptr("20"),
},
}
tc.AddAnnotation(&configuration.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(configuration)
tc.Expect(configuration.Status.Id).ToNot(BeNil())
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ func MySQLFlexibleServer_Configuration_20231230_CRUD(tc *testcommon.KubePerTestC
Value: to.Ptr("20"),
},
}
tc.AddAnnotation(&configuration.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(configuration)
tc.Expect(configuration.Status.Id).ToNot(BeNil())
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func FlexibleServer_Configuration_20221201_CRUD(tc *testcommon.KubePerTestContex
Value: to.Ptr("READ"),
},
}
tc.AddAnnotation(&configuration.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(configuration)
// This isn't a "real" resource so it cannot be deleted directly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func FlexibleServer_Configuration_20230601Preview_CRUD(tc *testcommon.KubePerTes
Value: to.Ptr("READ"),
},
}
tc.AddAnnotation(&configuration.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(configuration)
// This isn't a "real" resource so it cannot be deleted directly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func FlexibleServer_Configuration_20240801_CRUD(tc *testcommon.KubePerTestContex
Value: to.Ptr("READ"),
},
}
tc.AddAnnotation(&configuration.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(configuration)
// This isn't a "real" resource so it cannot be deleted directly
Expand Down Expand Up @@ -261,9 +262,10 @@ func FlexibleServer_AdvancedThreatProtection_20240801_CRUD(tc *testcommon.KubePe
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&threatProtection.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(threatProtection)
// This isn't a "real" resource so it cannot be deleted directly
// defer tc.DeleteResourceAndWait(threatProtection)

tc.Expect(threatProtection.Status.Id).ToNot(BeNil())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func CosmosDB_MongoDB_Database_ThroughputSettings_CRUD(tc *testcommon.KubePerTes
},
},
}
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.T.Log("creating mongo database throughput")
tc.CreateResourceAndWait(&throughputSettings)
Expand Down Expand Up @@ -205,9 +206,11 @@ func CosmosDB_MongoDB_Database_Collections_ThroughputSettings_CRUD(tc *testcommo
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.T.Log("creating mongo database collections throughput")
tc.CreateResourceAndWait(&throughputSettings)
// no DELETE, this is not a real resource - to delete it you must delete its parent

// Ensure that the status is what we expect
tc.Expect(throughputSettings.Status.Id).ToNot(BeNil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func DocumentDB_MongoDB_Database_ThroughputSettings_v20231115_CRUD(tc *testcommo
},
},
}
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.T.Log("creating mongo database throughput")
tc.CreateResourceAndWait(&throughputSettings)
Expand Down Expand Up @@ -228,9 +229,11 @@ func DocumentDB_MongoDB_Database_Collections_ThroughputSettings_v20231515_CRUD(t
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.LogSectionf("creating mongo database collections throughput")
tc.CreateResourceAndWait(&throughputSettings)
// no DELETE, this is not a real resource - to delete it you must delete its parent

// Ensure that the status is what we expect
tc.Expect(throughputSettings.Status.Id).ToNot(BeNil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func DocumentDB_MongoDB_Database_ThroughputSettings_v20240815_CRUD(tc *testcommo
},
},
}
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.T.Log("creating mongo database throughput")
tc.CreateResourceAndWait(&throughputSettings)
Expand Down Expand Up @@ -251,9 +252,11 @@ func DocumentDB_MongoDB_Database_Collections_ThroughputSettings_v20240815_CRUD(t
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.LogSectionf("creating mongo database collections throughput")
tc.CreateResourceAndWait(&throughputSettings)
// no DELETE, this is not a real resource - to delete it you must delete its parent

// Ensure that the status is what we expect
tc.Expect(throughputSettings.Status.Id).ToNot(BeNil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,11 @@ func CosmosDB_SQL_Database_ThroughputSettings_v20231115_CRUD(tc *testcommon.Kube
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

// Create the resource
tc.CreateResourceAndWait(&throughputSettings)
// no DELETE, this is not a real resource - to delete it you must delete its parent

// Ensure that the status is what we expect
tc.Expect(throughputSettings.Status.Id).ToNot(BeNil())
Expand Down Expand Up @@ -359,9 +361,11 @@ func CosmosDB_SQL_Database_Container_ThroughputSettings_v20231115_CRUD(tc *testc
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

// Create the resource
tc.CreateResourceAndWait(&throughputSettings)
// no DELETE, this is not a real resource - to delete it you must delete its parent

// Ensure that the status is what we expect
tc.Expect(throughputSettings.Status.Id).ToNot(BeNil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,11 @@ func CosmosDB_SQL_Database_ThroughputSettings_v20240815_CRUD(tc *testcommon.Kube
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

// Create the resource
tc.CreateResourceAndWait(&throughputSettings)
// no DELETE, this is not a real resource - to delete it you must delete its parent

// Ensure that the status is what we expect
tc.Expect(throughputSettings.Status.Id).ToNot(BeNil())
Expand Down Expand Up @@ -358,9 +360,11 @@ func CosmosDB_SQL_Database_Container_ThroughputSettings_v20240815_CRUD(tc *testc
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&throughputSettings.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

// Create the resource
tc.CreateResourceAndWait(&throughputSettings)
// no DELETE, this is not a real resource - to delete it you must delete its parent

// Ensure that the status is what we expect
tc.Expect(throughputSettings.Status.Id).ToNot(BeNil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ func Insights_PricingPlan_20171001_CRUD(
},
}

// Don't try to delete directly, this is not a real resource - to delete it you must delete its parent
tc.AddAnnotation(&plan.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.CreateResourceAndWait(plan)

tc.Expect(plan.Status.PlanType).NotTo(BeNil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Test_MariaDB_Server_CRUD(t *testing.T) {
adminUser := "testadmin"
adminPasswordRef := createPasswordSecret("admin", "password", tc)

server := mariadb.Server{
server := &mariadb.Server{
ObjectMeta: tc.MakeObjectMetaWithName(serverName),
Spec: mariadb.Server_Spec{
AzureName: serverName,
Expand Down Expand Up @@ -65,37 +65,29 @@ func Test_MariaDB_Server_CRUD(t *testing.T) {
},
}

tc.T.Logf("Creating MariaDB Server %q", serverName)
tc.CreateResourcesAndWait(&server)

tc.ExpectSecretHasKeys(fqdnSecret, "fqdn")

// Configuration
configName := tc.NoSpaceNamer.GenerateName("mcfg")

configuration := mariadb.Configuration{
configuration := &mariadb.Configuration{
ObjectMeta: tc.MakeObjectMetaWithName(configName),
Spec: mariadb.Configuration_Spec{
AzureName: "query_cache_size",
Owner: testcommon.AsOwner(&server),
Owner: testcommon.AsOwner(server),
Value: to.Ptr("102400"),
},
}
tc.AddAnnotation(&configuration.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")

tc.T.Logf("Creating MariaDB Configuration %q", configName)
tc.CreateResourcesAndWait(&configuration)
// Can't delete, so don't even try // defer tc.DeleteResourcesAndWait(&configuration)

database := mariadb.Database{
database := &mariadb.Database{
ObjectMeta: tc.MakeObjectMetaWithName(configName),
Spec: mariadb.Database_Spec{
AzureName: *to.Ptr("adventureworks"),
Owner: testcommon.AsOwner(&server),
Owner: testcommon.AsOwner(server),
},
}

tc.T.Logf("Creating MariaDB Database %q", database.Spec.AzureName)
tc.CreateResourcesAndWait(&database)
tc.CreateResourcesAndWait(server, database, configuration)
tc.ExpectSecretHasKeys(fqdnSecret, "fqdn")
}

func createPasswordSecret(
Expand Down
1 change: 1 addition & 0 deletions v2/internal/controllers/owner_arm_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func Test_OwnerIsARMIDOfParent_ChildResourceSuccessfullyReconciled(t *testing.T)
Owner: testcommon.AsOwner(acct),
},
}
tc.AddAnnotation(&blobService.ObjectMeta, "serviceoperator.azure.com/reconcile-policy", "detach-on-delete")
tc.CreateResourceAndWait(blobService)

tc.Expect(blobService.Status.Id).ToNot(BeNil())
Expand Down
Loading