Skip to content
Olaf Alders edited this page Feb 16, 2019 · 59 revisions

SysAdmin FAQ

Network infrastructure

https://github.com/CPAN-API/network-infrastructure

  • Includes disk setup / expansion instructions

Manual maintenance issues

How to reindex a missing module?

sudo -u metacpan /home/metacpan/bin/metacpan-api-carton-exec bin/metacpan release --latest http://cpan.metacpan.org/authors/id/X/XS/XSAWYERX/MetaCPAN-API-0.33.tar.gz 

Or, just use this shell script

How to index all unindexed dists uploaded over the last 24 hours?

bin/metacpan release --skip --age 24 --latest ~/CPAN/authors/id/

How to index the latest Perl release

bin/metacpan release http://cpan.metacpan.org/authors/id/R/RJ/RJBS/perl-5.16.0.tar.bz2
bin/metacpan release --status latest http://cpan.metacpan.org/authors/id/R/RJ/RJBS/perl-5.16.1.tar.bz2

Or use this shell script

The above syntax will force the status bit to "latest", which we need to do manually only for new, latest Perl releases. It also reindexes the predecessor so that we don't have two Perl releases with the status of "latest".

Restarting services

The following services are set up:

starman_metacpan-api
starman_metacpan-web
metacpan-watcher
rrrclient-metacpan
elasticsearch-es-01

Each of those services can be restarted by calling service $name restart (as superuser).

How to deploy a new version of ANYTHING?

On all machines run..

sudo /etc/puppet/run.sh.

How to clear the fastly cache for metacpan-web

From within the metacpan-conf-private repository:

Specific 'keys' ( as set in the code with $c->add_surrogate_key() )

perl bin/purge_fastly.pl --service web --key HOMEPAGE --key ABOUT

The entire site ( e.g. if JS or css is updated and affects every page )

perl bin/purge_fastly.pl --all --service web

Note also these caching issues.

How to put new mappings

As metacpan user:

sh /home/metacpan/bin/metacpan-api-carton-exec bin/metacpan mapping

Network/high level issues

What is the procedure if the server is unreachable?

ByteMark

https://github.com/CPAN-API/metacpan-credentials/blob/master/hosting/bytemark.md (access limited)

Where are system monitoring reports stored?

The ElasticSearch status can be queried from within the box:

$ curl localhost:9200/cpan/_status?pretty

$ curl localhost:9200/_cluster/health/cpan_v1?level=shards

Where are backups stored

[22:03:08]  <mo>	 [20:12:26] sudo -i -u metacpan # become metacpan user
[22:03:08]  <mo>	 [20:12:32] we don't have root on that box
...
[22:03:09]  <mo>	 [20:26:53] $ mount /mnt/backup
[22:03:09]  <mo>	 [20:27:22] and backups are in /home/metacpan/api.metacpan.org/var/backup
[22:03:09]  <mo>	 [20:27:33] run bin/metacpan backup to restore

SSL certificates

Certificates are currently minted by StartSSL using their free Class 1 level process. The Class 1 level certs are good for one year, cover a top-level domain as well as a subdomain, and only require minimal personal identity information (name, email, physical address, phone). Best of all, they're free. The only caveat is that you cannot mint a cert if an existing cert exists for the same DNS name and the existing cert's expiry is more than two weeks out. To do so would first require a 25$ revocation fee for the original cert before being able to mint a new one.

Where are certs stored?

https://github.com/CPAN-API/metacpan-conf-private/tree/master/ssl/metacpan-api

  • server.key - Copy of the 2048-bit RSA private key
  • server.csr - Certificate Signing Request sent to StartSSL
  • server.pub - Public cert provided by StartSSL
  • server.crt - Combined public cert + intermediate cert + StartSSL CA root

The combined server.crt file is generated using the /etc/puppet/private/bm-n2/ssl/chain-to-startssl script and files in /etc/puppet/private/bm-n2/ssl/startssl-ca.

The server.key for api.metacpan.org, cpan.metacpan.org, and metacpan.org is a copy of 2014-01-09.key. Sharing a private key makes renewing certs easier. Note that currently www.metacpan.org has a different key.

The containing directory, ssl/, is a local git repository. This aids in not losing our keys or certs, which may be hard or impossible to replace easily if overwritten during a botched update.

Current certificates

If you have access.. see: https://github.com/CPAN-API/metacpan-conf-private

Only api.metacpan.org needs a public certificate, as the rest use the Fastly SSL certificates for the public, and self signed certs for Fastly to talk to.

api.metacpan.org

Good for api.metacpan.org - Only used by api. Minted by trs.

Renewing certificates

Renewing the certs from StartSSL requires:

  1. Re-validate control over metacpan.org via their process. Email to hostmaster@ or [email protected] will both go to [email protected] where you can see it.
  2. Skip their private key generation step and supply a CSR directly. You can and should reuse the existing CSRs to avoid problems. If you regenerate a CSR, make sure it matches the key! Compare the output of:
    openssl rsa -noout -modulus < server.key | sha1sum
    openssl req -noout -modulus < new.csr | sha1sum
  1. Save the new public cert to <dns-name>/server.pub
  2. Run chain-to-startssl <dns-name> to generate a server.crt with the appropriate certificate chain.
  3. Install new certs and restart services by running puppet: /etc/puppet/run.sh
  4. Manually verify that everything worked!
  5. Commit your changes to the local git repo:
    cd /etc/puppet/private/bm-n2/ssl
    sudo git add -A
    sudo git commit --author='Your Name <[email protected]>'

Finding High Volume IPs Hitting the API

sudo awk '{print $1}' /var/log/nginx/metacpan-api/access.log | sort | uniq -c | sort -nr | less

Finding High Volume UserAgents hitting the Search Site

There's no point in searching for IPs, as they'll all point back to Fastly.

sudo awk -F"\"" '{print $6}' /var/log/nginx/metacpan-web/access.log | sort | uniq -dc | sort -nr | head -20