]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-conf: add boolean arg for verbosity when loading config
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 1 Aug 2024 18:25:38 +0000 (14:25 -0400)
committerMartin Schwenke <martins@samba.org>
Tue, 6 Aug 2024 00:43:36 +0000 (00:43 +0000)
In a future commit we will add support for loading the config file from
the `ctdb` command line tool. Prior to this change the config file load
func always called D_NOTICE that causes the command to emit new text and
thus break all the tests that rely on the specific test output (not to
mention something users could notice). This change plumbs a new
`verbose` argument into some of the config file loading functions.
Generally, all existing functions will have verbose set to true to match
the existing behavior. Future callers of this function can set it to
false in order to avoid emitting the extra text.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/conf/conf.c
ctdb/conf/conf.h
ctdb/conf/conf_tool.c
ctdb/conf/ctdb_config.c
ctdb/conf/ctdb_config.h
ctdb/event/event_config.c
ctdb/server/ctdbd.c
ctdb/tests/src/conf_test.c

index 67046c715e24fe692caed2c0785377762b89079f..2eb619765adeca998a296a204d5981c8e8b2a954 100644 (file)
@@ -1176,7 +1176,8 @@ done:
 
 int conf_load(struct conf_context *conf,
              const char *filename,
-             bool ignore_unknown)
+             bool ignore_unknown,
+             bool verbose)
 {
        conf->filename = talloc_strdup(conf, filename);
        if (conf->filename == NULL) {
@@ -1185,7 +1186,9 @@ int conf_load(struct conf_context *conf,
 
        conf->ignore_unknown = ignore_unknown;
 
-       D_NOTICE("Reading config file %s\n", filename);
+       if (verbose) {
+               D_NOTICE("Reading config file %s\n", filename);
+       }
 
        return conf_load_internal(conf);
 }
index 4dbf9c3372349694146045b8a15f0da1b932eaaa..29f36bd55e8ce4ff4f5dfbd4fef5d58b2c639abf 100644 (file)
@@ -306,7 +306,8 @@ void conf_set_defaults(struct conf_context *conf);
  */
 int conf_load(struct conf_context *conf,
              const char *filename,
-             bool ignore_unknown);
+             bool ignore_unknown,
+             bool verbose);
 
 /**
  * @brief Reload the values for configuration options
index 28f6c1090d007779af58f0a2a3d9461d597d5941..be4f06f57f64919266d95902487036a73588e77d 100644 (file)
@@ -57,7 +57,7 @@ static int conf_tool_dump(TALLOC_CTX *mem_ctx,
                return EINVAL;
        }
 
-       ret = conf_load(ctx->conf, ctx->conf_file, true);
+       ret = conf_load(ctx->conf, ctx->conf_file, true, true);
        if (ret != 0 && ret != ENOENT) {
                D_ERR("Failed to load config file %s\n", ctx->conf_file);
                return ret;
@@ -97,7 +97,7 @@ static int conf_tool_get(TALLOC_CTX *mem_ctx,
                return ENOENT;
        }
 
-       ret = conf_load(ctx->conf, ctx->conf_file, true);
+       ret = conf_load(ctx->conf, ctx->conf_file, true, true);
        if (ret != 0 && ret != ENOENT) {
                D_ERR("Failed to load config file %s\n", ctx->conf_file);
                return ret;
@@ -169,7 +169,7 @@ static int conf_tool_validate(TALLOC_CTX *mem_ctx,
                return EINVAL;
        }
 
-       ret = conf_load(ctx->conf, ctx->conf_file, false);
+       ret = conf_load(ctx->conf, ctx->conf_file, false, true);
        if (ret != 0) {
                D_ERR("Failed to load config file %s\n", ctx->conf_file);
                return ret;
index f1f9ec020f0d03ec03854cac82f2b459bd544970..f75bf374a8083a6bf2abc947a831406f0f1773fc 100644 (file)
@@ -138,7 +138,8 @@ static void setup_config_pointers(struct conf_context *conf)
 }
 
 int ctdb_config_load(TALLOC_CTX *mem_ctx,
-                    struct conf_context **result)
+                    struct conf_context **result,
+                    bool verbose)
 {
        struct conf_context *conf = NULL;
        int ret = 0;
@@ -169,7 +170,7 @@ int ctdb_config_load(TALLOC_CTX *mem_ctx,
                ret = ENOMEM;
                goto fail;
        }
-       ret = conf_load(conf, conf_file, true);
+       ret = conf_load(conf, conf_file, true, verbose);
        /* Configuration file does not need to exist */
        if (ret != 0 && ret != ENOENT) {
                D_ERR("Failed to load configuration file %s\n", conf_file);
index 2cf6a16f1cb91cdf76f98a9a6334c55d6f86cebd..575e3045fa4853a1948dcdc0fbf9926c888c210c 100644 (file)
@@ -55,6 +55,7 @@ struct ctdb_config {
 
 extern struct ctdb_config ctdb_config;
 
-int ctdb_config_load(TALLOC_CTX *mem_ctx, struct conf_context **conf);
+int ctdb_config_load(TALLOC_CTX *mem_ctx, struct conf_context **conf,
+                    bool verbose);
 
 #endif /* __CTDB_CONFIG_H__ */
index 8617ebaad30dc2b7de5d79d21de8602e5ce964b8..616b5284d52231fac34f93af996a8f9689455767 100644 (file)
@@ -85,7 +85,7 @@ int event_config_init(TALLOC_CTX *mem_ctx, struct event_config **result)
                return EINVAL;
        }
 
-       ret = conf_load(config->conf, config->config_file, true);
+       ret = conf_load(config->conf, config->config_file, true, true);
        if (ret != 0 && ret != ENOENT) {
                talloc_free(config);
                return ret;
index 73c4372f70d207604219677521c5649aee824b83..524c51b91e5f58f55ad186acb2bf843ecbd7a9d8 100644 (file)
@@ -233,7 +233,7 @@ int main(int argc, const char *argv[])
         * Configuration file handling
         */
 
-       ret = ctdb_config_load(ctdb, &conf);
+       ret = ctdb_config_load(ctdb, &conf, true);
        if (ret != 0) {
                /* ctdb_config_load() logs the failure */
                goto fail;
index a38a51bf37e28a32142862533993e714d4b30165..3ca0c1482c4375744ef52c043d6bd8f18f5ddb36 100644 (file)
@@ -373,7 +373,7 @@ static void test8(const char *filename)
        status = conf_valid(conf);
        assert(status == true);
 
-       ret = conf_load(conf, filename, true);
+       ret = conf_load(conf, filename, true, true);
        conf_dump(conf, stdout);
 
        talloc_free(mem_ctx);
@@ -402,7 +402,7 @@ static void test9(const char *filename, bool ignore_unknown)
 
        conf_set_boolean(conf, "section1", "key3", false);
 
-       ret = conf_load(conf, filename, ignore_unknown);
+       ret = conf_load(conf, filename, ignore_unknown, true);
        conf_dump(conf, stdout);
 
        talloc_free(mem_ctx);
@@ -433,7 +433,7 @@ static void test11(const char *filename)
        status = conf_valid(conf);
        assert(status == true);
 
-       ret = conf_load(conf, filename, false);
+       ret = conf_load(conf, filename, false, true);
        assert(ret == 0);
 
        ret = rename(reload, filename);