Skip to content

Commit

Permalink
Merge branch 'main' into dev/438
Browse files Browse the repository at this point in the history
  • Loading branch information
phisco committed Jul 20, 2022
2 parents ec83e8c + 197b3f2 commit c059606
Show file tree
Hide file tree
Showing 9 changed files with 11,264 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/src/installation_upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
The operator can be installed like any other resource in Kubernetes,
through a YAML manifest applied via `kubectl`.

You can install the [latest operator manifest](https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/releases/cnpg-1.15.1.yaml)
You can install the [latest operator manifest](https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/releases/cnpg-1.16.0.yaml)
as follows:

```sh
kubectl apply -f \
https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/releases/cnpg-1.15.1.yaml
https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/releases/cnpg-1.16.0.yaml
```

Once you have run the `kubectl` command, CloudNativePG will be installed in your Kubernetes cluster.
Expand Down
7 changes: 5 additions & 2 deletions internal/cmd/manager/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/cloudnative-pg/cloudnative-pg/internal/configuration"
"github.com/cloudnative-pg/cloudnative-pg/pkg/certs"
"github.com/cloudnative-pg/cloudnative-pg/pkg/management/log"
"github.com/cloudnative-pg/cloudnative-pg/pkg/management/postgres/webserver"
"github.com/cloudnative-pg/cloudnative-pg/pkg/multicache"
"github.com/cloudnative-pg/cloudnative-pg/pkg/utils"
"github.com/cloudnative-pg/cloudnative-pg/pkg/versions"
Expand Down Expand Up @@ -430,8 +431,10 @@ func startPprofDebugServer(ctx context.Context) {
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)

pprofServer := http.Server{
Addr: "0.0.0.0:6060",
Handler: mux,
Addr: "0.0.0.0:6060",
Handler: mux,
ReadTimeout: webserver.DefaultReadTimeout,
ReadHeaderTimeout: webserver.DefaultReadHeaderTimeout,
}

setupLog.Info("Starting pprof HTTP server", "addr", pprofServer.Addr)
Expand Down
10 changes: 8 additions & 2 deletions pkg/management/pgbouncer/metricsserver/metricsserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promhttp"

"github.com/cloudnative-pg/cloudnative-pg/pkg/management/postgres/webserver"
"github.com/cloudnative-pg/cloudnative-pg/pkg/management/url"
)

Expand Down Expand Up @@ -56,12 +57,17 @@ func Setup() error {
return nil
}

// ListenAndServe starts a the web server handling metrics
// ListenAndServe starts the web server handling metrics
func ListenAndServe() error {
serveMux := http.NewServeMux()
serveMux.Handle(url.PathMetrics, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))

server = &http.Server{Addr: fmt.Sprintf(":%d", url.PgBouncerMetricsPort), Handler: serveMux}
server = &http.Server{
Addr: fmt.Sprintf(":%d", url.PgBouncerMetricsPort),
Handler: serveMux,
ReadTimeout: webserver.DefaultReadTimeout,
ReadHeaderTimeout: webserver.DefaultReadHeaderTimeout,
}
err := server.ListenAndServe()

// The metricsServer has been shut down
Expand Down
7 changes: 6 additions & 1 deletion pkg/management/postgres/webserver/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ func NewLocalWebServer(instance *postgres.Instance) (*Webserver, error) {
serveMux.HandleFunc(url.PathCache, endpoints.serveCache)
serveMux.HandleFunc(url.PathPgBackup, endpoints.requestBackup)

server := &http.Server{Addr: fmt.Sprintf("localhost:%d", url.LocalPort), Handler: serveMux}
server := &http.Server{
Addr: fmt.Sprintf("localhost:%d", url.LocalPort),
Handler: serveMux,
ReadHeaderTimeout: DefaultReadTimeout,
ReadTimeout: DefaultReadTimeout,
}

webserver := NewWebServer(instance, server)

Expand Down
7 changes: 6 additions & 1 deletion pkg/management/postgres/webserver/metricserver/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ func New(serverInstance *postgres.Instance) (*MetricsServer, error) {
serveMux := http.NewServeMux()
serveMux.Handle(url.PathMetrics, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))

server := &http.Server{Addr: fmt.Sprintf(":%d", url.PostgresMetricsPort), Handler: serveMux}
server := &http.Server{
Addr: fmt.Sprintf(":%d", url.PostgresMetricsPort),
Handler: serveMux,
ReadTimeout: webserver.DefaultReadTimeout,
ReadHeaderTimeout: webserver.DefaultReadHeaderTimeout,
}

metricServer := &MetricsServer{
Webserver: webserver.NewWebServer(serverInstance, server),
Expand Down
7 changes: 6 additions & 1 deletion pkg/management/postgres/webserver/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ func NewRemoteWebServer(
serveMux.HandleFunc(url.PathUpdate,
endpoints.updateInstanceManager(cancelFunc, exitedConditions))

server := &http.Server{Addr: fmt.Sprintf(":%d", url.StatusPort), Handler: serveMux}
server := &http.Server{
Addr: fmt.Sprintf(":%d", url.StatusPort),
Handler: serveMux,
ReadTimeout: DefaultReadTimeout,
ReadHeaderTimeout: DefaultReadHeaderTimeout,
}

return NewWebServer(instance, server), nil
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/management/postgres/webserver/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ package webserver
import (
"context"
"net/http"
"time"

"github.com/cloudnative-pg/cloudnative-pg/pkg/management/log"
"github.com/cloudnative-pg/cloudnative-pg/pkg/management/postgres"
)

const (
// DefaultReadTimeout is the default value to be used by the webservers
DefaultReadTimeout = 20 * time.Second
// DefaultReadHeaderTimeout is the default value to be used by the webservers
DefaultReadHeaderTimeout = 3 * time.Second
)

// Webserver contains a server that interacts with postgres instance
type Webserver struct {
// instance is the PostgreSQL instance to be collected
Expand Down
6 changes: 3 additions & 3 deletions pkg/versions/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ package versions

const (
// Version is the version of the operator
Version = "1.15.1"
Version = "1.16.0"

// DefaultImageName is the default image used by the operator to create pods
DefaultImageName = "ghcr.io/cloudnative-pg/postgresql:14.4"

// DefaultOperatorImageName is the default operator image used by the controller in the pods running PostgreSQL
DefaultOperatorImageName = "ghcr.io/cloudnative-pg/cloudnative-pg:1.15.1"
DefaultOperatorImageName = "ghcr.io/cloudnative-pg/cloudnative-pg:1.16.0"
)

// BuildInfo is a struct containing all the info about the build
Expand All @@ -36,7 +36,7 @@ type BuildInfo struct {

var (
// buildVersion injected during the build
buildVersion = "1.15.1"
buildVersion = "1.16.0"

// buildCommit injected during the build
buildCommit = "none"
Expand Down

0 comments on commit c059606

Please sign in to comment.