Dimitri John Ledkov has proposed merging lp:~xnox/upstart/lp1303891 into
lp:upstart.
Commit message:
Reintroduce previous reload semantics that simply sent SIGHUP to the main
process, thus allowing to reload services during precise -> trusty upgrades.
Requested reviews:
Upstart Reviewers (upstart-reviewers)
Related bugs:
Bug #1303891 in upstart : "new initctl should fallback to old reload signal
semantics, if pid1 doesn't export reload dbus method"
https://bugs.launchpad.net/upstart/+bug/1303891
For more details, see:
https://code.launchpad.net/~xnox/upstart/lp1303891/+merge/214908
Reintroduce previous reload semantics that simply sent SIGHUP to the main
process, thus allowing to reload services during precise -> trusty upgrades.
--
https://code.launchpad.net/~xnox/upstart/lp1303891/+merge/214908
Your team Upstart Reviewers is requested to review the proposed merge of
lp:~xnox/upstart/lp1303891 into lp:upstart.
=== modified file 'util/initctl.c'
--- util/initctl.c 2013-10-25 13:49:49 +0000
+++ util/initctl.c 2014-04-09 09:24:08 +0000
@@ -1033,9 +1033,25 @@
job->auto_start = FALSE;
- if (job_reload_sync (NULL, job) < 0)
- goto error;
-
+ if (job_get_processes_sync (NULL, job, &processes) < 0)
+ goto error;
+
+ if ((! processes[0]) || strcmp (processes[0]->item0, "main")) {
+ nih_error (_("Not running"));
+ return 1;
+ }
+
+ if (job_reload_sync (NULL, job) < 0) {
+ /* well reload_sync call should always work... unless we
+ * didn't reboot since upgrade and pid1 is still old
+ * upstart that does not have reload_sync call, fallback
+ * to sending SIGHUP to main process
+ */
+ if (kill (processes[0]->item1, SIGHUP) < 0) {
+ nih_error_raise_system ();
+ goto error;
+ }
+ }
return 0;
error:
=== modified file 'util/tests/test_initctl.c'
--- util/tests/test_initctl.c 2014-03-06 15:21:54 +0000
+++ util/tests/test_initctl.c 2014-04-09 09:24:08 +0000
@@ -8462,12 +8462,20 @@
FILE * output;
FILE * errors;
pid_t server_pid;
+ pid_t proc_pid;
DBusMessage * method_call;
DBusMessage * reply = NULL;
const char * name_value;
char ** args_value;
int args_elements;
const char * str_value;
+ const char * interface;
+ const char * property;
+ DBusMessageIter iter;
+ DBusMessageIter subiter;
+ DBusMessageIter arrayiter;
+ DBusMessageIter structiter;
+ int32_t int32_value;
NihCommand command;
char * args[4];
int ret = 0;
@@ -8501,6 +8509,10 @@
*/
TEST_FEATURE ("with single argument");
TEST_ALLOC_FAIL {
+ TEST_CHILD (proc_pid) {
+ pause ();
+ }
+
TEST_CHILD (server_pid) {
/* Expect the GetJobByName method call on the
* manager object, make sure the job name is passed
@@ -8573,6 +8585,67 @@
dbus_message_unref (method_call);
dbus_message_unref (reply);
+ /* Expect the Get call for the processes, reply with
+ * a main process pid.
+ */
+ TEST_DBUS_MESSAGE (server_conn, method_call);
+
+ TEST_TRUE (dbus_message_is_method_call (method_call,
+ DBUS_INTERFACE_PROPERTIES,
+ "Get"));
+ TEST_EQ_STR (dbus_message_get_path (method_call),
+ DBUS_PATH_UPSTART "/jobs/test/_");
+
+ TEST_TRUE (dbus_message_get_args (method_call, NULL,
+ DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &property,
+ DBUS_TYPE_INVALID));
+
+ TEST_ALLOC_SAFE {
+ reply = dbus_message_new_method_return (method_call);
+
+ dbus_message_iter_init_append (reply, &iter);
+
+ dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT,
+ (DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_INT32_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING),
+ &subiter);
+
+ dbus_message_iter_open_container (&subiter, DBUS_TYPE_ARRAY,
+ (DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_INT32_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING),
+ &arrayiter);
+
+ dbus_message_iter_open_container (&arrayiter, DBUS_TYPE_STRUCT,
+ NULL,
+ &structiter);
+
+ str_value = "main";
+ dbus_message_iter_append_basic (&structiter, DBUS_TYPE_STRING,
+ &str_value);
+
+ int32_value = proc_pid;
+ dbus_message_iter_append_basic (&structiter, DBUS_TYPE_INT32,
+ &int32_value);
+
+ dbus_message_iter_close_container (&arrayiter, &structiter);
+
+ dbus_message_iter_close_container (&subiter, &arrayiter);
+
+ dbus_message_iter_close_container (&iter, &subiter);
+ }
+
+ dbus_connection_send (server_conn, reply, NULL);
+ dbus_connection_flush (server_conn);
+
+ dbus_message_unref (method_call);
+ dbus_message_unref (reply);
+
/* Expect the Reload call against job instance
* and reply with an instance path to
* acknowledge.
@@ -8630,6 +8703,9 @@
kill (server_pid, SIGTERM);
waitpid (server_pid, NULL, 0);
+
+ kill (proc_pid, SIGTERM);
+ waitpid (proc_pid, NULL, 0);
continue;
}
@@ -8652,6 +8728,10 @@
*/
TEST_FEATURE ("with multiple arguments");
TEST_ALLOC_FAIL {
+ TEST_CHILD (proc_pid) {
+ pause ();
+ }
+
TEST_CHILD (server_pid) {
/* Expect the GetJobByName method call on the
* manager object, make sure the job name is passed
@@ -8726,6 +8806,68 @@
dbus_message_unref (method_call);
dbus_message_unref (reply);
+ /* Expect the Get call for the processes, reply with
+ * a main process pid.
+ */
+ TEST_DBUS_MESSAGE (server_conn, method_call);
+
+ TEST_TRUE (dbus_message_is_method_call (method_call,
+ DBUS_INTERFACE_PROPERTIES,
+ "Get"));
+ TEST_EQ_STR (dbus_message_get_path (method_call),
+ DBUS_PATH_UPSTART "/jobs/test/_");
+
+ TEST_TRUE (dbus_message_get_args (method_call, NULL,
+ DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &property,
+ DBUS_TYPE_INVALID));
+
+ TEST_ALLOC_SAFE {
+ reply = dbus_message_new_method_return (method_call);
+
+ dbus_message_iter_init_append (reply, &iter);
+
+ dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT,
+ (DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_INT32_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING),
+ &subiter);
+
+ dbus_message_iter_open_container (&subiter, DBUS_TYPE_ARRAY,
+ (DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_INT32_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING),
+ &arrayiter);
+
+ dbus_message_iter_open_container (&arrayiter, DBUS_TYPE_STRUCT,
+ NULL,
+ &structiter);
+
+ str_value = "main";
+ dbus_message_iter_append_basic (&structiter, DBUS_TYPE_STRING,
+ &str_value);
+
+ int32_value = proc_pid;
+ dbus_message_iter_append_basic (&structiter, DBUS_TYPE_INT32,
+ &int32_value);
+
+ dbus_message_iter_close_container (&arrayiter, &structiter);
+
+ dbus_message_iter_close_container (&subiter, &arrayiter);
+
+ dbus_message_iter_close_container (&iter, &subiter);
+ }
+
+ dbus_connection_send (server_conn, reply, NULL);
+ dbus_connection_flush (server_conn);
+
+ dbus_message_unref (method_call);
+ dbus_message_unref (reply);
+
+
/* Expect the Reload call against job instance
* and reply with an instance path to
* acknowledge
@@ -8785,6 +8927,9 @@
kill (server_pid, SIGTERM);
waitpid (server_pid, NULL, 0);
+
+ kill (proc_pid, SIGTERM);
+ waitpid (proc_pid, NULL, 0);
continue;
}
@@ -8812,6 +8957,10 @@
setenv ("UPSTART_INSTANCE", "foo", TRUE);
TEST_ALLOC_FAIL {
+ TEST_CHILD (proc_pid) {
+ pause ();
+ }
+
TEST_CHILD (server_pid) {
/* Expect the GetJobByName method call on the
* manager object, make sure the job name is passed
@@ -8883,6 +9032,67 @@
dbus_message_unref (method_call);
dbus_message_unref (reply);
+ /* Expect the Get call for the processes, reply with
+ * a main process pid.
+ */
+ TEST_DBUS_MESSAGE (server_conn, method_call);
+
+ TEST_TRUE (dbus_message_is_method_call (method_call,
+ DBUS_INTERFACE_PROPERTIES,
+ "Get"));
+ TEST_EQ_STR (dbus_message_get_path (method_call),
+ DBUS_PATH_UPSTART "/jobs/test/foo");
+
+ TEST_TRUE (dbus_message_get_args (method_call, NULL,
+ DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &property,
+ DBUS_TYPE_INVALID));
+
+ TEST_ALLOC_SAFE {
+ reply = dbus_message_new_method_return (method_call);
+
+ dbus_message_iter_init_append (reply, &iter);
+
+ dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT,
+ (DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_INT32_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING),
+ &subiter);
+
+ dbus_message_iter_open_container (&subiter, DBUS_TYPE_ARRAY,
+ (DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_INT32_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING),
+ &arrayiter);
+
+ dbus_message_iter_open_container (&arrayiter, DBUS_TYPE_STRUCT,
+ NULL,
+ &structiter);
+
+ str_value = "main";
+ dbus_message_iter_append_basic (&structiter, DBUS_TYPE_STRING,
+ &str_value);
+
+ int32_value = proc_pid;
+ dbus_message_iter_append_basic (&structiter, DBUS_TYPE_INT32,
+ &int32_value);
+
+ dbus_message_iter_close_container (&arrayiter, &structiter);
+
+ dbus_message_iter_close_container (&subiter, &arrayiter);
+
+ dbus_message_iter_close_container (&iter, &subiter);
+ }
+
+ dbus_connection_send (server_conn, reply, NULL);
+ dbus_connection_flush (server_conn);
+
+ dbus_message_unref (method_call);
+ dbus_message_unref (reply);
+
/* Expect the Reload call against job instance
* and reply with an instance path to
* acknowledge.
@@ -8939,6 +9149,9 @@
kill (server_pid, SIGTERM);
waitpid (server_pid, NULL, 0);
+
+ kill (proc_pid, SIGTERM);
+ waitpid (proc_pid, NULL, 0);
continue;
}
--
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/upstart-devel