@@ -12,6 +12,7 @@ import (
1212 "sync"
1313 "time"
1414
15+ "github.com/hashicorp/go-multierror"
1516 "github.com/pkg/errors"
1617 "github.com/rs/zerolog/log"
1718 "github.com/threefoldtech/zbus"
@@ -558,6 +559,9 @@ func (g *gatewayModule) SetNamedProxy(wlID string, config zos.GatewayNameProxy)
558559 ctx , cancel := context .WithTimeout (context .Background (), 1 * time .Minute )
559560 defer cancel ()
560561
562+ if len (config .Backends ) <= 0 {
563+ return "" , fmt .Errorf ("at least one backend is needed got '%d'" , len (config .Backends ))
564+ }
561565 twinID , _ , _ , err := gridtypes .WorkloadID (wlID ).Parts ()
562566 if err != nil {
563567 return "" , errors .Wrap (err , "invalid workload id" )
@@ -596,6 +600,9 @@ func (g *gatewayModule) SetFQDNProxy(wlID string, config zos.GatewayFQDNProxy) e
596600 ctx , cancel := context .WithTimeout (context .Background (), 1 * time .Minute )
597601 defer cancel ()
598602
603+ if len (config .Backends ) <= 0 {
604+ return fmt .Errorf ("at least one backend is needed got '%d'" , len (config .Backends ))
605+ }
599606 cfg , err := g .ensureGateway (ctx , false )
600607 if err != nil {
601608 return err
@@ -623,12 +630,17 @@ func (g *gatewayModule) setupRouting(ctx context.Context, wlID string, fqdn stri
623630 g .domainLock .Lock ()
624631 defer g .domainLock .Unlock ()
625632
633+ var errs error
626634 for _ , backend := range config .Backends {
627635 if err := backend .Valid (config .TLSPassthrough ); err != nil {
628- return errors .Wrapf (err , "failed to validate backend '%s'" , backend )
636+ errs = multierror . Append ( errs , errors .Wrapf (err , "failed to validate backend '%s'" , backend ) )
629637 }
630638 }
631639
640+ if errs != nil {
641+ return errs
642+ }
643+
632644 if _ , ok := g .getReservedDomain (fqdn ); ok {
633645 return errors .Errorf ("domain already registered: %s" , fqdn )
634646 }
@@ -654,7 +666,7 @@ func (g *gatewayModule) setupRouting(ctx context.Context, wlID string, fqdn stri
654666 }
655667 ns := net .Namespace (ctx , netID )
656668
657- processedBackends := make ( []zos.Backend , 0 , len ( config . Backends ))
669+ processedBackends := []zos.Backend {}
658670 for _ , backend := range config .Backends {
659671 processedBackend , err := g .nncEnsure (wlID , ns , backend )
660672 if err != nil {
@@ -685,7 +697,7 @@ func (g *gatewayModule) setupRoutingGeneric(wlID string, fqdn string, tlsConfig
685697 rule = fmt .Sprintf ("Host(`%s`)" , fqdn )
686698 }
687699
688- servers := make ( []Server , 0 , len ( config . Backends ))
700+ servers := []Server {}
689701 for _ , backend := range config .Backends {
690702 var server Server
691703 if config .TLSPassthrough {
0 commit comments