@@ -1672,7 +1672,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
1672
1672
1673
1673
By ("deleting the Node" )
1674
1674
nodeName := node .Name
1675
- err = cl .Delete (context . TODO () , node )
1675
+ err = cl .Delete (ctx , node )
1676
1676
Expect (err ).NotTo (HaveOccurred ())
1677
1677
Expect (node .ObjectMeta .DeletionTimestamp ).NotTo (BeNil ())
1678
1678
@@ -1845,7 +1845,48 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
1845
1845
_ , err = clientset .AppsV1 ().Deployments (ns ).Get (ctx , dep2Name , metav1.GetOptions {})
1846
1846
Expect (err ).To (HaveOccurred ())
1847
1847
})
1848
+
1849
+ It ("should update the resource when deleting if it receives a response" , func () {
1850
+ cl , err := client .New (cfg , client.Options {})
1851
+ Expect (err ).NotTo (HaveOccurred ())
1852
+ Expect (cl ).NotTo (BeNil ())
1853
+
1854
+ By ("initially creating a Node" )
1855
+ node , err := clientset .CoreV1 ().Nodes ().Create (ctx , node , metav1.CreateOptions {})
1856
+ Expect (err ).NotTo (HaveOccurred ())
1857
+
1858
+ By ("adding a finalizer we prevent the node from being deleted immediately" )
1859
+ controllerutil .AddFinalizer (node , "example.com/test" )
1860
+ node , err = clientset .CoreV1 ().Nodes ().Update (ctx , node , metav1.UpdateOptions {})
1861
+ Expect (err ).NotTo (HaveOccurred ())
1862
+
1863
+ By ("deleting the Node" )
1864
+ nodeName := node .Name
1865
+ u := & unstructured.Unstructured {}
1866
+ Expect (scheme .Convert (node , u , nil )).To (Succeed ())
1867
+ u .SetGroupVersionKind (schema.GroupVersionKind {
1868
+ Group : "" ,
1869
+ Kind : "Node" ,
1870
+ Version : "v1" ,
1871
+ })
1872
+ err = cl .Delete (ctx , u )
1873
+ Expect (err ).NotTo (HaveOccurred ())
1874
+
1875
+ accessor , err := meta .Accessor (u )
1876
+ Expect (err ).NotTo (HaveOccurred ())
1877
+ Expect (accessor .GetDeletionTimestamp ()).NotTo (BeNil ())
1878
+
1879
+ By ("removing the finalizer" )
1880
+ controllerutil .RemoveFinalizer (u , "example.com/test" )
1881
+ err = cl .Delete (ctx , u )
1882
+ Expect (err ).NotTo (HaveOccurred ())
1883
+
1884
+ By ("validating the Node no longer exists" )
1885
+ _ , err = clientset .CoreV1 ().Nodes ().Get (ctx , nodeName , metav1.GetOptions {})
1886
+ Expect (err ).NotTo (HaveOccurred ())
1887
+ })
1848
1888
})
1889
+
1849
1890
Context ("with metadata objects" , func () {
1850
1891
It ("should delete an existing object from a go struct" , func () {
1851
1892
cl , err := client .New (cfg , client.Options {})
0 commit comments