Yuvipanda has uploaded a new change for review. https://gerrit.wikimedia.org/r/204014
Change subject: tools: Remove remnants of portgranter code ...................................................................... tools: Remove remnants of portgranter code Service can be stopped via salt. Bug: T93046 Change-Id: I3278d974b378acd2a06e6808bc5297139606612b --- D modules/toollabs/files/portgranter D modules/toollabs/files/portgranter.conf M modules/toollabs/files/proxylistener.conf M modules/toollabs/manifests/node/web.pp 4 files changed, 1 insertion(+), 172 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/14/204014/1 diff --git a/modules/toollabs/files/portgranter b/modules/toollabs/files/portgranter deleted file mode 100755 index b0e892a..0000000 --- a/modules/toollabs/files/portgranter +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright © 2013 Marc-André Pelletier <[email protected]> -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -use Socket; -use File::NFSLock; -use Fcntl qw(LOCK_EX LOCK_NB); - -my $scoreboard = "/data/project/.system/dynamic"; -my $sockname = "/tmp/sock.portgranter"; -my $uaddr = sockaddr_un($sockname); - -unlink($sockname); -socket(Server, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!"; -bind (Server, $uaddr) || die "bind: $!"; -chmod 0666, $sockname; -listen(Server, SOMAXCONN) || die "listen: $!"; - -sub spawn { - my $sock = shift; - my $coderef = shift; - my $pid = fork(); - - if($pid>0 or not defined $pid) { - close $sock; - return $pid; - } - - exit($coderef->($sock)); -} - -my $hostname = `hostname`; chomp $hostname; -my %clients; -my @ports; -my $update = 1; - -use POSIX ":sys_wait_h"; -sub REAPER { - my $child; - while( ($child = waitpid(-1, WNOHANG)) > 0 ) { - if(defined $clients{$child}) { - my $c = $clients{$child}; - delete $clients{$child}; - $update = 1; - unshift @ports, $c->{'port'}; - } - } - - $SIG{CHLD} = \&REAPER; # loathe SysV -} - -$SIG{CHLD} = \&REAPER; - - -for(my $i=12000; $i<13000; $i++) { - push @ports, $i; -} - -$| = 1; -for(;;) -{ - if($update) { - if(my $lock = new File::NFSLock { - file => "$scoreboard.new", - lock_type => LOCK_EX, - blocking_timeout => 10, - stale_lock_timeout => 120, - }) { - my @scoreboard; - if(open SB, "<$scoreboard") { - while(<SB>) { - if(m/^\S+ ([^:]+):[0-9]+$/) { - next if $1 eq $hostname; - } - push @scoreboard, $_; - } - close SB; - } - foreach my $c (values %clients) { - push @scoreboard, "$c->{'tool'} $hostname:$c->{'port'}\n"; - } - - if(open SB, ">$scoreboard.new") { - print SB join '', @scoreboard; - if(rename "$scoreboard.new", $scoreboard) { - $update = 0; - } else { - unlink "$scoreboard.new"; - } - close SB; - } - } - } - - if($#ports < 0) { - sleep 1; - next; - } - - my $client; - next unless accept($client, Server); - - my $tool = <$client>; - my $port = shift @ports; - chomp $tool; - print $client "$port\n"; - - my $pid = spawn $client, sub { - my $sock = shift; - scalar <$sock>; - close $sock; - return 0; - }; - if(defined $pid) { - $clients{$pid} = { - pid => $pid, - tool => $tool, - port => $port, - }; - $update = 1; - } -} - diff --git a/modules/toollabs/files/portgranter.conf b/modules/toollabs/files/portgranter.conf deleted file mode 100644 index 5851a8d..0000000 --- a/modules/toollabs/files/portgranter.conf +++ /dev/null @@ -1,13 +0,0 @@ -# portgranter - grant ports dynamically for daemons - -description "Portgranter" - -start on runlevel [2345] -stop on runlevel [!2345] - -respawn - -console log - -exec /usr/local/sbin/portgranter - diff --git a/modules/toollabs/files/proxylistener.conf b/modules/toollabs/files/proxylistener.conf index d0771aa..b93934a 100644 --- a/modules/toollabs/files/proxylistener.conf +++ b/modules/toollabs/files/proxylistener.conf @@ -1,4 +1,4 @@ -# portgranter - setup routing info in redis for Yuviproxy +# proxylistener - setup routing info in redis for Yuviproxy description "ProxyListener" diff --git a/modules/toollabs/manifests/node/web.pp b/modules/toollabs/manifests/node/web.pp index db76cdf..9451ce1 100644 --- a/modules/toollabs/manifests/node/web.pp +++ b/modules/toollabs/manifests/node/web.pp @@ -46,28 +46,6 @@ require => File['/usr/local/lib/python2.7/dist-packages/portgrabber.py'], } - file { '/usr/local/sbin/portgranter': - ensure => file, - owner => 'root', - group => 'root', - mode => '0555', - source => 'puppet:///modules/toollabs/portgranter', - } - - file { '/etc/init/portgranter.conf': - ensure => file, - owner => 'root', - group => 'root', - mode => '0444', - source => 'puppet:///modules/toollabs/portgranter.conf', - require => File['/usr/local/sbin/portgranter'], - } - - service { 'portgranter': - ensure => running, - require => File['/etc/init/portgranter.conf'], - } - file { '/usr/local/bin/jobkill': ensure => file, owner => 'root', -- To view, visit https://gerrit.wikimedia.org/r/204014 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3278d974b378acd2a06e6808bc5297139606612b Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Yuvipanda <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
