feat: add instance cnpgi probe

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
This commit is contained in:
Armando Ruocco 2024-09-26 12:22:42 +02:00
parent 1bd96b0126
commit 276ec942a2
2 changed files with 14 additions and 1 deletions

View File

@ -2,12 +2,17 @@ package instance
import (
"context"
"fmt"
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/cloudnative-pg/cnpg-i/pkg/identity"
)
type IdentityImplementation struct {
identity.UnimplementedIdentityServer
BarmanObjectKey client.ObjectKey
Client client.Client
}
func (i IdentityImplementation) GetPluginMetadata(
@ -45,6 +50,11 @@ func (i IdentityImplementation) Probe(
ctx context.Context,
request *identity.ProbeRequest,
) (*identity.ProbeResponse, error) {
var obj barmancloudv1.ObjectStore
if err := i.Client.Get(ctx, i.BarmanObjectKey, &obj); err != nil {
return nil, fmt.Errorf("while fetching object store %s: %w", i.BarmanObjectKey.Name, err)
}
return &identity.ProbeResponse{
Ready: true,
}, nil

View File

@ -38,7 +38,10 @@ func (c *CNPGI) Start(ctx context.Context) error {
}
srv := http.Server{
IdentityImpl: IdentityImplementation{},
IdentityImpl: IdentityImplementation{
Client: c.Client,
BarmanObjectKey: c.BarmanObjectKey,
},
Enrichers: []http.ServerEnricher{enrich},
ServerCertPath: c.ServerCertPath,
ServerKeyPath: c.ServerKeyPath,