04.05.2015 Views

Versioning Infrastructure Michael Mirman - Perforce

Versioning Infrastructure Michael Mirman - Perforce

Versioning Infrastructure Michael Mirman - Perforce

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Versioning</strong> <strong>Infrastructure</strong><br />

<strong>Michael</strong> <strong>Mirman</strong><br />

<strong>Perforce</strong> Administrator<br />

1


Introduction<br />

2


Architecture Overview<br />

§ ~750 users worldwide<br />

§ Several million archive files<br />

§ ~50 <strong>Perforce</strong>-related hosts<br />

§ Almost all possible triggers;<br />

several daemons<br />

§ Mirroring our own bug<br />

database into <strong>Perforce</strong><br />

§ Interfaces: P4, P4V,<br />

P4Perl, P4Java, Emacs,<br />

P4Eclipse, P4DB, P4EXP<br />

3


Describing Servers<br />

4


Using markup language<br />

<br />

brokerhost=p4brokerprod<br />

<br />

<br />

p4broker <br />

Primary<br />

$brokerhost<br />

<br />

[/local/perforce/bin/p4broker -d -c /local/perforce/config/broker.conf]<br />

<br />

<br />

5


Using markup language (cont.)<br />

§<br />

Defining primary and secondary servers<br />

<br />

master=p4host-00<br />

standby=p4host-01<br />

<br />

<br />

Primary<br />

$master<br />

<br />

[$bin/p4d -d -p 1666 -In Master -r /local/p4/db -J /local/p4/jdir/journal]<br />

<br />

<br />

<br />

Secondary<br />

$standby<br />

<br />

[$bin/p4d -d -p 1666 -In Standby -r /local/p4/db -J off]<br />

<br />

<br />

Master <br />

(primary) <br />

p4broker <br />

Standby <br />

(secondary) <br />

6


Using configurables<br />

§<br />

Configurables complement start-up commands<br />

-> p4 configure set P4LOG=/local/perforce/logs/p4d.log<br />

-> p4 configure set Standby#serviceUser=service<br />

-> p4 configure set ‘Standby#startup.1=pull -i 2 -J /local/perforce/jdir/journal’<br />

-> p4 configure set ‘Standby#startup.2=pull -i 1 –u’<br />

-> p4 configure set FwdReplica#db.replication=readonly<br />

-> p4 configure set FwdReplica#lbr.replication=readonly<br />

-> p4 configure set FwdReplica#rpl.forward.all=1<br />

-> p4 configure set FwdReplica#serviceUser=service<br />

-> p4 configure set ‘FwdReplica#startup.1=pull -i 2 -J /local/perforce/jdir/journal’<br />

-> p4 configure set ‘FwdReplica#startup.2=pull -i 1 –u’<br />

7


Maintenance Commands (start up scripts)<br />

§<br />

§<br />

Keep commands as similar as possible.<br />

They can read the configuration file(s)<br />

and make the right decisions.<br />

Start-up commands – based on the<br />

configuration file and local host name<br />

decide what processes (services) must<br />

be started<br />

§<br />

/etc/init.d/p4d.current -> /local/perforce/<br />

support/init.scripts/p4d.prod<br />

8


Maintenance Commands (crontabs)<br />

§ Crontabs on different hosts look practically<br />

identical, making repurposing hosts easy<br />

# Daily maintenance<br />

00 03 * * * /local/perforce/cronjobs/p0X.cron<br />

# Rolling journal<br />

35,05 * * * * /local/perforce/cronjobs/roll_journal -conf /local/perforce/CONFIG/test_config.xml<br />

9


Deployment of maintenance scripts (version 1.0)<br />

§<br />

“Push” using change-commit trigger:<br />

push1 change-commit //depot/p4admin/... "updateRefTree -p %serverport% -c<br />

p4serv.p4adm.p00,p4serv.p4adm.t00“<br />

§ Comma-separated list defines clients to be updated<br />

§<br />

§<br />

Problem: some clients are on different hosts<br />

Attempt to solve it:<br />

push2 change-commit //depot/p4admin/... "updateRefTree -p %serverport% -c<br />

p4serv.p4adm.p00,p4serv.p4adm.t00:ssh:p4test00“<br />

§<br />

Problem: Triggers line is too long and cumbersome<br />

10


Deployment of maintenance scripts (version 1.1)<br />

§<br />

Leverage spec depot, file spec, and client spec:<br />

push3 change-commit //depot/p4admin/... "updateRefTree -p %serverport% -c p4serv.p4adm.p…“<br />

§<br />

§<br />

§<br />

Spec depot contains all client specs<br />

§ Trigger gets all effective clients<br />

p4 files -e //spec/client/p4serv.p4adm.p…<br />

p4 print //spec/client/p4serv.p4adm.p…<br />

Client specs contain Host<br />

§ Trigger runs ssh to the given host to update client<br />

Problems:<br />

§<br />

§<br />

Sometimes trigger runs for a long time<br />

If target host is down, we have no mechanism to update the target area<br />

11


Deployment scalability issue<br />

§<br />

2009/12/31: 5 targets<br />

• 2010/12/31: 13 targets<br />

• 2011/12/31: 20 targets<br />

• 2012/12/31: 49 targets<br />

12


Deployment of maintenance scripts (version 2.0)<br />

§<br />

Pull, don’t push<br />

set1 change-commit //depot/p4admin/... “set_mwsync -p %serverport% -c p4serv.p4adm.p…“<br />

13


Deployment of maintenance scripts (cont.)<br />

Set counter in the trigger <br />

p4 set counter mwsync.host_name.client_name .me_stamp <br />

14


Deployment of maintenance scripts (cont.)<br />

§<br />

§<br />

Run cron job on every host that needs to<br />

pull<br />

Cron retrieves the counters, corresponding<br />

to the local host name and syncs client(s)<br />

*/5 * * * * /local/perforce/cronjobs/watch2sync -­‐p perforce:1666 <br />

• Monitoring verifies that no counters with “old” Omestamps exist on the master <br />

00 6,12,18 * * * /local/perforce/scripts/lag_in_sync <br />

15


Deployment of crontabs<br />

§<br />

§<br />

§<br />

§<br />

Use change-commit trigger to install crontab<br />

commit.cron change-commit //depot/crontabs/p4serv/... "install.crontab -p4port<br />

%serverport% -changelist %changelist%"<br />

Crontab files in the depot are //depot/crontabs/userid/host<br />

For every crontab file the trigger retrieves from the change, the<br />

trigger deploys by piping the content to this command:<br />

ssh user@host crontab -<br />

Additional insurance (what if ssh fails?) in every crontab<br />

p4 -p perforce:1666 print -q //depot/crontabs/p4serv/$HOST > /tmp/crontab.$$; [ -s /<br />

tmp/crontab.$$ ] && crontab /tmp/crontab.$$; rm /tmp/crontab.$$<br />

16


Conclusion<br />

17


Summary<br />

§<br />

§<br />

§<br />

§<br />

Use meta language to describe infrastructure to allow change it<br />

easily<br />

Keep infrastructure description files, supporting scripts, and crontabs<br />

in <strong>Perforce</strong> (possibly on different servers)<br />

Use triggers to deploy changes in the infrastructure<br />

If your servers often change roles:<br />

§<br />

§<br />

Keep the details about the servers in configuration files, read by different scripts.<br />

Keep crontabs and boot-up scripts identical between servers.<br />

18


Q&A<br />

<strong>Michael</strong> <strong>Mirman</strong>: <strong>Michael</strong>.<strong>Mirman</strong>@mathworks.com<br />

19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!