From a078e1a848d67e12c10085741dfe8a7146948ef6 Mon Sep 17 00:00:00 2001 From: Aymeric Ducroquetz Date: Wed, 1 Jun 2022 14:29:53 +0200 Subject: [PATCH] meta2: Put the complete URL in container update event Some tools, like oio-replicator, need the complete URL to work properly. --- meta2v2/meta2_backend.c | 17 +++++++++-------- meta2v2/meta2_backend.h | 5 ++--- sqliterepo/replication_dispatcher.c | 14 +++----------- sqliterepo/repository.c | 15 +++++++-------- sqliterepo/sqliterepo.h | 8 +++----- 5 files changed, 24 insertions(+), 35 deletions(-) diff --git a/meta2v2/meta2_backend.c b/meta2v2/meta2_backend.c index e0e3534a03..e4b69f4384 100644 --- a/meta2v2/meta2_backend.c +++ b/meta2v2/meta2_backend.c @@ -2,7 +2,7 @@ OpenIO SDS meta2v2 Copyright (C) 2014 Worldline, as part of Redcurrant Copyright (C) 2015-2019 OpenIO SAS, as part of OpenIO SDS -Copyright (C) 2021 OVH SAS +Copyright (C) 2021-2022 OVH SAS This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -336,7 +336,7 @@ _is_container_initiated(struct sqlx_sqlite3_s *sq3) /* workaround for a known bug, when the container has no flag because * of some failed replication (yet to be determined) but it is used - * because of a (now-fixed) inexistant check on the flag. */ + * because of a (now-fixed) inexistent check on the flag. */ if (sqlx_admin_has(sq3, M2V2_ADMIN_OBJ_COUNT) || sqlx_admin_has(sq3, M2V2_ADMIN_SIZE)) { GRID_DEBUG("DB partially initiated: [%s][%.s]", @@ -366,9 +366,10 @@ _container_state (struct sqlx_sqlite3_s *sq3) g_free(v); } - struct oio_url_s *u = sqlx_admin_get_url (sq3); + struct oio_url_s *url = sqlx_admin_get_url(sq3); GString *gs = oio_event__create_with_id( - META2_EVENTS_PREFIX ".container.state", u, oio_ext_get_reqid()); + META2_EVENTS_PREFIX ".container.state", url, oio_ext_get_reqid()); + oio_url_clean(url); g_string_append_static (gs, ",\"data\":{"); append_str(gs, "bucket", sqlx_admin_get_str(sq3, M2V2_ADMIN_BUCKET_NAME)); append_str(gs, "policy", sqlx_admin_get_str(sq3, M2V2_ADMIN_STORAGE_POLICY)); @@ -379,7 +380,6 @@ _container_state (struct sqlx_sqlite3_s *sq3) append_int64(gs, "missing-chunks", m2db_get_missing_chunks(sq3)); g_string_append_static (gs, "}}"); - oio_url_clean (u); return g_string_free(gs, FALSE); } @@ -1880,14 +1880,15 @@ meta2_backend_change_callback(struct sqlx_sqlite3_s *sq3, } void -meta2_backend_db_properties_change_callback(struct sqlx_sqlite3_s *sq3 UNUSED, - struct meta2_backend_s *m2b, struct oio_url_s *url, - struct db_properties_s *db_properties) +meta2_backend_db_properties_change_callback(struct sqlx_sqlite3_s *sq3, + struct meta2_backend_s *m2b, struct db_properties_s *db_properties) { if (m2b->notifier_container_updated) { + struct oio_url_s *url = sqlx_admin_get_url(sq3); GString *event = oio_event__create_with_id( META2_EVENTS_PREFIX ".container.update", url, oio_ext_get_reqid()); + oio_url_clean(url); g_string_append_static(event, ",\"data\":{"); db_properties_to_json(db_properties, event); gchar *bucket = sqlx_admin_get_str(sq3, M2V2_ADMIN_BUCKET_NAME); diff --git a/meta2v2/meta2_backend.h b/meta2v2/meta2_backend.h index 1fb4b8fc0c..5ddc47a452 100644 --- a/meta2v2/meta2_backend.h +++ b/meta2v2/meta2_backend.h @@ -2,7 +2,7 @@ OpenIO SDS meta2v2 Copyright (C) 2014 Worldline, as part of Redcurrant Copyright (C) 2015-2019 OpenIO SAS, as part of OpenIO SDS -Copyright (C) 2021 OVH SAS +Copyright (C) 2021-2022 OVH SAS This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -67,8 +67,7 @@ void meta2_backend_change_callback(struct sqlx_sqlite3_s *sq3, struct meta2_backend_s *m2b); void meta2_backend_db_properties_change_callback(struct sqlx_sqlite3_s *sq3, - struct meta2_backend_s *m2b, struct oio_url_s *url, - struct db_properties_s *db_properties); + struct meta2_backend_s *m2b, struct db_properties_s *db_properties); /* -------------------------------------------------------------------------- */ diff --git a/sqliterepo/replication_dispatcher.c b/sqliterepo/replication_dispatcher.c index c9f4ae8e30..f3b9592f50 100644 --- a/sqliterepo/replication_dispatcher.c +++ b/sqliterepo/replication_dispatcher.c @@ -2,7 +2,7 @@ OpenIO SDS sqliterepo Copyright (C) 2014 Worldline, as part of Redcurrant Copyright (C) 2015-2019 OpenIO SAS, as part of OpenIO SDS -Copyright (C) 2021 OVH SAS +Copyright (C) 2021-2022 OVH SAS This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -2188,11 +2188,7 @@ _handler_PROPDEL(struct gridd_reply_ctx_s *reply, } if (!err && db_properties) { - struct oio_url_s *url = metautils_message_extract_url( - reply->request); - sqlx_repository_call_db_properties_change_callback( - sq3, url, db_properties); - oio_url_clean(url); + sqlx_repository_call_db_properties_change_callback(sq3, db_properties); } sqlx_repository_unlock_and_close_noerror(sq3); @@ -2342,11 +2338,7 @@ _handler_PROPSET(struct gridd_reply_ctx_s *reply, } if (!err && db_properties) { - struct oio_url_s *url = metautils_message_extract_url( - reply->request); - sqlx_repository_call_db_properties_change_callback( - sq3, url, db_properties); - oio_url_clean(url); + sqlx_repository_call_db_properties_change_callback(sq3, db_properties); } sqlx_repository_unlock_and_close_noerror(sq3); diff --git a/sqliterepo/repository.c b/sqliterepo/repository.c index ffd0b9493c..72d3504dce 100644 --- a/sqliterepo/repository.c +++ b/sqliterepo/repository.c @@ -2,7 +2,7 @@ OpenIO SDS sqliterepo Copyright (C) 2014 Worldline, as part of Redcurrant Copyright (C) 2015-2020 OpenIO SAS, as part of OpenIO SDS -Copyright (C) 2021 OVH SAS +Copyright (C) 2021-2022 OVH SAS This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -303,7 +303,7 @@ sqlx_repository_init(const gchar *vol, const struct sqlx_repo_config_s *cfg, if (cfg->flags & SQLX_REPO_NOCACHE) { /* if there are several connections on the same base, we will use a - shared cache that wil prevent us of too many I/O operations. */ + shared cache that will prevent too many I/O operations. */ if (SQLITE_OK != sqlite3_enable_shared_cache(1)) GRID_NOTICE("SQLite3 not in SHAREDCACHE mode"); } @@ -564,15 +564,14 @@ sqlx_repository_configure_db_properties_change_callback( void sqlx_repository_call_db_properties_change_callback( - struct sqlx_sqlite3_s *sq3, struct oio_url_s *url, - struct db_properties_s *db_properties) + struct sqlx_sqlite3_s *sq3, struct db_properties_s *db_properties) { if (!sq3 || !sq3->repo || !sq3->repo->running || !sq3->repo->db_properties_change_callback) return; return sq3->repo->db_properties_change_callback(sq3, sq3->repo->db_properties_change_callback_data, - url, db_properties); + db_properties); } void @@ -1194,7 +1193,7 @@ sqlx_repository_timed_open_and_lock(sqlx_repository_t *repo, } if (!err) { - /* XXX(jfs): patching the db handle so it has the lastest election_manager + /* XXX(jfs): patching the db handle so it has the latest election_manager allows reusing a handle from the cache, and that was initiated during the _post_config hook (when the election_manager was not associated yet to the repository. */ @@ -1204,7 +1203,7 @@ sqlx_repository_timed_open_and_lock(sqlx_repository_t *repo, // This MIGHT happen if a cache is present (and this is the // common case for m2v2), because the deletion will happen // when the base exit the cache. - // In facts this SHOULD NOT happend because a base being deleted + // In facts this SHOULD NOT happen because a base being deleted // is closed with an instruction to exit the cache immediately. // TODO FIXME this is maybe a good place for an assert(). if ((*result)->deleted) @@ -1431,7 +1430,7 @@ sqlx_repository_use_base(sqlx_repository_t *repo, const struct sqlx_name_s *n, if (!(err = election_init(repo->election_manager, n, peers, &status, replicated))) { - /* Interleave a DB creation (out of the lock) if explicitely + /* Interleave a DB creation (out of the lock) if explicitly * allowed by both the request type AND the application */ if (allow_autocreate && sqliterepo_election_lazy_recover) { err = _base_lazy_recover(repo, n, status); diff --git a/sqliterepo/sqliterepo.h b/sqliterepo/sqliterepo.h index caba10ab4e..fca948d127 100644 --- a/sqliterepo/sqliterepo.h +++ b/sqliterepo/sqliterepo.h @@ -2,7 +2,7 @@ OpenIO SDS sqliterepo Copyright (C) 2014 Worldline, as part of Redcurrant Copyright (C) 2015-2019 OpenIO SAS, as part of OpenIO SDS -Copyright (C) 2021 OVH SAS +Copyright (C) 2021-2022 OVH SAS This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -50,8 +50,7 @@ typedef void (*sqlx_repo_change_hook)(struct sqlx_sqlite3_s *sq3, gpointer cb_data); typedef void (*sqlx_repo_db_properties_change_hook)(struct sqlx_sqlite3_s *sq3, - gpointer cb_data, struct oio_url_s *url, - struct db_properties_s *db_properties); + gpointer cb_data, struct db_properties_s *db_properties); typedef void (*sqlx_file_locator_f) (gpointer locator_data, const struct sqlx_name_s *n, GString *file_name); @@ -225,8 +224,7 @@ void sqlx_repository_configure_db_properties_change_callback( sqlx_repo_db_properties_change_hook cb, gpointer cb_data); void sqlx_repository_call_db_properties_change_callback( - struct sqlx_sqlite3_s *sq3, struct oio_url_s *url, - struct db_properties_s *db_properties); + struct sqlx_sqlite3_s *sq3, struct db_properties_s *db_properties); /* Bases operations -------------------------------------------------------- */