Skip to content

Commit

Permalink
fix templates install issues (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
gertd authored Dec 12, 2024
1 parent 7985281 commit 17bfe5a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
26 changes: 9 additions & 17 deletions pkg/app/topaz.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,30 +265,22 @@ type services struct {

func mapToGRPCPorts(api map[string]*builder.API) map[string]services {
portMap := make(map[string]services)

for key, config := range api {
serv := services{}
if existing, ok := portMap[config.GRPC.ListenAddress]; ok {
serv = existing
serv.registeredServices = append(serv.registeredServices, key)
existing.registeredServices = append(existing.registeredServices, key)
if existing.API.Gateway.ListenAddress == "" && config.Gateway.ListenAddress != "" {
existing.API.Gateway = config.Gateway
}
portMap[config.GRPC.ListenAddress] = existing
} else {
serv := services{}
serv.registeredServices = append(serv.registeredServices, key)
serv.API = config
portMap[config.GRPC.ListenAddress] = serv
}
// set default gateway timeouts
if serv.API.Gateway.ReadTimeout == 0 {
serv.API.Gateway.ReadTimeout = 2 * time.Second
}
if serv.API.Gateway.ReadHeaderTimeout == 0 {
serv.API.Gateway.ReadHeaderTimeout = 2 * time.Second
}
if serv.API.Gateway.WriteTimeout == 0 {
serv.API.Gateway.WriteTimeout = 2 * time.Second
}
if serv.API.Gateway.IdleTimeout == 0 {
serv.API.Gateway.IdleTimeout = 30 * time.Second
}
portMap[config.GRPC.ListenAddress] = serv
}

return portMap
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cc/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
healthpb "google.golang.org/grpc/health/grpc_health_v1"
)

const rpcTimeout = time.Second * 30
const rpcTimeout = time.Second * 10

// ServiceHealthStatus adopted from grpc-health-probe cli implementation
// https://github.com/grpc-ecosystem/grpc-health-probe/blob/master/main.go.
Expand Down
29 changes: 17 additions & 12 deletions pkg/cli/cmd/templates/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func (cmd *InstallTemplateCmd) installTemplate(c *cc.CommonCtx, tmpl *template)
CACertPath: "",
Insecure: false,
NoTLS: true,
NoProxy: false,
}

if healthy, err := cc.ServiceHealthStatus(c.Context, healthCfg, "model"); err != nil {
Expand Down Expand Up @@ -375,20 +376,24 @@ func (i *tmplInstaller) runTemplateTests() error {
Desc: "on-error",
},
&azc.Config{
Host: cc.AuthorizerSvc(),
APIKey: i.cfg.APIKey,
Token: i.cfg.Token,
Insecure: i.cfg.Insecure,
TenantID: i.cfg.TenantID,
Headers: i.cfg.Headers,
Host: cc.AuthorizerSvc(),
APIKey: i.cfg.APIKey,
Token: i.cfg.Token,
Insecure: i.cfg.Insecure,
Plaintext: i.cfg.Plaintext,
TenantID: i.cfg.TenantID,
Headers: i.cfg.Headers,
Timeout: i.cfg.Timeout,
},
&dsc.Config{
Host: i.cfg.Host,
APIKey: i.cfg.APIKey,
Token: i.cfg.Token,
Insecure: i.cfg.Insecure,
TenantID: i.cfg.TenantID,
Headers: i.cfg.Headers,
Host: i.cfg.Host,
APIKey: i.cfg.APIKey,
Token: i.cfg.Token,
Insecure: i.cfg.Insecure,
Plaintext: i.cfg.Plaintext,
TenantID: i.cfg.TenantID,
Headers: i.cfg.Headers,
Timeout: i.cfg.Timeout,
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/builder/service_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (f *ServiceFactory) prepareGateway(config *API, gatewayOpts *GatewayOptions
runtimeMux := f.gatewayMux(config.Gateway.AllowedHeaders, gatewayOpts.ErrorHandler)

opts := []grpc.DialOption{}
if config.GRPC.Certs.HasCert() {
if config.GRPC.Certs.HasCA() {
tlsCreds, err := config.GRPC.Certs.ClientCredentials(true)
if err != nil {
return nil, errors.Wrapf(err, "failed to get TLS credentials")
Expand Down

0 comments on commit 17bfe5a

Please sign in to comment.