From 79d424fa05a96b35228331e7a156774fd4a2dfb2 Mon Sep 17 00:00:00 2001 From: Jeff Martin Date: Thu, 10 Feb 2022 13:37:21 -0700 Subject: [PATCH] Operator logging for database init SQL failures If there is an error in the init SQL that runs as part of reconcileDatabaseInitSQL, then there is no way for the user to know what the error is. Adding this additional log statement will make it easier for users to know when init sql operations have succeeded and/or failed. It also brings this part of the code up to par with other similar operations in the codebase. Issue: #3029 --- internal/controller/postgrescluster/postgres.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/controller/postgrescluster/postgres.go b/internal/controller/postgrescluster/postgres.go index 1afe40df8d..f3c9d04563 100644 --- a/internal/controller/postgrescluster/postgres.go +++ b/internal/controller/postgrescluster/postgres.go @@ -739,7 +739,8 @@ func (r *Reconciler) reconcileDatabaseInitSQL(ctx context.Context, // A writable pod executor has been found and we have the sql provided by // the user. Setup a write function to execute the sql using the podExecutor write := func(ctx context.Context, exec postgres.Executor) error { - _, _, err := exec.Exec(ctx, strings.NewReader(data), map[string]string{}) + stdout, stderr, err := exec.Exec(ctx, strings.NewReader(data), map[string]string{}) + log.V(1).Info("applied init SQL", "stdout", stdout, "stderr", stderr) return err }