diff --git a/core/pkg/ingress/annotations/ratelimit/main.go b/core/pkg/ingress/annotations/ratelimit/main.go index 774bf6e07..97af41e10 100644 --- a/core/pkg/ingress/annotations/ratelimit/main.go +++ b/core/pkg/ingress/annotations/ratelimit/main.go @@ -70,8 +70,23 @@ func ParseAnnotations(ing *extensions.Ingress) (*RateLimit, error) { return &RateLimit{}, parser.ErrMissingAnnotations } - rps, _ := parser.GetIntAnnotation(limitRPS, ing) - conn, _ := parser.GetIntAnnotation(limitIP, ing) + rpsMissing := false + rps, err := parser.GetIntAnnotation(limitRPS, ing) + if err != nil && err != parser.ErrMissingAnnotations { + return &RateLimit{}, err + } + if err == parser.ErrMissingAnnotations { + rpsMissing = true + } + conn, errip := parser.GetIntAnnotation(limitIP, ing) + if errip != nil && errip != parser.ErrMissingAnnotations { + return &RateLimit{}, errip + } + if rpsMissing && errip == parser.ErrMissingAnnotations { + // Both annotations missing, that's not an 'InvalidRateLimit', return the + // right error + return &RateLimit{}, parser.ErrMissingAnnotations + } if rps == 0 && conn == 0 { return &RateLimit{ diff --git a/core/pkg/ingress/annotations/rewrite/main.go b/core/pkg/ingress/annotations/rewrite/main.go index 33ff7bcad..d40e4b8a0 100644 --- a/core/pkg/ingress/annotations/rewrite/main.go +++ b/core/pkg/ingress/annotations/rewrite/main.go @@ -17,8 +17,6 @@ limitations under the License. package rewrite import ( - "errors" - "k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/ingress/core/pkg/ingress/annotations/parser" @@ -46,7 +44,7 @@ type Redirect struct { // rule used to rewrite the defined paths func ParseAnnotations(cfg defaults.Backend, ing *extensions.Ingress) (*Redirect, error) { if ing.GetAnnotations() == nil { - return &Redirect{}, errors.New("no annotations present") + return &Redirect{}, parser.ErrMissingAnnotations } sslRe, err := parser.GetBoolAnnotation(sslRedirect, ing)