Skip to content

Commit

Permalink
Fix duplicate value in ports
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaps committed Dec 6, 2024
1 parent da9e0cf commit bb09519
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pkg/controller/kubevirteps/kubevirteps_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,23 @@ func (c *Controller) finalize(service *v1.Service, slicesToCreate []*discovery.E
if len(slicesToCreate) == 0 {
break
}
if slicesToDelete[i].AddressType == slicesToCreate[0].AddressType && ownedBy(slicesToDelete[i], service) {
slicesToCreate[0].Name = slicesToDelete[i].Name

sd := slicesToDelete[i]
sc := slicesToCreate[0]

if sd.AddressType == sc.AddressType && ownedBy(sd, service) {
// Save the slice we want to update
sliceToUpdate := sc
// Rename it
sliceToUpdate.Name = sd.Name

// Remove it from slicesToCreate
slicesToCreate = slicesToCreate[1:]
slicesToUpdate = append(slicesToUpdate, slicesToCreate[0])
// Remove the sliceToDelete
slicesToDelete = append(slicesToDelete[:i], slicesToDelete[i+1:]...)

// Now safely add the updated slice to slicesToUpdate
slicesToUpdate = append(slicesToUpdate, sliceToUpdate)
} else {
i++
}
Expand Down

0 comments on commit bb09519

Please sign in to comment.