Repository navigation
fix(controller): parse master_host on the first colon only - #618
arpitjain099 wants to merge 2 commits into
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
| if masterIp != redisMasterIp { | ||
| if masterIp != pod.Labels[resources.MasterIpLabelKey] && masterIp != pod.Annotations[resources.MasterIpAnnotationKey] { | ||
| return false, nil | ||
| } | ||
| } |
There was a problem hiding this comment.
@arpitjain099 do we now need resources.MasterIpLabelKey and resources.MasterIpAnnotationKey?
There was a problem hiding this comment.
@tjovicic The annotation is still needed: a label value cannot contain colons, so it is the only one that can hold an IPv6 master. The label is already IPv4-only and marked for removal. Please say if you would like it dropped here or separately.
There was a problem hiding this comment.
@arpitjain099 the change look ok to me. Could you improve the tests a bit:
- make them table driven and add a negative test
- reuse
fakeTakeoverServerinstead of creatingfakeInfoServer - is this line in the PR description
A replica with no annotation then has REPLICAOF re-issued on every reconcile.correct? Is it on every reconcile or the first reconcile?
Except that i think we can merge it. @Abhra303 wdyt?
There was a problem hiding this comment.
@tjovicic Both done: the table now has two negatives, a replica pointed at another master and a pod reporting the master role, and it uses fakeTakeoverServer, which I extended to answer INFO.
There was a problem hiding this comment.
@tjovicic You were right to question that line. It is the first reconcile, not every one: replicaOf writes the masterIP annotation, which matches on the next pass and hides the mismatch. I have corrected the description, so please take another look.
| // Split on the first colon only: an IPv6 master_host contains colons of its | ||
| // own, and splitting on every one of them keeps just the first group. |
There was a problem hiding this comment.
maybe move this comment to parseInfoToMap func
There was a problem hiding this comment.
@tjovicic Moved, it is the doc comment on parseInfoToMap now, which is where the split actually happens.
| if masterIp != redisMasterIp { | ||
| if masterIp != pod.Labels[resources.MasterIpLabelKey] && masterIp != pod.Annotations[resources.MasterIpAnnotationKey] { | ||
| return false, nil | ||
| } | ||
| } |
There was a problem hiding this comment.
@arpitjain099 the change look ok to me. Could you improve the tests a bit:
- make them table driven and add a negative test
- reuse
fakeTakeoverServerinstead of creatingfakeInfoServer - is this line in the PR description
A replica with no annotation then has REPLICAOF re-issued on every reconcile.correct? Is it on every reconcile or the first reconcile?
Except that i think we can merge it. @Abhra303 wdyt?
Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
checkReplicaRolereadsmaster_hostfromINFO replicationwithstrings.Split(line, ":")[1], so an IPv6 address such asfd00:10:244::5comes back asfd00. The comparison against the expected master can then never match, and the outcome rests on the IPv4-onlymaster-iplabel (#313) and on the annotation. REPLICAOF is re-issued once, on the first reconcile where the annotation is missing or stale, and the annotationreplicaOfwrites masks the mismatch after that.parseInfoToMapin the same file splits on the first colon, andisReplicaStableandgetMasterCandidatealready use it, socheckReplicaRolenow goes through it too. The tests are table driven, with the IPv6 case, an IPv4 control, and two negatives.