Merge lp:~toykeeper/whoopsie/uploaded-url into lp:whoopsie

Proposed by Selene ToyKeeper
Status: Merged
Merged at revision: 699
Proposed branch: lp:~toykeeper/whoopsie/uploaded-url
Merge into: lp:whoopsie
Diff against target: 156 lines (+34/-7)
6 files modified
src/monitor.c (+2/-2)
src/tests/test_utils.c (+1/-1)
src/utils.c (+5/-1)
src/utils.h (+1/-1)
src/whoopsie.c (+24/-2)
src/whoopsie.h (+1/-0)
To merge this branch: bzr merge lp:~toykeeper/whoopsie/uploaded-url
Reviewer Review Type Date Requested Status
Brian Murray (community) Disapprove
Review via email: mp+294865@code.launchpad.net

Description of the change

Fix bug 1582470 (should put OOPS ID / URL in .uploaded file)

Intended to make it easier for both scripts and humans to map crash dump files to OOPS IDs and errors.ubuntu.com URLs, by storing that data in the .uploaded file created after a successful upload.

To test, force a crash, wait for whoopsie upload (or do a whoopsie-upload-all), then ensure the OOPS ID and URL are in the matching .uploaded file.

To post a comment you must log in.
Revision history for this message
Selene ToyKeeper (toykeeper) wrote :

Not actually ready yet; I still need to build it, test it, get feedback on how to properly implement it, then possibly rewrite it.

lp:~toykeeper/whoopsie/uploaded-url updated
681. By Selene ToyKeeper

oops, use fprintf() instead of write()

Revision history for this message
Brian Murray (brian-murray) wrote :

I've added a comment about hard coding errors.ubuntu.com.

Revision history for this message
Brian Murray (brian-murray) wrote :

There were quite a few issues with this branch as implemented but I went ahead and used it as a basis for adding this functionality to whoopsie so thanks!

review: Disapprove

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/monitor.c'
2--- src/monitor.c 2014-07-22 23:13:35 +0000
3+++ src/monitor.c 2016-05-17 03:09:42 +0000
4@@ -46,12 +46,12 @@
5 if (already_handled_report (crash_file)) {
6 /* Ensure that if we ended up here because of an error, that we do not
7 * attempt to process this report again. */
8- if (!mark_handled (crash_file))
9+ if (!mark_handled (crash_file, NULL))
10 log_msg ("Unable to mark report as seen (%s).\n", crash_file);
11
12 } else if (callback (crash_file)) {
13 /* We successfully uploaded the report */
14- if (!mark_handled (crash_file))
15+ if (!mark_handled (crash_file, last_uploaded_oopsid))
16 log_msg ("Unable to mark report as seen (%s).\n", crash_file);
17 }
18
19
20=== modified file 'src/tests/test_utils.c'
21--- src/tests/test_utils.c 2013-08-06 14:44:19 +0000
22+++ src/tests/test_utils.c 2016-05-17 03:09:42 +0000
23@@ -186,7 +186,7 @@
24 mktemp (template);
25 crash_file = g_strdup_printf ("%s.crash", template);
26 uploaded_file = g_strdup_printf ("%s.uploaded", template);
27- if (!mark_handled (crash_file)) {
28+ if (!mark_handled (crash_file), NULL) {
29 g_test_fail ();
30 goto out;
31 }
32
33=== modified file 'src/utils.c'
34--- src/utils.c 2013-08-06 14:44:19 +0000
35+++ src/utils.c 2016-05-17 03:09:42 +0000
36@@ -141,7 +141,7 @@
37 }
38
39 gboolean
40-mark_handled (const char* crash_file)
41+mark_handled (const char* crash_file, char * oops_id)
42 {
43 char* uploaded_file = NULL;
44 int fd;
45@@ -158,6 +158,10 @@
46 if (fd < 0)
47 return FALSE;
48 else {
49+ if (oops_id) {
50+ fprintf (fd, "OOPS ID: %s\n", oops_id);
51+ fprintf (fd, "URL: https://errors.ubuntu.com/oops/%s\n", oops_id);
52+ }
53 close (fd);
54 return TRUE;
55 }
56
57=== modified file 'src/utils.h'
58--- src/utils.h 2013-08-06 14:44:19 +0000
59+++ src/utils.h 2016-05-17 03:09:42 +0000
60@@ -26,7 +26,7 @@
61
62 char* change_file_extension (const char* path, const char* extension);
63 gboolean already_handled_report (const char* crash_file);
64-gboolean mark_handled (const char* crash_file);
65+gboolean mark_handled (const char* crash_file, char * oops_id);
66 void init_response_string (struct response_string* resp);
67 void grow_response_string (struct response_string* resp, char* str, size_t length);
68 void destroy_response_string (struct response_string* resp);
69
70=== modified file 'src/whoopsie.c'
71--- src/whoopsie.c 2016-03-17 20:25:35 +0000
72+++ src/whoopsie.c 2016-05-17 03:09:42 +0000
73@@ -73,6 +73,9 @@
74 /* The URL for sending the initial crash report */
75 static char* crash_db_submit_url = NULL;
76
77+/* OOPS ID of the last successfully-uploaded crash file */
78+char* last_uploaded_oopsid = NULL;
79+
80 /* The file path and descriptor for our instance lock */
81 static const char* lock_path = "/var/lock/whoopsie/lock";
82 static int lock_fd = 0;
83@@ -596,6 +599,7 @@
84 if (command) {
85 if (strcmp (command, "CORE") == 0) {
86 log_msg ("Reported OOPS ID %.36s\n", response_data);
87+ set_last_uploaded_oopsid(response_data);
88 core = g_hash_table_lookup (report, "CoreDump");
89 arch = g_hash_table_lookup (report, "Architecture");
90 if (core && arch) {
91@@ -606,10 +610,12 @@
92 log_msg ("Upload of the core dump failed.\n");
93 } else if (strcmp (command, "OOPSID") == 0) {
94 log_msg ("Reported OOPS ID %.36s\n", response_data);
95+ set_last_uploaded_oopsid(response_data);
96 } else
97 log_msg ("Asked for a core dump that we don't have.\n");
98 } else if (strcmp (command, "OOPSID") == 0) {
99 log_msg ("Reported OOPS ID %.36s\n", response_data);
100+ set_last_uploaded_oopsid(response_data);
101 } else
102 log_msg ("Got command: %s\n", command);
103 }
104@@ -668,8 +674,10 @@
105 log_msg ("%s\n", s.p);
106 }
107
108- if (response == 200 && s.length > 0)
109+ if (response == 200 && s.length > 0) {
110+ unset_last_uploaded_oopsid();
111 handle_response (report, s.p);
112+ }
113 destroy_response_string (&s);
114 }
115
116@@ -712,7 +720,7 @@
117 g_free (crash_file);
118 continue;
119 } else if (online_state && parse_and_upload_report (crash_file)) {
120- if (!mark_handled (crash_file))
121+ if (!mark_handled (crash_file, last_uploaded_oopsid))
122 log_msg ("Unable to mark report as seen (%s) removing it.\n", crash_file);
123 g_unlink (crash_file);
124 }
125@@ -725,6 +733,20 @@
126 return G_SOURCE_CONTINUE;
127 }
128
129+void set_last_uploaded_oopsid (char * response)
130+{
131+ unset_last_uploaded_oopsid();
132+ last_uploaded_oopsid = g_strdup_printf ("%.36s", response);
133+}
134+
135+void unset_last_uploaded_oopsid ()
136+{
137+ if (last_uploaded_oopsid) {
138+ g_free (last_uploaded_oopsid);
139+ last_uploaded_oopsid = NULL;
140+ }
141+}
142+
143 void daemonize (void)
144 {
145 pid_t pid, sid;
146
147=== modified file 'src/whoopsie.h'
148--- src/whoopsie.h 2013-08-06 14:44:19 +0000
149+++ src/whoopsie.h 2016-05-17 03:09:42 +0000
150@@ -25,5 +25,6 @@
151 void destroy_key_and_value (gpointer key, gpointer value, gpointer user_data);
152 void drop_privileges (GError** error);
153 gboolean process_existing_files (const char* report_dir);
154+char* last_uploaded_oopsid;
155
156 #endif /* WHOOPSIE_H */

Subscribers

People subscribed via source and target branches

to status/vote changes: