diff --git a/managed/services/server/server.go b/managed/services/server/server.go index 258fb7647f..08bec308bc 100644 --- a/managed/services/server/server.go +++ b/managed/services/server/server.go @@ -513,6 +513,7 @@ func (s *Server) validateChangeSettingsRequest(ctx context.Context, req *serverp if req.PmmPublicAddress != "" && req.RemovePmmPublicAddress { return status.Error(codes.InvalidArgument, "Both pmm_public_address and remove_pmm_public_address are present.") } + if req.SshKey != "" { if err := s.validateSSHKey(ctx, req.SshKey); err != nil { return err @@ -797,7 +798,7 @@ func (s *Server) TestEmailAlertingSettings( return &serverpb.TestEmailAlertingSettingsResponse{}, nil } -// UpdateConfigurations updates supervisor config and requests configuration update for VictoriaMetrics components. +// UpdateConfigurations updates supervisor config and requests configuration update for PMM components. func (s *Server) UpdateConfigurations(ctx context.Context) error { settings, err := models.GetSettings(s.db) if err != nil { diff --git a/managed/services/supervisord/supervisord.go b/managed/services/supervisord/supervisord.go index 40f7e21061..3a596c54e2 100644 --- a/managed/services/supervisord/supervisord.go +++ b/managed/services/supervisord/supervisord.go @@ -445,6 +445,19 @@ func (s *Service) marshalConfig(tmpl *template.Template, settings *models.Settin s.addPostgresParams(templateParams) + templateParams["PMMServerHost"] = "" + if settings.PMMPublicAddress != "" { + publicURL, err := url.Parse(settings.PMMPublicAddress) + if err != nil { + return nil, errors.Wrap(err, "failed to parse PMM public address.") + } + if publicURL.Host == "" { + if publicURL, err = url.Parse(fmt.Sprintf("https://%s", settings.PMMPublicAddress)); err != nil { + return nil, errors.Wrap(err, "failed to parse PMM public address.") + } + } + templateParams["PMMServerHost"] = publicURL.Host + } if ssoDetails != nil { u, err := url.Parse(ssoDetails.IssuerURL) if err != nil { @@ -782,8 +795,10 @@ command = /usr/sbin/grafana server --homepath=/usr/share/grafana --config=/etc/grafana/grafana.ini + {{- if .PMMServerHost}} + cfg:default.server.domain="{{ .PMMServerHost }}" + {{- end}} {{- if .PerconaSSODetails}} - cfg:default.server.domain="{{ .PMMServerAddress }}" cfg:default.auth.generic_oauth.enabled=true cfg:default.auth.generic_oauth.name="Percona Account" cfg:default.auth.generic_oauth.client_id="{{ .PerconaSSODetails.GrafanaClientID }}"