Avoid race conditions by copying the list before sorting (#8573)
Avoid race conditions by copying the list before sorting (#8573)

When creating several ingresses at the same time a race condition can
happen by modifying a variable deep in another object. When this race
condition is triggered the generated nginx configuration is broken:

```
nginx: [emerg] invalid parameter "8.8.8.8/32,8" in /tmp/nginx-cfg4027854160:671
nginx: configuration file /tmp/nginx-cfg4027854160 test failed
```

Once it happens, the controller won't ever be able to generate the
configuration again. Thus the only option is to restart the process.

There is not really a good way to reproduce this issue. It happens quite
sporadically every 2 or 3 days. However, after this fix has been
applied, we haven't seen it happen after about 4 weeks.

Co-authored-by: Ruud van der Weijde <374bc4897c869275edefea93a17e23fbb69b2efa@gmail.com>
kubernetes/ingress-nginx,kubernetes/ingress-nginx,kubernetes/ingress-nginx,kubernetes/ingress-nginx,kubernetes/ingress-nginx