Skip to content

Commit

Permalink
Merge pull request #79 from woblerr/bump_infra
Browse files Browse the repository at this point in the history
  • Loading branch information
woblerr authored Apr 6, 2024
2 parents 2f45066 + a809b41 commit 363f4e2
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 29 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
build:
runs-on: ubuntu-latest
env:
backrest_version: "2.48"
docker_backrest_version: "v0.21"
backrest_version: "2.51"
docker_backrest_version: "v0.24"
build_platforms: "linux/amd64,linux/arm64"
steps:
- name: Set up go 1.20
- name: Set up go 1.21
uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.21"
id: go

- name: Checkout
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Run linters
uses: golangci/golangci-lint-action@v3
with:
version: v1.53.3
version: v1.56.2
env:
TZ: "Etc/UTC"

Expand Down Expand Up @@ -170,12 +170,12 @@ jobs:
needs: build
runs-on: ubuntu-latest
env:
goreleaser_version: "v1.20.0"
goreleaser_version: "v1.24.0"
steps:
- name: Set up go 1.20
- name: Set up go 1.21
uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.21"
id: go

- name: Checkout
Expand Down
11 changes: 11 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ linters-settings:
line-length: 140
gocyclo:
min-complexity: 20
gocritic:
enabled-tags:
- performance
- style
- experimental
disabled-checks:
- hugeParam
- rangeValCopy
- octalLiteral
- nestingReduce

linters:
enable:
Expand Down Expand Up @@ -51,6 +61,7 @@ issues:
exclude-rules:
- path: _test\.go
linters:
- gocritic
- gosec
- text: "at least one file in a package should have a package comment"
linters:
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG BACKREST_VERSION="2.48"
ARG DOCKER_BACKREST_VERSION="v0.21"
ARG BACKREST_VERSION="2.51"
ARG DOCKER_BACKREST_VERSION="v0.24"
ARG REPO_BUILD_TAG="unknown"

FROM golang:1.20-bookworm AS builder
FROM golang:1.21-bookworm AS builder
ARG REPO_BUILD_TAG
COPY . /build
WORKDIR /build
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.artifacts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM goreleaser/goreleaser:v1.20.0 as builder
FROM goreleaser/goreleaser:v1.24.0 as builder
WORKDIR /build
COPY . /build
RUN goreleaser release --snapshot --skip-publish --clean
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ BRANCH := $(subst /,-,$(BRANCH_FULL))
GIT_REV := $(shell git describe --abbrev=7 --always)
SERVICE_CONF_DIR := /etc/systemd/system
HTTP_PORT := 9854
BACKREST_VERSION := 2.48
DOCKER_BACKREST_VERSION := v0.21
BACKREST_VERSION := 2.51
DOCKER_BACKREST_VERSION := v0.24
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
DOCKER_CONTAINER_E2E := $(shell docker ps -a -q -f name=$(APP_NAME)_e2e)
HTTP_PORT_E2E := $(shell echo $$((10000 + ($$RANDOM % 10000))))
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ For a significant number of stanzas, this may require additional time to collect

### Building and running docker

By default, pgBackRest version is `2.48`. Another version can be specified via arguments.
By default, pgBackRest version is `2.51`. Another version can be specified via arguments.
For base image used [docker-pgbackrest](https://github.com/woblerr/docker-pgbackrest) image.

Environment variables supported by this image:
Expand Down Expand Up @@ -404,7 +404,7 @@ To communicate with pgBackRest TLS server you need correct pgBackRest config, fo

```ini
[demo]
pg1-path=/var/lib/postgresql/13/main
pg1-path=/var/lib/postgresql/16/main

[global]
repo1-host=backup
Expand Down
2 changes: 1 addition & 1 deletion backrest/backrest_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func StartPromEndpoint(logger log.Logger) {
}

// GetPgBackRestInfo get and parse pgBackRest info and set metrics
func GetPgBackRestInfo(config, configIncludePath, backupType string, stanzas []string, stanzasExclude []string, backupDBCount, backupDBCountLatest, verboseWAL bool, backupDBCountParallelProcesses int, logger log.Logger) {
func GetPgBackRestInfo(config, configIncludePath, backupType string, stanzas, stanzasExclude []string, backupDBCount, backupDBCountLatest, verboseWAL bool, backupDBCountParallelProcesses int, logger log.Logger) {
// To calculate the time elapsed since the last completed full, differential or incremental backup.
// For all stanzas values are calculated relative to one value.
currentUnixTime := time.Now().Unix()
Expand Down
13 changes: 7 additions & 6 deletions e2e_tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG BACKREST_VERSION="2.48"
ARG DOCKER_BACKREST_VERSION="v0.21"
ARG PG_VERSION="13"
ARG BACKREST_VERSION="2.51"
ARG DOCKER_BACKREST_VERSION="v0.24"
ARG PG_VERSION="16"

FROM golang:1.20-bookworm AS builder
FROM golang:1.21-bookworm AS builder
ARG REPO_BUILD_TAG
COPY . /build
WORKDIR /build
Expand All @@ -24,8 +24,9 @@ RUN apt-get update -y \
ca-certificates \
gnupg \
jq \
&& curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main" \
lsb-release \
&& curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list
RUN apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/pgbackrest.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[demo]
pg1-path=/var/lib/postgresql/13/main
pg1-path=/var/lib/postgresql/16/main

[global]
repo1-path=/var/lib/pgbackrest/repo1
Expand Down
6 changes: 3 additions & 3 deletions e2e_tests/prepare_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ EXPORTER_CONFIG="${1}"

PG_CLUSTER="main"
PG_DATABASE="test_db"
PG_BIN="/usr/lib/postgresql/13/bin"
PG_DATA="/var/lib/postgresql/13/${PG_CLUSTER}"
PG_BIN="/usr/lib/postgresql/16/bin"
PG_DATA="/var/lib/postgresql/16/${PG_CLUSTER}"
BACKREST_STANZA="demo"
EXPORTER_COMMAND="/etc/pgbackrest/pgbackrest_exporter \
--backrest.database-count \
Expand All @@ -18,7 +18,7 @@ EXPORTER_COMMAND="/etc/pgbackrest/pgbackrest_exporter \
# Enable checksums.
${PG_BIN}/pg_checksums -e -D ${PG_DATA}
# Start postgres.
pg_ctlcluster 13 ${PG_CLUSTER} start
pg_ctlcluster 16 ${PG_CLUSTER} start
# Create database.
psql -c "create database ${PG_DATABASE}"
db_oid=$(psql -t -c "select OID from pg_database where datname='demo_db';")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/woblerr/pgbackrest_exporter

go 1.20
go 1.21

require (
github.com/alecthomas/kingpin/v2 v2.3.2
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
Expand All @@ -24,9 +25,11 @@ github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
Expand All @@ -50,6 +53,7 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down Expand Up @@ -80,7 +84,9 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion pgbackrest_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestMain(t *testing.T) {
if err != nil {
t.Errorf("\nGet error during read resp body:\n%v", err)
}
if len(string(b)) == 0 {
if string(b) == "" {
t.Errorf("\nGet zero body:\n%s", string(b))
}
}
Expand Down

0 comments on commit 363f4e2

Please sign in to comment.