mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-09-06 06:52:21 +02:00
Compare commits
1 Commits
4815f14fa6
...
28726a0690
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28726a0690 |
@ -23,7 +23,7 @@ tasks:
|
|||||||
# renovate: datasource=git-refs depName=golangci-lint lookupName=https://github.com/sagikazarmark/daggerverse currentValue=main
|
# renovate: datasource=git-refs depName=golangci-lint lookupName=https://github.com/sagikazarmark/daggerverse currentValue=main
|
||||||
DAGGER_GOLANGCI_LINT_SHA: ff27cd50f6b4eed2e3753c520632cd6099e1ce52
|
DAGGER_GOLANGCI_LINT_SHA: ff27cd50f6b4eed2e3753c520632cd6099e1ce52
|
||||||
# renovate: datasource=docker depName=golangci/golangci-lint versioning=semver
|
# renovate: datasource=docker depName=golangci/golangci-lint versioning=semver
|
||||||
GOLANGCI_LINT_VERSION: v2.13.1
|
GOLANGCI_LINT_VERSION: v2.12.2
|
||||||
cmds:
|
cmds:
|
||||||
- >
|
- >
|
||||||
GITHUB_REF= dagger -sc "github.com/sagikazarmark/daggerverse/golangci-lint@${DAGGER_GOLANGCI_LINT_SHA}
|
GITHUB_REF= dagger -sc "github.com/sagikazarmark/daggerverse/golangci-lint@${DAGGER_GOLANGCI_LINT_SHA}
|
||||||
|
|||||||
12
go.mod
12
go.mod
@ -14,7 +14,7 @@ require (
|
|||||||
github.com/onsi/gomega v1.42.1
|
github.com/onsi/gomega v1.42.1
|
||||||
github.com/spf13/cobra v1.10.2
|
github.com/spf13/cobra v1.10.2
|
||||||
github.com/spf13/viper v1.21.0
|
github.com/spf13/viper v1.21.0
|
||||||
google.golang.org/grpc v1.83.2
|
google.golang.org/grpc v1.83.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
k8s.io/api v0.36.3
|
k8s.io/api v0.36.3
|
||||||
k8s.io/apiextensions-apiserver v0.36.3
|
k8s.io/apiextensions-apiserver v0.36.3
|
||||||
@ -109,15 +109,15 @@ require (
|
|||||||
go.yaml.in/yaml/v2 v2.4.4 // indirect
|
go.yaml.in/yaml/v2 v2.4.4 // indirect
|
||||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||||
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 // indirect
|
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 // indirect
|
||||||
golang.org/x/mod v0.38.0 // indirect
|
golang.org/x/mod v0.37.0 // indirect
|
||||||
golang.org/x/net v0.58.0 // indirect
|
golang.org/x/net v0.56.0 // indirect
|
||||||
golang.org/x/oauth2 v0.36.0 // indirect
|
golang.org/x/oauth2 v0.36.0 // indirect
|
||||||
golang.org/x/sync v0.22.0 // indirect
|
golang.org/x/sync v0.22.0 // indirect
|
||||||
golang.org/x/sys v0.47.0 // indirect
|
golang.org/x/sys v0.47.0 // indirect
|
||||||
golang.org/x/term v0.45.0 // indirect
|
golang.org/x/term v0.44.0 // indirect
|
||||||
golang.org/x/text v0.41.0 // indirect
|
golang.org/x/text v0.40.0 // indirect
|
||||||
golang.org/x/time v0.15.0 // indirect
|
golang.org/x/time v0.15.0 // indirect
|
||||||
golang.org/x/tools v0.48.0 // indirect
|
golang.org/x/tools v0.47.0 // indirect
|
||||||
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
|
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad // indirect
|
||||||
|
|||||||
24
go.sum
24
go.sum
@ -260,24 +260,24 @@ go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
|||||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0=
|
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0=
|
||||||
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=
|
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=
|
||||||
golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk=
|
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
|
||||||
golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
|
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
|
||||||
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
|
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
|
||||||
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
|
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
|
||||||
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
|
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
|
||||||
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
||||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||||
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
|
golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc=
|
||||||
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
|
golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y=
|
||||||
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
|
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||||
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
|
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||||
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
||||||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||||
golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE=
|
golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q=
|
||||||
golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
|
golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA=
|
||||||
gomodules.xyz/jsonpatch/v2 v2.5.0 h1:JELs8RLM12qJGXU4u/TO3V25KW8GreMKl9pdkk14RM0=
|
gomodules.xyz/jsonpatch/v2 v2.5.0 h1:JELs8RLM12qJGXU4u/TO3V25KW8GreMKl9pdkk14RM0=
|
||||||
gomodules.xyz/jsonpatch/v2 v2.5.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
|
gomodules.xyz/jsonpatch/v2 v2.5.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
|
||||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||||
@ -286,8 +286,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa h1:
|
|||||||
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:q4lMZS6kskjT5HvCPrnnypcDPVJqT/f4nfxmkE7gryY=
|
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:q4lMZS6kskjT5HvCPrnnypcDPVJqT/f4nfxmkE7gryY=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad h1:45WmJvIV6C2+O/jjLkPUH+F3aOj/1miDoU2DD0+NWbg=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad h1:45WmJvIV6C2+O/jjLkPUH+F3aOj/1miDoU2DD0+NWbg=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||||
google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU=
|
google.golang.org/grpc v1.83.1 h1:HIO0+BEtBP6soyqvqC8sNUjZ7bTs+0hFQuFF+RAy++Y=
|
||||||
google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8=
|
google.golang.org/grpc v1.83.1/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
||||||
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI=
|
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI=
|
||||||
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
@ -52,11 +52,6 @@ const (
|
|||||||
// BarmanEndpointCACertificateFileName is the name of the file in which the barman endpoint
|
// BarmanEndpointCACertificateFileName is the name of the file in which the barman endpoint
|
||||||
// CA certificate is stored.
|
// CA certificate is stored.
|
||||||
BarmanEndpointCACertificateFileName = "barman-ca.crt"
|
BarmanEndpointCACertificateFileName = "barman-ca.crt"
|
||||||
|
|
||||||
// PgWalVolumePgWalPath is the path of the pg_wal directory inside the WAL volume,
|
|
||||||
// used when a separate WAL storage is configured. During a restore the pg_wal
|
|
||||||
// directory is moved here and symlinked back into PGDATA.
|
|
||||||
PgWalVolumePgWalPath = "/var/lib/postgresql/wal/pg_wal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRestoreCABundleEnv gets the enveronment variables to be used when custom
|
// GetRestoreCABundleEnv gets the enveronment variables to be used when custom
|
||||||
|
|||||||
@ -70,13 +70,6 @@ func (i IdentityImplementation) GetPluginCapabilities(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Type: &identity.PluginCapability_Service_{
|
|
||||||
Service: &identity.PluginCapability_Service{
|
|
||||||
Type: identity.PluginCapability_Service_TYPE_RESTORE_JOB,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright © contributors to CloudNativePG, established as
|
|
||||||
CloudNativePG a Series of LF Projects, LLC.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package instance
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
|
||||||
. "github.com/onsi/gomega"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ = Describe("IdentityImplementation", func() {
|
|
||||||
Describe("GetPluginCapabilities", func() {
|
|
||||||
It("declares the WAL, backup, metrics and restore-job services", func(ctx SpecContext) {
|
|
||||||
impl := IdentityImplementation{}
|
|
||||||
response, err := impl.GetPluginCapabilities(ctx, &identity.GetPluginCapabilitiesRequest{})
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
Expect(response).NotTo(BeNil())
|
|
||||||
|
|
||||||
var serviceTypes []identity.PluginCapability_Service_Type
|
|
||||||
for _, capability := range response.GetCapabilities() {
|
|
||||||
serviceTypes = append(serviceTypes, capability.GetService().GetType())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Runs the phase-0 restore in-process now, hence TYPE_RESTORE_JOB below.
|
|
||||||
Expect(serviceTypes).To(ConsistOf(
|
|
||||||
identity.PluginCapability_Service_TYPE_WAL_SERVICE,
|
|
||||||
identity.PluginCapability_Service_TYPE_BACKUP_SERVICE,
|
|
||||||
identity.PluginCapability_Service_TYPE_METRICS,
|
|
||||||
identity.PluginCapability_Service_TYPE_RESTORE_JOB,
|
|
||||||
))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -25,13 +25,11 @@ import (
|
|||||||
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/metrics"
|
"github.com/cloudnative-pg/cnpg-i/pkg/metrics"
|
||||||
restore "github.com/cloudnative-pg/cnpg-i/pkg/restore/job"
|
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/wal"
|
"github.com/cloudnative-pg/cnpg-i/pkg/wal"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/common"
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/common"
|
||||||
barmanrestore "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/restore"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CNPGI is the implementation of the PostgreSQL sidecar
|
// CNPGI is the implementation of the PostgreSQL sidecar
|
||||||
@ -62,15 +60,6 @@ func (c *CNPGI) Start(ctx context.Context) error {
|
|||||||
metrics.RegisterMetricsServer(server, &metricsImpl{
|
metrics.RegisterMetricsServer(server, &metricsImpl{
|
||||||
Client: c.Client,
|
Client: c.Client,
|
||||||
})
|
})
|
||||||
// The instance pod runs the phase-0 bootstrap in-process (no separate
|
|
||||||
// recovery Job), so the same sidecar must answer the Restore RPC that
|
|
||||||
// initializes PGDATA from the object store before PostgreSQL starts.
|
|
||||||
restore.RegisterRestoreJobHooksServer(server, &barmanrestore.JobHookImpl{
|
|
||||||
Client: c.Client,
|
|
||||||
SpoolDirectory: c.SpoolDirectory,
|
|
||||||
PgDataPath: c.PGDataPath,
|
|
||||||
PgWalFolderToSymlink: common.PgWalVolumePgWalPath,
|
|
||||||
})
|
|
||||||
common.AddHealthCheck(server)
|
common.AddHealthCheck(server)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,13 +102,6 @@ func (config *PluginConfiguration) GetReplicaSourceBarmanObjectKey() types.Names
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasAnyBarmanObjectStore reports whether any barman object store is configured.
|
|
||||||
func (config *PluginConfiguration) HasAnyBarmanObjectStore() bool {
|
|
||||||
return len(config.BarmanObjectName) > 0 ||
|
|
||||||
len(config.RecoveryBarmanObjectName) > 0 ||
|
|
||||||
len(config.ReplicaSourceBarmanObjectName) > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetReferredBarmanObjectsKey gets the list of barman objects referred by this
|
// GetReferredBarmanObjectsKey gets the list of barman objects referred by this
|
||||||
// plugin configuration
|
// plugin configuration
|
||||||
func (config *PluginConfiguration) GetReferredBarmanObjectsKey() []types.NamespacedName {
|
func (config *PluginConfiguration) GetReferredBarmanObjectsKey() []types.NamespacedName {
|
||||||
@ -270,7 +263,9 @@ func getReplicaSourcePlugin(cluster *cnpgv1.Cluster) *cnpgv1.PluginConfiguration
|
|||||||
func (config *PluginConfiguration) Validate() error {
|
func (config *PluginConfiguration) Validate() error {
|
||||||
err := NewConfigurationError()
|
err := NewConfigurationError()
|
||||||
|
|
||||||
if !config.HasAnyBarmanObjectStore() {
|
if len(config.BarmanObjectName) == 0 &&
|
||||||
|
len(config.RecoveryBarmanObjectName) == 0 &&
|
||||||
|
len(config.ReplicaSourceBarmanObjectName) == 0 {
|
||||||
return err.WithMessage("no reference to barmanObjectName have been included")
|
return err.WithMessage("no reference to barmanObjectName have been included")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -322,42 +322,6 @@ func (impl LifecycleImplementation) collectAdditionalInstanceArgs(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// shouldInjectBarmanSidecar decides whether an instance pod needs the
|
|
||||||
// plugin-barman-cloud sidecar.
|
|
||||||
//
|
|
||||||
// Backup/archiving and replica-source configs need it for as long as the
|
|
||||||
// cluster exists, so those always inject it. A recovery-only cluster (only
|
|
||||||
// RecoveryBarmanObjectName set, mirroring pluginConfiguration.Validate())
|
|
||||||
// only needs it for the one-time bootstrap restore, so it's gated on
|
|
||||||
// cluster.Status.CurrentPrimary instead.
|
|
||||||
//
|
|
||||||
// CurrentPrimary is set by the instance manager itself, from inside the pod,
|
|
||||||
// only once bootstrap completes (see instance_startup.go in cloudnative-pg).
|
|
||||||
// cluster.Status.Instances / IsInitialized() looks equivalent but flips as
|
|
||||||
// soon as the instance's PVC exists, before the pod is even created - using
|
|
||||||
// it here would mean the sidecar never reaches the pod that needs it.
|
|
||||||
//
|
|
||||||
// Once CurrentPrimary is set, the operator's drift-check
|
|
||||||
// (checkPodSpecIsOutdated) sees the running pod's spec as outdated and rolls
|
|
||||||
// it out to drop the sidecar. Accepted deliberately: one deterministic
|
|
||||||
// rollout via the same machinery used for any other pod-spec change
|
|
||||||
// (switchover if a replica exists, in-place restart otherwise), not a new
|
|
||||||
// risk.
|
|
||||||
func shouldInjectBarmanSidecar(
|
|
||||||
cluster *cnpgv1.Cluster,
|
|
||||||
pluginConfiguration *config.PluginConfiguration,
|
|
||||||
) bool {
|
|
||||||
if len(pluginConfiguration.BarmanObjectName) != 0 || len(pluginConfiguration.ReplicaSourceBarmanObjectName) != 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(pluginConfiguration.RecoveryBarmanObjectName) == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return cluster.Status.CurrentPrimary == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func reconcileInstancePod(
|
func reconcileInstancePod(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
cluster *cnpgv1.Cluster,
|
cluster *cnpgv1.Cluster,
|
||||||
@ -375,7 +339,8 @@ func reconcileInstancePod(
|
|||||||
|
|
||||||
mutatedPod := pod.DeepCopy()
|
mutatedPod := pod.DeepCopy()
|
||||||
|
|
||||||
if shouldInjectBarmanSidecar(cluster, pluginConfiguration) {
|
if len(pluginConfiguration.BarmanObjectName) != 0 ||
|
||||||
|
len(pluginConfiguration.ReplicaSourceBarmanObjectName) != 0 {
|
||||||
if err := reconcilePodSpec(
|
if err := reconcilePodSpec(
|
||||||
cluster,
|
cluster,
|
||||||
&mutatedPod.Spec,
|
&mutatedPod.Spec,
|
||||||
@ -388,7 +353,7 @@ func reconcileInstancePod(
|
|||||||
return nil, fmt.Errorf("while reconciling pod spec for pod: %w", err)
|
return nil, fmt.Errorf("while reconciling pod spec for pod: %w", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contextLogger.Debug("No need to mutate instance, sidecar not required for this configuration and pod")
|
contextLogger.Debug("No need to mutate instance with no backup & archiving configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
patch, err := object.CreatePatch(mutatedPod, pod)
|
patch, err := object.CreatePatch(mutatedPod, pod)
|
||||||
|
|||||||
@ -242,69 +242,6 @@ var _ = Describe("LifecycleImplementation", func() {
|
|||||||
HaveKey("value")))
|
HaveKey("value")))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("injects the sidecar for a recovery-only cluster", func(ctx SpecContext) {
|
|
||||||
recoveryOnlyConfig := &config.PluginConfiguration{
|
|
||||||
RecoveryBarmanObjectName: "minio-store-recovery",
|
|
||||||
}
|
|
||||||
pod := &corev1.Pod{
|
|
||||||
TypeMeta: podTypeMeta,
|
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "test-pod"},
|
|
||||||
Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: "postgres"}}},
|
|
||||||
}
|
|
||||||
podJSON, _ := json.Marshal(pod)
|
|
||||||
request := &lifecycle.OperatorLifecycleRequest{
|
|
||||||
ObjectDefinition: podJSON,
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := reconcileInstancePod(ctx, cluster, request, recoveryOnlyConfig, sidecarConfiguration{})
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
Expect(response).NotTo(BeNil())
|
|
||||||
Expect(response.JsonPatch).NotTo(BeEmpty())
|
|
||||||
var patch []map[string]interface{}
|
|
||||||
Expect(json.Unmarshal(response.JsonPatch, &patch)).To(Succeed())
|
|
||||||
Expect(patch).To(ContainElement(HaveKeyWithValue("path", "/spec/initContainers")))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("does not inject the sidecar for a recovery-only cluster that has "+
|
|
||||||
"already completed its initial bootstrap", func(ctx SpecContext) {
|
|
||||||
recoveryOnlyConfig := &config.PluginConfiguration{
|
|
||||||
RecoveryBarmanObjectName: "minio-store-recovery",
|
|
||||||
}
|
|
||||||
cluster.Status.CurrentPrimary = "test-pod"
|
|
||||||
pod := &corev1.Pod{
|
|
||||||
TypeMeta: podTypeMeta,
|
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "test-pod"},
|
|
||||||
Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: "postgres"}}},
|
|
||||||
}
|
|
||||||
podJSON, _ := json.Marshal(pod)
|
|
||||||
request := &lifecycle.OperatorLifecycleRequest{
|
|
||||||
ObjectDefinition: podJSON,
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := reconcileInstancePod(ctx, cluster, request, recoveryOnlyConfig, sidecarConfiguration{})
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
Expect(response).NotTo(BeNil())
|
|
||||||
Expect(response.JsonPatch).To(BeEmpty())
|
|
||||||
})
|
|
||||||
|
|
||||||
It("does not mutate the pod when no object store is configured", func(ctx SpecContext) {
|
|
||||||
emptyConfig := &config.PluginConfiguration{}
|
|
||||||
pod := &corev1.Pod{
|
|
||||||
TypeMeta: podTypeMeta,
|
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "test-pod"},
|
|
||||||
Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: "postgres"}}},
|
|
||||||
}
|
|
||||||
podJSON, _ := json.Marshal(pod)
|
|
||||||
request := &lifecycle.OperatorLifecycleRequest{
|
|
||||||
ObjectDefinition: podJSON,
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := reconcileInstancePod(ctx, cluster, request, emptyConfig, sidecarConfiguration{})
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
Expect(response).NotTo(BeNil())
|
|
||||||
Expect(response.JsonPatch).To(BeEmpty())
|
|
||||||
})
|
|
||||||
|
|
||||||
It("returns an error for invalid pod definition", func(ctx SpecContext) {
|
It("returns an error for invalid pod definition", func(ctx SpecContext) {
|
||||||
request := &lifecycle.OperatorLifecycleRequest{
|
request := &lifecycle.OperatorLifecycleRequest{
|
||||||
ObjectDefinition: []byte("invalid-json"),
|
ObjectDefinition: []byte("invalid-json"),
|
||||||
|
|||||||
@ -44,6 +44,9 @@ type CNPGI struct {
|
|||||||
|
|
||||||
// Start starts the GRPC service
|
// Start starts the GRPC service
|
||||||
func (c *CNPGI) Start(ctx context.Context) error {
|
func (c *CNPGI) Start(ctx context.Context) error {
|
||||||
|
// PgWalVolumePgWalPath is the path of pg_wal directory inside the WAL volume when present
|
||||||
|
const PgWalVolumePgWalPath = "/var/lib/postgresql/wal/pg_wal"
|
||||||
|
|
||||||
enrich := func(server *grpc.Server) error {
|
enrich := func(server *grpc.Server) error {
|
||||||
wal.RegisterWALServer(server, common.WALServiceImplementation{
|
wal.RegisterWALServer(server, common.WALServiceImplementation{
|
||||||
InstanceName: c.InstanceName,
|
InstanceName: c.InstanceName,
|
||||||
@ -57,7 +60,7 @@ func (c *CNPGI) Start(ctx context.Context) error {
|
|||||||
Client: c.Client,
|
Client: c.Client,
|
||||||
SpoolDirectory: c.SpoolDirectory,
|
SpoolDirectory: c.SpoolDirectory,
|
||||||
PgDataPath: c.PGDataPath,
|
PgDataPath: c.PGDataPath,
|
||||||
PgWalFolderToSymlink: common.PgWalVolumePgWalPath,
|
PgWalFolderToSymlink: PgWalVolumePgWalPath,
|
||||||
})
|
})
|
||||||
|
|
||||||
common.AddHealthCheck(server)
|
common.AddHealthCheck(server)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user