Skip to content

Commit

Permalink
cleanup ipv6 format mess
Browse files Browse the repository at this point in the history
  • Loading branch information
margau committed Mar 12, 2024
1 parent f950bd8 commit 0d354e3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions frontend/gotgt/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ func (t *goTgt) Startup(name string, frontendIP string, clusterIP string, size,
continue
}
break
} else if ipv6 := addr.To16(); ipv6 != nil {
// second try: handle addr as v6 address only if we know it is not v4
frontendIP = ipv6.String()
if frontendIP == "::1" {
continue
}
break
}
}
}
Expand Down
Binary file modified package/jivactl
Binary file not shown.
Binary file modified package/longhorn
Binary file not shown.
20 changes: 14 additions & 6 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ func (t *Task) DeleteSnapshot(snapshot string) error {
return t.client.DeleteSnapshot(snapshot)
}

func cleanAddr(replicaAddress string) string {
// This is a hack to sort out the replica ip address issue.
// This should be properly handled in future, e.g. with netip.Addr as the replica addr.
addr := strings.Split(replicaAddress, "://")
parts := strings.Split(addr[1], ":")
if len(parts) > 0 {
parts = parts[:len(parts)-1]
}
return strings.Join(parts, ":")
}

func getNameAndIndex(chain []string, snapshot string) (string, int) {
index := find(chain, snapshot)
if index < 0 {
Expand Down Expand Up @@ -106,8 +117,6 @@ Register:
if err != nil {
return err
}
addr := strings.Split(replicaAddress, "://")
parts := strings.Split(addr[1], ":")
Replica, _ := replica.CreateTempReplica(s)
server, _ := replica.CreateTempServer(s)

Expand All @@ -116,7 +125,7 @@ Register:
replicaType := "quorum"
upTime := time.Since(Replica.ReplicaStartTime)
state, _ := server.PrevStatus()
_ = t.client.Register(parts[0], Replica.Info().UUID, revisionCount, replicaType, upTime, string(state))
_ = t.client.Register(cleanAddr(replicaAddress), Replica.Info().UUID, revisionCount, replicaType, upTime, string(state))
select {
case <-ticker.C:
goto Register
Expand Down Expand Up @@ -258,15 +267,14 @@ Register:
if err != nil {
return fmt.Errorf("failed to get volume info, error: %s", err.Error())
}
addr := strings.Split(replicaAddress, "://")
parts := strings.Split(addr[1], ":")

if volume.ReplicaCount == 0 {
revisionCount := Replica.GetRevisionCounter()
replicaType := "Backend"
upTime := time.Since(Replica.ReplicaStartTime)
state, _ := server.PrevStatus()
logrus.Infof("Register replica at controller")
err := t.client.Register(parts[0], Replica.Info().UUID, revisionCount, replicaType, upTime, string(state))
err := t.client.Register(cleanAddr(replicaAddress), Replica.Info().UUID, revisionCount, replicaType, upTime, string(state))
if err != nil {
logrus.Errorf("Error in sending register command, error: %s", err)
}
Expand Down

0 comments on commit 0d354e3

Please sign in to comment.