@@ -202,6 +202,46 @@ var _ = Describe("Dynamic Attachment controller", func() {
202202 }).Should (BeEmpty ())
203203 })
204204 })
205+
206+ When ("an update to an existing attachment occurs" , func () {
207+ BeforeEach (func () {
208+ var err error
209+
210+ currentPodAttachments , err := networkSelectionElements (pod .Annotations , pod .GetNamespace ())
211+ Expect (err ).NotTo (HaveOccurred ())
212+ Expect (currentPodAttachments ).NotTo (BeEmpty ())
213+
214+ currentPodAttachments [0 ].MacRequest = "07:06:05:04:03:02"
215+ var newAttachments []nad.NetworkSelectionElement
216+ for i := range currentPodAttachments {
217+ newAttachments = append (newAttachments , * currentPodAttachments [i ])
218+ }
219+
220+ serializedAttachments , err := json .Marshal (newAttachments )
221+ Expect (err ).NotTo (HaveOccurred ())
222+ pod .Annotations [nad .NetworkAttachmentAnnot ] = string (serializedAttachments )
223+
224+ _ , err = k8sClient .CoreV1 ().Pods (namespace ).UpdateStatus (
225+ context .TODO (),
226+ pod ,
227+ metav1.UpdateOptions {})
228+ Expect (err ).NotTo (HaveOccurred ())
229+ })
230+
231+ It ("nothing happens" , func () {
232+ Consistently (func () ([]nad.NetworkStatus , error ) {
233+ updatedPod , err := k8sClient .CoreV1 ().Pods (namespace ).Get (context .TODO (), podName , metav1.GetOptions {})
234+ if err != nil {
235+ return nil , err
236+ }
237+ status , err := networkStatus (updatedPod .Annotations )
238+ if err != nil {
239+ return nil , err
240+ }
241+ return status , nil
242+ }).Should (ConsistOf (ifaceStatus (namespace , networkName , "net0" , "" )))
243+ })
244+ })
205245 })
206246 })
207247})
0 commit comments