-
Notifications
You must be signed in to change notification settings - Fork 739
Passive Update mode supported #1014
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
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,6 +15,7 @@ | |||||||||||||||||||||||||||||||||||||
package ipvs | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||
"sort" | ||||||||||||||||||||||||||||||||||||||
"strings" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
"github.com/dpvs-agent/models" | ||||||||||||||||||||||||||||||||||||||
|
@@ -73,11 +74,57 @@ func (h *postVsRs) Handle(params apiVs.PostVsVipPortRsParams) middleware.Respond | |||||||||||||||||||||||||||||||||||||
rss[i].SetInhibited(&inhibited) | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
update := !*params.PassiveUpdate | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
shareSnapshot := settings.ShareSnapshot() | ||||||||||||||||||||||||||||||||||||||
if shareSnapshot.ServiceLock(params.VipPort) { | ||||||||||||||||||||||||||||||||||||||
defer shareSnapshot.ServiceUnlock(params.VipPort) | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
// default passiveUpdate == false | ||||||||||||||||||||||||||||||||||||||
if *params.PassiveUpdate { | ||||||||||||||||||||||||||||||||||||||
// passiveUpdate == true | ||||||||||||||||||||||||||||||||||||||
vsModel := shareSnapshot.ServiceGet(params.VipPort) | ||||||||||||||||||||||||||||||||||||||
if vsModel == nil { | ||||||||||||||||||||||||||||||||||||||
h.logger.Info("Try update update. vs not found in snapshot.", "VipPort", params.VipPort) | ||||||||||||||||||||||||||||||||||||||
update = true | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if vsModel != nil { | ||||||||||||||||||||||||||||||||||||||
if len(vsModel.RSs.Items) != len(rss) { | ||||||||||||||||||||||||||||||||||||||
h.logger.Info("Try update update. vs rss len has changed.", "VipPort", params.VipPort) | ||||||||||||||||||||||||||||||||||||||
update = true | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+89
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The log message contains a duplicated word 'update update'. Consider revising it to a clearer message such as 'Attempt update: vs not found in snapshot.'
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback
Comment on lines
+95
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The log message uses the duplicated phrase 'update update'. Consider revising it to 'Attempt update: vs RS list length has changed.' for clarity.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if len(vsModel.RSs.Items) == len(rss) { | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the contrary side of previous if condition. if...else... is more efficient. |
||||||||||||||||||||||||||||||||||||||
cacheRSs := (types.SliceRealServerSpecExpandModel)(vsModel.RSs.Items) | ||||||||||||||||||||||||||||||||||||||
sort.Sort(cacheRSs) | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
newRSs := (types.SliceRealServerSpec)(rss) | ||||||||||||||||||||||||||||||||||||||
sort.Sort(newRSs) | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
for i, newRs := range newRSs { | ||||||||||||||||||||||||||||||||||||||
cacheRs := cacheRSs[i] | ||||||||||||||||||||||||||||||||||||||
if int(cacheRs.Spec.Weight) != int(newRs.GetWeight()) { | ||||||||||||||||||||||||||||||||||||||
h.logger.Info("Try update update. rs weight has changed.", "VipPort", params.VipPort, "rs", newRs.ID(), "cache weight", cacheRs.Spec.Weight, "update weight", newRs.GetWeight()) | ||||||||||||||||||||||||||||||||||||||
update = true | ||||||||||||||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if !strings.EqualFold(strings.ToUpper(cacheRs.Spec.Mode), strings.ToUpper(newRs.GetFwdModeString())) { | ||||||||||||||||||||||||||||||||||||||
h.logger.Info("Try update update. rs nat mode has changed.", "VipPort", params.VipPort, "rs", newRs.ID(), "cache nat mode", cacheRs.Spec.Mode, "update nat mode", newRs.GetFwdModeString()) | ||||||||||||||||||||||||||||||||||||||
update = true | ||||||||||||||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't it need to consider any other field changes in RS? |
||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if !update { | ||||||||||||||||||||||||||||||||||||||
return apiVs.NewPostVsVipPortRsOK().WithPayload("PassiveUpdate") | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
result := front.Update(rss, h.connPool, h.logger) | ||||||||||||||||||||||||||||||||||||||
switch result { | ||||||||||||||||||||||||||||||||||||||
case types.EDPVS_EXIST, types.EDPVS_OK: | ||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,54 @@ func (h *putVsItem) Handle(params apiVs.PutVsVipPortParams) middleware.Responder | |
} | ||
} | ||
|
||
update := !*params.PassiveUpdate | ||
|
||
shareSnapshot := settings.ShareSnapshot() | ||
if shareSnapshot.ServiceRLock(vs.ID()) { | ||
vsModel := shareSnapshot.ServiceGet(vs.ID()) | ||
if vsModel == nil { | ||
shareSnapshot.ServiceRUnlock(vs.ID()) | ||
return apiVs.NewPutVsVipPortInvalidBackend() | ||
} | ||
|
||
if *params.PassiveUpdate { | ||
// bypass VIP, Port, Protocol, Af, netmask | ||
if vsModel.Fwmark != vs.GetFwmark() || | ||
vsModel.ConnTimeout != vs.GetConnTimeout() || | ||
vsModel.Bps != vs.GetBps() || | ||
vsModel.LimitProportion != vs.GetLimitProportion() { | ||
|
||
h.logger.Info("Try to update !!! Fwmark | ConnTimeout | Bps | LimitProportion has Changed.", "VipPort", params.VipPort) | ||
|
||
update = true | ||
} | ||
|
||
// ExpireQuiescent | SynProxy | Quic | Persistence | ||
newFlags := vs.GetFlags() | ||
newFlagsNOT := ^newFlags | ||
tmpFlags := vsModel.RAMFlags ^ newFlagsNOT | ||
if (tmpFlags & vsModel.RAMFlags) != newFlags { | ||
Comment on lines
+116
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's purpose of the four line codes? To tell if |
||
|
||
h.logger.Info("Try to update !!! the flags has changed.", "VipPort", params.VipPort) | ||
|
||
update = true | ||
} | ||
|
||
if !strings.EqualFold(vs.GetSchedName(), vsModel.SchedName) { | ||
|
||
h.logger.Info("Try to update !!! the SchedName has changed.", "VipPort", params.VipPort) | ||
|
||
update = true | ||
} | ||
} | ||
|
||
shareSnapshot.ServiceRUnlock(vs.ID()) | ||
} | ||
|
||
if !update { | ||
return apiVs.NewPutVsVipPortOK().WithPayload("PassiveUpdate") | ||
} | ||
|
||
result := vs.Add(h.connPool, h.logger) | ||
h.logger.Info("Add virtual server done.", "vs", vs, "result", result.String()) | ||
switch result { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
It's the contrary side of previous
if
condition.if...else...
is more efficient.