Skip to content

Commit 79a9a8a

Browse files
authored
Merge branch 'main' into K8SPSMDB-972-k8s-1.27-e2e-tests-fix
2 parents ddaa33b + 048a113 commit 79a9a8a

File tree

141 files changed

+12235
-1168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+12235
-1168
lines changed

.github/workflows/reviewdog.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
name: runner / suggester / golangci-lint
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v3.5.3
8+
- uses: actions/checkout@v3.6.0
99
- name: golangci-lint
1010
uses: golangci/golangci-lint-action@v3
1111
with:
@@ -17,7 +17,7 @@ jobs:
1717
name: runner / suggester / gofmt
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3.5.3
20+
- uses: actions/checkout@v3.6.0
2121
- run: gofmt -w -s $(find . -not -path "*/vendor/*" -name "*.go")
2222
- uses: reviewdog/action-suggester@v1
2323
with:
@@ -27,7 +27,7 @@ jobs:
2727
name: runner / suggester / shfmt
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v3.5.3
30+
- uses: actions/checkout@v3.6.0
3131
- uses: actions/setup-go@v4
3232
with:
3333
go-version: '^1.17'
@@ -43,7 +43,7 @@ jobs:
4343
name: runner / shellcheck
4444
runs-on: ubuntu-latest
4545
steps:
46-
- uses: actions/checkout@v3.5.3
46+
- uses: actions/checkout@v3.6.0
4747
- uses: reviewdog/action-shellcheck@v1
4848
with:
4949
github_token: ${{ secrets.github_token }}
@@ -54,7 +54,7 @@ jobs:
5454
name: runner / misspell
5555
runs-on: ubuntu-latest
5656
steps:
57-
- uses: actions/checkout@v3.5.3
57+
- uses: actions/checkout@v3.6.0
5858
- uses: reviewdog/action-misspell@v1
5959
with:
6060
github_token: ${{ secrets.github_token }}
@@ -66,7 +66,7 @@ jobs:
6666
name: runner / alex
6767
runs-on: ubuntu-latest
6868
steps:
69-
- uses: actions/checkout@v3.5.3
69+
- uses: actions/checkout@v3.6.0
7070
- uses: reviewdog/action-alex@v1
7171
with:
7272
github_token: ${{ secrets.github_token }}

.github/workflows/scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- name: Checkout code
9-
uses: actions/checkout@v3.5.3
9+
uses: actions/checkout@v3.6.0
1010
- name: Build an image from Dockerfile
1111
run: |
1212
export IMAGE=perconalab/percona-server-mongodb-operator:${{ github.sha }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ jobs:
88
- uses: actions/setup-go@v4
99
with:
1010
go-version: '^1.19'
11-
- uses: actions/checkout@v3.5.3
11+
- uses: actions/checkout@v3.6.0
1212
- name: go test
1313
run: go test -v ./...

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ percona-server-mongodb-operator
116116
mongodb-healthcheck
117117

118118
!cmd/percona-server-mongodb-operator
119+
!cmd/mongodb-healthcheck
119120

120121
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
121122

build/physical-restore-ps-entry.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/bash
2-
set -Eeuo pipefail
32

3+
set -Eeuo pipefail
44
set -o xtrace
55

6-
/opt/percona/pbm-agent &
6+
log=/tmp/pbm-agent.log
77

8+
/opt/percona/pbm-agent 2> ${log} &
89
/opt/percona/ps-entry.sh "$@"
910

1011
echo "Physical restore in progress"
11-
12+
cat ${log}
1213
sleep infinity

clientcmd/clientcmd.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package clientcmd
22

33
import (
4+
"context"
45
"io"
56

67
corev1 "k8s.io/api/core/v1"
@@ -42,9 +43,9 @@ func NewClient() (*Client, error) {
4243
}, nil
4344
}
4445

45-
func (c *Client) Exec(pod *corev1.Pod, containerName string, command []string, stdin io.Reader, stdout, stderr io.Writer, tty bool) error {
46-
// Prepare the API URL used to execute another process within the Pod. In
47-
// this case, we'll run a remote shell.
46+
func (c *Client) Exec(ctx context.Context, pod *corev1.Pod, containerName string, command []string, stdin io.Reader, stdout, stderr io.Writer, tty bool) error {
47+
// Prepare the API URL used to execute another process within the Pod.
48+
// In this case, we'll run a remote shell.
4849
req := c.client.RESTClient().
4950
Post().
5051
Namespace(pod.Namespace).
@@ -66,7 +67,7 @@ func (c *Client) Exec(pod *corev1.Pod, containerName string, command []string, s
6667
}
6768

6869
// Connect this process' std{in,out,err} to the remote shell process.
69-
return exec.Stream(remotecommand.StreamOptions{
70+
return exec.StreamWithContext(ctx, remotecommand.StreamOptions{
7071
Stdin: stdin,
7172
Stdout: stdout,
7273
Stderr: stderr,

cmd/manager/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
// to ensure that exec-entrypoint and run can make use of them.
1212
_ "k8s.io/client-go/plugin/pkg/client/auth"
1313

14+
certmgrscheme "github.com/cert-manager/cert-manager/pkg/client/clientset/versioned/scheme"
1415
"github.com/go-logr/logr"
15-
certmgrscheme "github.com/jetstack/cert-manager/pkg/client/clientset/versioned/scheme"
1616
uzap "go.uber.org/zap"
1717
"go.uber.org/zap/zapcore"
1818
k8sruntime "k8s.io/apimachinery/pkg/runtime"

cmd/mongodb-healthcheck/main.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ package main
1717
import (
1818
"context"
1919
"os"
20+
"os/signal"
2021
"strconv"
2122
"strings"
23+
"syscall"
2224

2325
uzap "go.uber.org/zap"
2426
"go.uber.org/zap/zapcore"
@@ -36,6 +38,9 @@ var (
3638
)
3739

3840
func main() {
41+
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM, os.Interrupt)
42+
defer stop()
43+
3944
app := tool.New("Performs health and readiness checks for MongoDB", GitCommit, GitBranch)
4045

4146
k8sCmd := app.Command("k8s", "Performs liveness check for MongoDB on Kubernetes")
@@ -77,14 +82,14 @@ func main() {
7782
os.Exit(1)
7883
}
7984

80-
client, err := db.Dial(cnf)
85+
client, err := db.Dial(ctx, cnf)
8186
if err != nil {
8287
log.Error(err, "connection error")
8388
os.Exit(1)
8489
}
8590

8691
defer func() {
87-
if err := client.Disconnect(context.TODO()); err != nil {
92+
if err := client.Disconnect(ctx); err != nil {
8893
log.Error(err, "failed to disconnect")
8994
os.Exit(1)
9095
}
@@ -99,7 +104,7 @@ func main() {
99104
case "mongod":
100105
memberState, err := healthcheck.HealthCheckMongodLiveness(client, int64(*startupDelaySeconds))
101106
if err != nil {
102-
client.Disconnect(context.TODO()) // nolint:golint,errcheck
107+
client.Disconnect(ctx) // nolint:golint,errcheck
103108
log.Error(err, "Member failed Kubernetes liveness check")
104109
os.Exit(1)
105110
}
@@ -108,7 +113,7 @@ func main() {
108113
case "mongos":
109114
err := healthcheck.HealthCheckMongosLiveness(client)
110115
if err != nil {
111-
client.Disconnect(context.TODO()) // nolint:golint,errcheck
116+
client.Disconnect(ctx) // nolint:golint,errcheck
112117
log.Error(err, "Member failed Kubernetes liveness check")
113118
os.Exit(1)
114119
}
@@ -120,14 +125,14 @@ func main() {
120125
switch *component {
121126

122127
case "mongod":
123-
client.Disconnect(context.TODO()) // nolint:golint,errcheck
128+
client.Disconnect(ctx) // nolint:golint,errcheck
124129
log.Error(err, "readiness check for mongod is not implemented")
125130
os.Exit(1)
126131

127132
case "mongos":
128-
err := healthcheck.MongosReadinessCheck(client)
133+
err := healthcheck.MongosReadinessCheck(ctx, client)
129134
if err != nil {
130-
client.Disconnect(context.TODO()) // nolint:golint,errcheck
135+
client.Disconnect(ctx) // nolint:golint,errcheck
131136
log.Error(err, "Member failed Kubernetes readiness check")
132137
os.Exit(1)
133138
}

config/crd/bases/psmdb.percona.com_perconaservermongodbrestores.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ spec:
132132
type: string
133133
pbmName:
134134
type: string
135+
pitrTarget:
136+
type: string
135137
state:
136138
type: string
137139
type: object

0 commit comments

Comments
 (0)