equalIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash] We ignore pod-template-hash because: 1. The hash result would be different upon podTemplateSpec API changes (e.g. the addition of a new field will cause the hash code to chang
(template1, template2 *corev1.PodTemplateSpec)
| 171 | // (e.g. the addition of a new field will cause the hash code to change) |
| 172 | // 2. The deployment template won't have hash labels |
| 173 | func equalIgnoreHash(template1, template2 *corev1.PodTemplateSpec) bool { |
| 174 | t1Copy := template1.DeepCopy() |
| 175 | t2Copy := template2.DeepCopy() |
| 176 | // Remove hash labels from template.Labels before comparing |
| 177 | delete(t1Copy.Labels, appsv1.DefaultDeploymentUniqueLabelKey) |
| 178 | delete(t2Copy.Labels, appsv1.DefaultDeploymentUniqueLabelKey) |
| 179 | return apiequality.Semantic.DeepEqual(t1Copy, t2Copy) |
| 180 | } |
| 181 | |
| 182 | // annotationsToSkip lists the annotations that should be preserved from the deployment and not |
| 183 | // copied from the replicaset when rolling a deployment back |