Skip to content

Commit

Permalink
feat(CNPG-I): improve PhaseUnknownPlugin (cloudnative-pg#5274)
Browse files Browse the repository at this point in the history
Closes cloudnative-pg#5273  

Signed-off-by: Armando Ruocco <[email protected]>
  • Loading branch information
armru authored Aug 27, 2024
1 parent d63b653 commit 813cd63
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ const (

// PhaseUnknownPlugin is triggered when the required CNPG-i plugin have not been
// loaded still
PhaseUnknownPlugin = "Unknown plugin"
PhaseUnknownPlugin = "Cluster cannot proceed to reconciliation due to an unknown plugin being required"

// PhaseImageCatalogError is triggered when the cluster cannot select the image to
// apply because of an invalid or incomplete catalog
Expand Down
9 changes: 7 additions & 2 deletions internal/cnpi/plugin/repository/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func (r *data) setPluginProtocol(name string, protocol connection.Protocol) erro
}
}()

constructorLogger := log.FromContext(ctx).WithValues("pluginName", name)
constructorLogger := log.
FromContext(ctx).
WithName("setPluginProtocol").
WithValues("pluginName", name)
ctx = log.IntoContext(ctx, constructorLogger)

if handler, err = protocol.Dial(ctx); err != nil {
Expand All @@ -98,7 +101,9 @@ func (r *data) setPluginProtocol(name string, protocol connection.Protocol) erro
destructor := func(res connection.Interface) {
err := res.Close()
if err != nil {
destructorLogger := log.FromContext(context.Background()).WithValues("pluginName", res.Name())
destructorLogger := log.FromContext(context.Background()).
WithName("setPluginProtocol").
WithValues("pluginName", res.Name())
destructorLogger.Warning("Error while closing plugin connection", "err", err)
}
}
Expand Down
4 changes: 3 additions & 1 deletion internal/controller/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ func (r *ClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
ctx,
cluster,
apiv1.PhaseUnknownPlugin,
fmt.Sprintf("Unknown plugin %s", errUnknownPlugin.Name),
fmt.Sprintf("Unknown plugin: '%s'. "+
"This may be caused by the plugin not being loaded correctly by the operator. "+
"Check the operator and plugin logs for errors", errUnknownPlugin.Name),
)
}

Expand Down

0 comments on commit 813cd63

Please sign in to comment.