@@ -275,6 +275,47 @@ var _ = Describe("Namespaced Pod Reflection Tests", func() {
275275
276276 When ("the remote object already exists, but is not managed by the reflection" , WhenBodyRemoteNotManagedByReflection ())
277277
278+ When ("the local object is in terminal phase Succeeded" , func () {
279+ BeforeEach (func () {
280+ // Mark local as Succeeded and persist.
281+ local .Status .Phase = corev1 .PodSucceeded
282+ UpdatePod (client , & local )
283+ })
284+
285+ It ("should succeed" , func () { Expect (err ).ToNot (HaveOccurred ()) })
286+ It ("should not create a remote shadowpod" , func () {
287+ Expect (GetShadowPodError (liqoClient , RemoteNamespace , PodName )).To (BeNotFound ())
288+ })
289+ })
290+
291+ When ("the local object is in terminal phase Failed without OffloadingAborted reason and a ShadowPod exists" , func () {
292+ BeforeEach (func () {
293+ // Prepare local Failed with a non-aborted reason and ensure it is stored.
294+ local .Status .Phase = corev1 .PodFailed
295+ local .Status .Reason = "SomeOtherReason"
296+ UpdatePod (client , & local )
297+
298+ // Create a managed ShadowPod.
299+ shadow .SetLabels (forge .ReflectionLabels ())
300+ CreateShadowPod (liqoClient , & shadow )
301+
302+ // Ensure that any attempt to mutate the ShadowPod would fail the test (should not happen).
303+ if c , ok := liqoClient .(* liqoclientfake.Clientset ); ok {
304+ c .PrependReactor ("update" , "shadowpods" , func (action testing.Action ) (bool , runtime.Object , error ) {
305+ return true , nil , fmt .Errorf ("should not call update on shadowpods" )
306+ })
307+ c .PrependReactor ("delete" , "shadowpods" , func (action testing.Action ) (bool , runtime.Object , error ) {
308+ return true , nil , fmt .Errorf ("should not call delete on shadowpods" )
309+ })
310+ }
311+ })
312+
313+ It ("should succeed" , func () { Expect (err ).ToNot (HaveOccurred ()) })
314+ It ("should not delete the existing remote shadowpod" , func () {
315+ Expect (GetShadowPodError (liqoClient , RemoteNamespace , PodName )).ToNot (HaveOccurred ())
316+ })
317+ })
318+
278319 When ("the local object has already the appropriate offloading label" , func () {
279320 BeforeEach (func () {
280321 shouldDenyPodPatches = true
0 commit comments