-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dpvs-agent dump/launch services #932
Conversation
you-looks-not-tasty
commented
Dec 26, 2023
- set query params 'snapshot' of API(/v2/vs) to dump the running service into cache file.
- resume running service with snapshot cache file by launch params 'init-mode=local'.
- new API(/v2/vs/${SERVICE-ID}/health) for dpvs-healthcheck.
…vice into cache file. 2. resume running service with snapshot cache file by launch params 'init-mode=local' 3. new API(/v2/vs/${SERVICE-ID}/health) for dpvs-healthcheck
// 4> bind laddr with vs (ipvsadm --add-laddr -z ${LADDR} -t ${VIPPORT} -F ${device}) | ||
laddr := types.NewLocalAddrFront() | ||
if err := laddr.ParseVipPortProto(vs.ID()); err != nil { | ||
} | ||
lds := make([]*types.LocalAddrDetail, len(laddrs.Items)) | ||
for i, lip := range laddrs.Items { | ||
lds[i] = types.NewLocalAddrDetail() | ||
lds[i].SetAddr(lip.Addr) | ||
lds[i].SetIfName(lip.Device) | ||
} | ||
laddr.Add(lds, cp, logger) | ||
// 5> ip addr add ${VIP} dev ${KNIDEVICE(lo?)} | ||
if err := device.NetlinkAddrAdd(service.Addr, announcePort.Switch, logger); err != nil { | ||
logger.Error("add addr", service.Addr, "onto device failed") | ||
errs = append(errs, err) | ||
} | ||
} | ||
// 6> dpip addr add ${LADDR} dev ${device} | ||
for _, lip := range laddrs.Items { | ||
lipAddr := types.NewInetAddrDetail() | ||
lipAddr.SetAddr(lip.Addr) | ||
lipAddr.SetIfName(lip.Device) | ||
lipAddr.SetFlags("sapool") | ||
resultCode := lipAddr.Add(cp, logger) | ||
logger.Info("Add addr to device done.", "Device", lip.Device, "Addr", lip.Addr, "result", resultCode.String()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were the following cases considered?
- The forwarding mode is not FNAT, such as DR, Tunnel.
- The local addresses for FNAT services aren't always the same.
- The virtual addresses aren't required announced on netlink device.
The above features may not support in this intial version, but at least should be handled properly to ensure the procedure is successful and all the services booting from local file are correct.
VsAnnouncePort: | ||
type: object | ||
properties: | ||
switch: | ||
type: string | ||
dpvs: | ||
type: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little hard to understand. Add some comments or use more expresive names?
services := &models.VirtualServerList{Items: make([]*models.VirtualServerSpecExpand, len(snapshot.Services))} | ||
i := 0 | ||
for _, svc := range snapshot.Services { | ||
services.Items[i] = svc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is deepcopy needed here?
if err := os.Rename(cacheFile, bakName); err != nil { | ||
logger.Error(err.Error()) | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it consider the case where the chacheFile
doesn't exist?
func ShareSnapshot() *types.NodeSnapshot { | ||
initOnce.Do(setUp) | ||
return shareSnapshot | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should multi-thread safety be considered for the global data shareSnapshot
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please amend the issues mentioned in the review later.