updateOperatorLabels ensures that the instances are labelled as instances, and have the correct instance name Returns true if the instance needed updating
( ctx context.Context, instance *corev1.Pod, )
| 222 | // |
| 223 | // Returns true if the instance needed updating |
| 224 | func updateOperatorLabels( |
| 225 | ctx context.Context, |
| 226 | instance *corev1.Pod, |
| 227 | ) bool { |
| 228 | contextLogger := log.FromContext(ctx) |
| 229 | |
| 230 | if instance.Labels == nil { |
| 231 | instance.Labels = make(map[string]string) |
| 232 | } |
| 233 | |
| 234 | var modified bool |
| 235 | if instance.Labels[utils.InstanceNameLabelName] != instance.Name { |
| 236 | contextLogger.Info("Setting instance label name", "pod", instance.Name) |
| 237 | instance.Labels[utils.InstanceNameLabelName] = instance.Name |
| 238 | modified = true |
| 239 | } |
| 240 | |
| 241 | if instance.Labels[utils.PodRoleLabelName] != string(utils.PodRoleInstance) { |
| 242 | contextLogger.Info("Setting pod role label name", "pod", instance.Name) |
| 243 | instance.Labels[utils.PodRoleLabelName] = string(utils.PodRoleInstance) |
| 244 | modified = true |
| 245 | } |
| 246 | |
| 247 | return modified |
| 248 | } |
no test coverage detected