@@ -1672,7 +1672,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
16721672
16731673 By ("deleting the Node" )
16741674 nodeName := node .Name
1675- err = cl .Delete (context . TODO () , node )
1675+ err = cl .Delete (ctx , node )
16761676 Expect (err ).NotTo (HaveOccurred ())
16771677 Expect (node .ObjectMeta .DeletionTimestamp ).NotTo (BeNil ())
16781678
@@ -1845,7 +1845,48 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
18451845 _ , err = clientset .AppsV1 ().Deployments (ns ).Get (ctx , dep2Name , metav1.GetOptions {})
18461846 Expect (err ).To (HaveOccurred ())
18471847 })
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+ })
18481888 })
1889+
18491890 Context ("with metadata objects" , func () {
18501891 It ("should delete an existing object from a go struct" , func () {
18511892 cl , err := client .New (cfg , client.Options {})
0 commit comments