cmogstored dev/user discussion/issues/patches/etc
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [ANN] cmogstored 1.5.0 - a mogstored alternative
@ 2015-11-21  2:58  7% Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2015-11-21  2:58 UTC (permalink / raw)
  To: mogile, cmogstored-public

cmogstored is an alternative implementation of the "mogstored" storage
component of MogileFS.  cmogstored is implemented in C and does not use
Perl at runtime.  cmogstored is the only component you need to install
on a MogileFS storage node.

Changes since 1.4.3:

    cmogstored 1.5.0 - vfork, systemd, 416 codes

    A bunch of minor changes; most notable is systemd-style socket
    activation support.  This was easy-to-add since we've always had
    socket activation support for nginx-style SIGUSR2 upgrades.

    This places no link or runtime dependency on libsystemd, so the
    LISTEN_FDS and LISTEN_PID environment variables may be used in other
    init systems as well.  While I have my own reservations about
    systemd itself, I also strongly believe in using socket activation
    to prevent downtime.  Existing behavior with CMOGSTORED_FD
    (used for SIGUSR2 upgrades) is now documented in the manpage and
    will always supported.

    We've also added vfork support for Linux systems, allowing
    faster spawning of iostat if malloc is using too much memory.

    Behavior changes:

    Bad Range: headers return 416 responses in more cases for invalid
    ranges (e.g. miscalculated ranges such as "1--1", while
    completely wrong ones (lacking a "bytes=" prefix) are ignored
    entirely as in nginx.

    Bugfixes:

    There are also some cleanups to avoid dying on OOM in more places
    on weird systems which trigger OOM.  More work on this is ongoing.

    Also updates to the latest gnulib.git
    commit 71d39c1644762745b94e9449c45bfd716a79a5eb
    ("autoupdate") along with a change which fixes a memory leak when
    people build from cmogstored.git using gnulib
    commit c6148bca89e9465fd6ba3a10d273ec4cb58c2dbe
    or later ("mountlist: add me_mntroot field on Linux machines").

    This memory leak did not affect any released tarballs of cmogstored.
    Note, users building from git (as opposed to the tarball) will
    need gnulib commit 41d1b6c42641a5b9e21486ca2074198ee7909bd7
    ("mountlist: add support for deallocating returned list entries")
    or later (from July 2013).

    There are also various documentation updates and our mailing
    list is now readable over NNTP:

      nntp://news.public-inbox.org/inbox.comp.file-systems.mogilefs.cmogstored

8 changes since v1.5.0rc0:

      doc: document CMOGSTORED_FDS in the manpage
      use vfork under Linux before execve
      README: update contact information
      misc doc updates
      add cmogstored manpage to website
      Makefile.am: distribute txt2pre in tarball
      require newer gnulib for free_mount_entry support
      cmogstored 1.5.0 - vfork, systemd, 416 codes

14 changes for 1.5.0rc0:

      doc: use "builder" RubyGem to generate Atom feed
      dev.c: fail gracefully on out-of-memory errors
      do not die on OOM when for mgmt paths
      HACKING: update URLs to reduce redirects
      http: return 416 errors in more cases for bad Ranges
      update .gitignores for latest autotools + gnulib
      Rakefile: remove text-only part from the Atom feed
      support systemd-style socket activation via environment
      set TCP listener options on inherited sockets
      doc: add example systemd config files
      use free_mount_entry from gnulib instead of rolling our own
      fix tmpdir dependency for slow Ruby tests
      doc: publish examples directory to website
      cmogstored 1.5.0rc1

http://bogomips.org/cmogstored/files/cmogstored-1.5.0.tar.gz
SHA-1: 0581285d7104ff418eed853cfbd94ab08bba4951
SHA-256: b83b954874ef201b6e6616ec3e60f517c6a01f7bc6eda1fbb3901558e34c1388

* homepage: http://bogomips.org/cmogstored/README
* git clone git://bogomips.org/cmogstored.git
* cgit: http://bogomips.org/cmogstored.git
* gitweb: http://repo.or.cz/w/cmogstored.git
* list: cmogstored-public@bogomips.org (subscription optional)
* archives: http://bogomips.org/cmogstored-public/
* nntp://news.public-inbox.org/inbox.comp.file-systems.mogilefs.cmogstored

-- 
EW

^ permalink raw reply	[relevance 7%]

* [ANN] cmogstored 1.5.0rc1 - a mogstored alternative
@ 2015-11-11 22:05  7% Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2015-11-11 22:05 UTC (permalink / raw)
  To: mogile; +Cc: cmogstored-public

cmogstored is an alternative implementation of the "mogstored" storage
component of MogileFS.  cmogstored is implemented in C and does not use
Perl at runtime.  cmogstored is the only component you need to install
on a MogileFS storage node.

Changes since 1.4.3:

    A bunch of minor changes; most notable is systemd-style socket
    activation support.  This was easy-to-add since we've always had
    socket activation support for nginx-style SIGUSR2 upgrades.

    This places no link or runtime dependency on libsystemd, so the
    LISTEN_FDS and LISTEN_PID environment variables may be used in other
    init systems as well.  While I have my own reservations about
    systemd itself, I also strongly believe in using socket activation
    to prevent downtime.

    Behavior changes:

    Bad Range: headers return 416 responses in more cases for invalid
    ranges (e.g. miscalculated ranges such as "1--1", while
    completely wrong ones (lacking a "bytes=" prefix)) are ignored
    entirely as in nginx.

    Bugfixes:

    There are also some cleanups to avoid dying on OOM in more places
    on weird systems which trigger OOM.  More work on this is ongoing.

    Also updates to the latest gnulib.git
    commit f197c2c9e5e0d12c373f26d5b3211809457bc972
    ("intprops: new public macro EXPR_SIGNED")
    along with a change which fixes a memory leak when people
    build from cmogstored.git using gnulib
    commit c6148bca89e9465fd6ba3a10d273ec4cb58c2dbe
    or later ("mountlist: add me_mntroot field on Linux machines").
    This memory leak did not affect any released tarballs of cmogstored.

    shortlog of changes since 1.4.3:

          doc: use "builder" RubyGem to generate Atom feed
          dev.c: fail gracefully on out-of-memory errors
          do not die on OOM when for mgmt paths
          HACKING: update URLs to reduce redirects
          http: return 416 errors in more cases for bad Ranges
          update .gitignores for latest autotools + gnulib
          Rakefile: remove text-only part from the Atom feed
          support systemd-style socket activation via environment
          set TCP listener options on inherited sockets
          doc: add example systemd config files
          use free_mount_entry from gnulib instead of rolling our own
          fix tmpdir dependency for slow Ruby tests
          doc: publish examples directory to website

Expect 1.5.0 final in a week or so (unless I forget :x)

http://bogomips.org/cmogstored/files/pre/cmogstored-1.5.0rc1.tar.gz
SHA-1   1b301ce5f180f9001275e26fa1c065593cc3569c
SHA-256 f99a9d4186c0b267952ec4806e6ccd333ab4441fe36e41417e4a09ccbd0c3e1e

* homepage: http://bogomips.org/cmogstored/README
* git clone git://bogomips.org/cmogstored.git
* cgit: http://bogomips.org/cmogstored.git
* gitweb: http://repo.or.cz/w/cmogstored.git
* list: cmogstored-public@bogomips.org (subscription optional)
* archives: http://bogomips.org/cmogstored-public/
* nntp://news.public-inbox.org/inbox.comp.file-systems.mogilefs.cmogstored

-- 
EW

^ permalink raw reply	[relevance 7%]

* [PATCH] support systemd-style socket activation via environment
@ 2015-11-11  2:40  7% Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2015-11-11  2:40 UTC (permalink / raw)
  To: cmogstored-public; +Cc: Eric Wong

While I have my reservations about systemd, socket activation alone
is a good idea and we already have existing infrastructure for
supporting it in SIGUSR2 upgrades.

We are intentionally avoiding linkage to libsystemd to avoid dealing
with ABI compatibility issues between old and new systems.  This
also allows us to integrate more easily with non-systemd systems
which use the same environment variables as systemd.
---
 cmogstored.x    |  7 +++++++
 inherit.c       | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 test/inherit.rb | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/cmogstored.x b/cmogstored.x
index bd5956d..a6b96e6 100644
--- a/cmogstored.x
+++ b/cmogstored.x
@@ -15,6 +15,13 @@ MOG_IOSTAT_CMD - command-line for invoking iostat(1).  This is used
 by the sidechannel to report disk utilization to trackers.
 Default: "iostat -dx 1 30"
 
+LISTEN_FDS, LISTEN_PID - may be used for systemd-style socket activation
+regardless of whether systemd is on the system.  See sd_listen_fds(3)
+for more information.  Since cmogstored supports two protocols on
+different sockets, the command line or config file must still specify
+which addresses to listen on.  This feature is available in cmogstored
+1.5.0 and later.
+
 See MALLOC TUNING for environment variables which may affect memory
 usage.
 
diff --git a/inherit.c b/inherit.c
index ca7afa7..0229a04 100644
--- a/inherit.c
+++ b/inherit.c
@@ -89,6 +89,55 @@ static bool listener_close_each(void *_l, void *unused)
 	return true;
 }
 
+static void listeners_init(void)
+{
+	if (listeners) return;
+	listeners = hash_initialize(3, NULL, listener_hash, listener_cmp, free);
+	mog_oom_if_null(listeners);
+	atexit(listeners_cleanup);
+}
+
+static unsigned long listen_env(const char *env)
+{
+	const char *e = getenv(env);
+	unsigned long tmp;
+	char *end;
+
+	if (!e) return ULONG_MAX;
+	errno = 0;
+	tmp = strtoul(e, &end, 10);
+	if (errno) die_errno("failed to parse %s: %s", env, e);
+	if (*end) die("trailing byte in %s: %s", env, e);
+
+	return tmp;
+}
+
+/* systemd-style socket activation in the vein of sd_listen_fds(3) */
+static void systemd_inherit_fds(void)
+{
+	const int listen_fds_start = 3; /* SD_LISTEN_FDS_START */
+	int fd, listen_fds_end;
+	unsigned long tmp = listen_env("LISTEN_PID");
+
+	if (getpid() != (pid_t)tmp) goto out;
+
+	tmp = listen_env("LISTEN_FDS");
+	if (tmp > INT_MAX) die("LISTEN_FDS out of range: %lu", tmp);
+
+	listeners_init();
+	listen_fds_end = listen_fds_start + (int)tmp;
+	for (fd = listen_fds_start; fd < listen_fds_end; fd++) {
+		if (mog_set_cloexec(fd, true) == 0)
+			register_listen_fd(fd);
+		else
+			die("inherited out %d of %lu LISTEN_FDS",
+			    fd - listen_fds_start, tmp);
+	}
+out:
+	unsetenv("LISTEN_FDS");
+	unsetenv("LISTEN_PID");
+}
+
 /* close all inherited listeners we do not need */
 void mog_inherit_cleanup(void)
 {
@@ -131,13 +180,12 @@ void mog_inherit_init(void)
 	unsigned long fd;
 	unsigned endbyte;
 
+	systemd_inherit_fds();
+
 	if (orig == NULL)
 		return;
 
-	listeners = hash_initialize(3, NULL, listener_hash, listener_cmp, free);
-	mog_oom_if_null(listeners);
-	atexit(listeners_cleanup);
-
+	listeners_init();
 	fds = xstrdup(orig);
 	tip = fds;
 
diff --git a/test/inherit.rb b/test/inherit.rb
index b342ab0..34aa52f 100644
--- a/test/inherit.rb
+++ b/test/inherit.rb
@@ -142,4 +142,36 @@ def test_inherit_high
     @err.rewind
     assert_match(/failed to parse/, @err.read)
   end
+
+  def test_inherit_systemd
+    # disabled test on old Rubies: https://bugs.ruby-lang.org/issues/11336
+    # [ruby-core:69895] [Bug #11336] fixed by r51576
+    return unless RUBY_VERSION.to_f >= 2.3
+
+    mgmt = TCPServer.new(@host, 0)
+    @to_close << mgmt
+    mport = mgmt.addr[1]
+    cmd = %W(cmogstored --docroot=#@tmpdir --httplisten=#@host:#@port
+             --mgmtlisten=#@host:#{mport} --maxconns=100)
+    @pid = fork do
+      ENV['LISTEN_PID'] = "#$$"
+      ENV['LISTEN_FDS'] = '2'
+      exec(*cmd, 3 => mgmt.fileno, 4 => @srv.fileno)
+    end
+
+    # just ensure HTTP works after being inherited
+    Net::HTTP.start(@host, @port) do |http|
+      [ Net::HTTP::Get, Net::HTTP::Head ].each do |meth|
+        resp = http.request(meth.new("/"))
+        assert_kind_of Net::HTTPOK, resp
+      end
+    end
+
+    # still works since drop is open in _this_ process
+    c = TCPSocket.new(@host, mport)
+    assert_instance_of(TCPSocket, c)
+    @to_close << c
+    c.write "hello\n"
+    assert_match /ERROR: unknown command/, c.gets
+  end
 end
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-11-11  2:40  7% [PATCH] support systemd-style socket activation via environment Eric Wong
2015-11-11 22:05  7% [ANN] cmogstored 1.5.0rc1 - a mogstored alternative Eric Wong
2015-11-21  2:58  7% [ANN] cmogstored 1.5.0 " Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/cmogstored.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).