Skip to content

Commit

Permalink
Merge pull request #954 from abstractmj/v1.20.x
Browse files Browse the repository at this point in the history
fix: fix nil pointer error when clbingress is invalid; issue #953
  • Loading branch information
wenxinlee2015 authored Aug 24, 2021
2 parents 65c57f1 + 0b7fb29 commit f7f03fd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions bcs-services/bcs-clb-controller/pkg/processor/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,14 @@ func (updater *Updater) validateClbIngress(ingressList []*ingressType.ClbIngress
for _, tmpTCPRule := range tmpIngress.Spec.TCP {
err := tmpTCPRule.Validate()
if err != nil {
blog.Errorf("rule %s validate failed, err %s", tmpTCPRule.ToString(), err.Error())
tmpIngress.SetStatusMessage(ingressType.ClbIngressStatusAbnormal,
fmt.Sprintf("rule %s validate failed, err %s", tmpTCPRule.ToString(), err.Error()))
err = updater.ingressRegistry.SetIngress(tmpIngress)
if err != nil {
blog.Warnf("set ingress %s/%s failed, err %s",
tmpIngress.GetNamespace(), tmpIngress.GetName(), err.Error())
}
blog.Errorf("rule %s validate failed, err %s", tmpTCPRule.ToString(), err.Error())
return false
}
err = updater.validateFourLayerRuleConflict(tmpTCPRule, fourLayerMap, sevenLayerMap)
Expand All @@ -435,14 +435,14 @@ func (updater *Updater) validateClbIngress(ingressList []*ingressType.ClbIngress
for _, tmpUDPRule := range tmpIngress.Spec.UDP {
err := tmpUDPRule.Validate()
if err != nil {
blog.Errorf("rule %s validate failed, err %s", tmpUDPRule.ToString(), err.Error())
tmpIngress.SetStatusMessage(ingressType.ClbIngressStatusAbnormal,
fmt.Sprintf("rule %s validate failed, err %s", tmpUDPRule.ToString(), err.Error()))
err = updater.ingressRegistry.SetIngress(tmpIngress)
if err != nil {
blog.Warnf("set ingress %s/%s failed, err %s",
tmpIngress.GetNamespace(), tmpIngress.GetName(), err.Error())
}
blog.Errorf("rule %s validate failed, err %s", tmpUDPRule.ToString(), err.Error())
return false
}
err = updater.validateFourLayerRuleConflict(tmpUDPRule, fourLayerMap, sevenLayerMap)
Expand All @@ -460,14 +460,14 @@ func (updater *Updater) validateClbIngress(ingressList []*ingressType.ClbIngress
for _, tmpHTTPRule := range tmpIngress.Spec.HTTP {
err := tmpHTTPRule.ValidateHTTP()
if err != nil {
blog.Errorf("rule %s validate failed, err %s", tmpHTTPRule.ToString(), err.Error())
tmpIngress.SetStatusMessage(ingressType.ClbIngressStatusAbnormal,
fmt.Sprintf("rule %s validate failed, err %s", tmpHTTPRule.ToString(), err.Error()))
err = updater.ingressRegistry.SetIngress(tmpIngress)
if err != nil {
blog.Warnf("set ingress %s/%s failed, err %s",
tmpIngress.GetNamespace(), tmpIngress.GetName(), err.Error())
}
blog.Errorf("rule %s validate failed, err %s", tmpHTTPRule.ToString(), err.Error())
return false
}
err = updater.validateSevenLayerRuleConflict(tmpHTTPRule, fourLayerMap, sevenLayerMap)
Expand All @@ -485,14 +485,14 @@ func (updater *Updater) validateClbIngress(ingressList []*ingressType.ClbIngress
for _, tmpHTTPSRule := range tmpIngress.Spec.HTTPS {
err := tmpHTTPSRule.ValidateHTTPS()
if err != nil {
blog.Errorf("rule %s validate failed, err %s", tmpHTTPSRule.ToString(), err.Error())
tmpIngress.SetStatusMessage(ingressType.ClbIngressStatusAbnormal,
fmt.Sprintf("rule %s validate failed, err %s", tmpHTTPSRule.ToString(), err.Error()))
err = updater.ingressRegistry.SetIngress(tmpIngress)
if err != nil {
blog.Warnf("set ingress %s/%s failed, err %s",
tmpIngress.GetNamespace(), tmpIngress.GetName(), err.Error())
}
blog.Errorf("rule %s validate failed, err %s", tmpHTTPSRule.ToString(), err.Error())
return false
}
err = updater.validateSevenLayerRuleConflict(tmpHTTPSRule, fourLayerMap, sevenLayerMap)
Expand All @@ -508,7 +508,6 @@ func (updater *Updater) validateClbIngress(ingressList []*ingressType.ClbIngress
}
if err := updater.validateStatefulSetIngress(
tmpIngress.Spec.StatefulSet, fourLayerMap, sevenLayerMap); err != nil {

tmpIngress.SetStatusMessage(ingressType.ClbIngressStatusAbnormal, err.Error())
err = updater.ingressRegistry.SetIngress(tmpIngress)
if err != nil {
Expand Down

0 comments on commit f7f03fd

Please sign in to comment.