diff --git a/nginx-controller/nginx/configurator.go b/nginx-controller/nginx/configurator.go index 63ab37120a..48d6c10405 100644 --- a/nginx-controller/nginx/configurator.go +++ b/nginx-controller/nginx/configurator.go @@ -57,10 +57,12 @@ func (cnf *Configurator) AddOrUpdateDHParam(content string) (string, error) { // AddOrUpdateIngress adds or updates NGINX configuration for the Ingress resource func (cnf *Configurator) AddOrUpdateIngress(ingEx *IngressEx) error { - cnf.addOrUpdateIngress(ingEx) - - if err := cnf.nginx.Reload(); err != nil { - return fmt.Errorf("Error when adding or updating ingress %v/%v: %v", ingEx.Ingress.Namespace, ingEx.Ingress.Name, err) + err := cnf.addOrUpdateIngress(ingEx) + if err != nil { + return fmt.Errorf("Error adding or updating ingress %v/%v: %v", ingEx.Ingress.Namespace, ingEx.Ingress.Name, err) + } + if err = cnf.nginx.Reload(); err != nil { + return fmt.Errorf("Error reloading NGINX for %v/%v: %v", ingEx.Ingress.Namespace, ingEx.Ingress.Name, err) } return nil } @@ -81,11 +83,13 @@ func (cnf *Configurator) addOrUpdateIngress(ingEx *IngressEx) error { // AddOrUpdateMergableIngress adds or updates NGINX configuration for the Ingress resources with Mergeable Types func (cnf *Configurator) AddOrUpdateMergableIngress(mergeableIngs *MergeableIngresses) error { - cnf.addOrUpdateMergableIngress(mergeableIngs) - - if err := cnf.nginx.Reload(); err != nil { + err := cnf.addOrUpdateMergableIngress(mergeableIngs) + if err != nil { return fmt.Errorf("Error when adding or updating ingress %v/%v: %v", mergeableIngs.Master.Ingress.Namespace, mergeableIngs.Master.Ingress.Name, err) } + if err = cnf.nginx.Reload(); err != nil { + return fmt.Errorf("Error reloading NGINX for %v/%v: %v", mergeableIngs.Master.Ingress.Namespace, mergeableIngs.Master.Ingress.Name, err) + } return nil } @@ -877,7 +881,10 @@ func upstreamMapToSlice(upstreams map[string]Upstream) []Upstream { func (cnf *Configurator) AddOrUpdateSecret(secret *api_v1.Secret) error { cnf.addOrUpdateSecret(secret) - kind, _ := GetSecretKind(secret) + kind, err := GetSecretKind(secret) + if err != nil { + return fmt.Errorf("Error secret is unknown") + } if cnf.isPlus() && kind == JWK { return nil } @@ -962,10 +969,13 @@ func (cnf *Configurator) DeleteIngress(key string) error { // UpdateEndpoints updates endpoints in NGINX configuration for the Ingress resource func (cnf *Configurator) UpdateEndpoints(ingEx *IngressEx) error { - cnf.addOrUpdateIngress(ingEx) + err := cnf.addOrUpdateIngress(ingEx) + if err != nil { + return fmt.Errorf("Error adding or updating ingress %v/%v: %v", ingEx.Ingress.Namespace, ingEx.Ingress.Name, err) + } if cnf.isPlus() { - err := cnf.updatePlusEndpoints(ingEx) + err = cnf.updatePlusEndpoints(ingEx) if err == nil { return nil } @@ -980,10 +990,12 @@ func (cnf *Configurator) UpdateEndpoints(ingEx *IngressEx) error { // UpdateEndpointsMergeableIngress updates endpoints in NGINX configuration for a mergeable Ingress resource func (cnf *Configurator) UpdateEndpointsMergeableIngress(mergeableIngs *MergeableIngresses) error { - cnf.addOrUpdateMergableIngress(mergeableIngs) + err := cnf.addOrUpdateMergableIngress(mergeableIngs) + if err != nil { + return fmt.Errorf("Error adding or updating ingress %v/%v: %v", mergeableIngs.Master.Ingress.Namespace, mergeableIngs.Master.Ingress.Name, err) + } if cnf.isPlus() { - var err error for _, ing := range mergeableIngs.Minions { err = cnf.updatePlusEndpoints(ing) if err != nil {