Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable rpmdb monitoring in build/composes #4029

Open
cgwalters opened this issue Sep 19, 2022 · 7 comments
Open

disable rpmdb monitoring in build/composes #4029

cgwalters opened this issue Sep 19, 2022 · 7 comments

Comments

@cgwalters
Copy link
Member

Seen in okd-project/okd-coreos-pipeline#12

(rpm-ostree compose extensions:1): libdnf-WARNING **: 14:13:47.883: failed to setup monitor: Operation not supported

It looks like inotify is being denied in this environment for some reason. But in any case, we shouldn't be trying to monitor the rpmdb for changes when we're doing a build.

@LorbusChris
Copy link
Collaborator

copied from okd-project/okd-coreos-pipeline#12 (comment):

@cgwalters hm, is this not the monitor looking for *.repo files in the compose dir? How else would rpm-ostree know about the yum repos? As the logs show, the c9s.repo is present and defines the baseos repo. If the failed monitor is not the reason, why is it not picked up and what can we do to fix this?

@travier
Copy link
Member

travier commented Jan 24, 2023

Looks fatal from an strace trace:

(rpm-ostree compose extensions:4): libdnf-WARNING **: 14:38:27.859: failed to setup monitor: Operation not supported
[{events=EPOLLIN, data={u32=2147483648, u64=2147483648}}], 1024, -1) = 1
close(3)                                = 0
close(5)                                = 0
close(4)                                = 0
close(8)                                = 0
futex(0x562afeaea5a0, FUTEX_WAKE_PRIVATE, 2147483647) = 1
futex(0x562afeaea4b0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f078ba2b910, FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 5, NULL, FUTEX_BITSET_MATCH_ANY) = 0
write(2, "error: Unknown rpm-md repository"..., 41error: Unknown rpm-md repository: baseos

@cgwalters
Copy link
Member Author

Ahh OK pretty sure the problem is this
https://github.com/rpm-software-management/libdnf/blob/943e3ac8d9044f126d810a04d49a4d0d3eacdc00/libdnf/dnf-context.cpp#L2273

If inotify fails then the libdnf code doesn't set an error and silently doesn't load the .repo files etc. (This code violates the gerror rules by returning FALSE but not setting an error)

In latest libdnf, this code also changed: rpm-software-management/libdnf#915

cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Jan 24, 2023
@cgwalters
Copy link
Member Author

If inotify fails then the libdnf code doesn't set an error

Hmm wait I may be wrong about that...not totally sure

@cgwalters
Copy link
Member Author

diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp
index ad467aab..b7c74e46 100644
--- a/libdnf/dnf-context.cpp
+++ b/libdnf/dnf-context.cpp
@@ -2272,8 +2272,11 @@ dnf_context_setup(DnfContext *context,
                                G_FILE_MONITOR_NONE,
                                NULL,
                                error);
-        if (priv->monitor_rpmdb == NULL)
+        if (priv->monitor_rpmdb == NULL) {
+            g_printerr ("Failed to monitor rpmdb\n");
             return FALSE;
+        }
+        g_printerr ("monitoring rpmdb\n");
         g_signal_connect(priv->monitor_rpmdb, "changed",
                          G_CALLBACK(dnf_context_rpmdb_changed_cb), context);
     }
@@ -2290,9 +2293,11 @@ dnf_context_setup(DnfContext *context,
 
     /* initialize repos */
     priv->repo_loader = dnf_repo_loader_new(context);
+    g_printerr ("Got repo loader\n");
     priv->repos = dnf_repo_loader_get_repos(priv->repo_loader, error);
     if (priv->repos == NULL)
         return FALSE;
+    g_printerr ("Got repos\n");
 
     if (!dnf_context_plugin_hook(context, PLUGIN_HOOK_ID_CONTEXT_CONF, nullptr, nullptr))
         return FALSE;
diff --git a/libdnf/dnf-repo-loader.cpp b/libdnf/dnf-repo-loader.cpp
index c6d4faaa..2e92a029 100644
--- a/libdnf/dnf-repo-loader.cpp
+++ b/libdnf/dnf-repo-loader.cpp
@@ -408,6 +408,7 @@ dnf_repo_loader_refresh(DnfRepoLoader *self, GError **error)
     if (!dnf_context_setup_enrollments(priv->context, error))
         return FALSE;
 
+
     /* load repos defined in main configuration */
     auto cfg_file_path = dnf_context_get_config_file_path();
     if (cfg_file_path[0] != '\0' &&
@@ -421,16 +422,20 @@ dnf_repo_loader_refresh(DnfRepoLoader *self, GError **error)
     auto repos_dir = dnf_context_get_repos_dir(priv->context);
     for (auto item = repos_dir; *item; ++item) {
         auto repo_path = *item;
+        g_printerr ("looking for yum repos in '%s'\n", repo_path);
         g_autoptr(GDir) dir = g_dir_open(repo_path, 0, NULL);
         // existence of repos directories is not mandatory
-        if (dir == NULL)
+        if (dir == NULL) {
+            g_printerr ("failed to open dir\n");
             continue;
+        }
         
         /* find all the .repo files */
         while (auto file = g_dir_read_name(dir)) {
             g_autofree gchar *path_tmp = NULL;
             if (!g_str_has_suffix(file, ".repo"))
                 continue;
+            g_printerr ("inspecting %s\n", file);
             path_tmp = g_build_filename(repo_path, file, NULL);
             if (!dnf_repo_loader_repo_parse(self, path_tmp, error))
                 return FALSE;

@cgwalters
Copy link
Member Author

[root@ab613414cbef srv]# /run/hostsrv/src/github/coreos/rpm-ostree.c9/rpm-ostree compose extensions --rootfs=/ --output-dir=/tmp/extensions manifest-c9s.yaml  extensions-c9s.yaml
monitoring rpmdb

(/run/hostsrv/src/github/coreos/rpm-ostree.c9/rpm-ostree compose extensions:6284): libdnf-WARNING **: 16:11:14.159: failed to setup monitor: Operation not supported
Got repo loader
looking for yum repos in ''
failed to open dir
Got repos
error: Unknown rpm-md repository: baseos (discovered 0)

cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Jan 24, 2023
This addresses the root cause of
coreos#4029

Basically we were calling `set_repos_dir("")` on the libdnf side
and it simply did not handle that, failing to open the directory.

(Though I'm not saying "Closes" since we should still fix the
 file monitoring stuff)

I don't yet know why this seemed to work in some cases but not
others though.
cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Jan 24, 2023
This addresses the root cause of
coreos#4029

Basically we were calling `set_repos_dir("")` on the libdnf side
and it simply did not handle that, failing to open the directory.

(Though I'm not saying "Closes" since we should still fix the
 file monitoring stuff)

I don't yet know why this seemed to work in some cases but not
others though.
@cgwalters
Copy link
Member Author

#4278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants