Main Page: Difference between revisions

From Wikitech
Content deleted Content added
imported>LeslieCarr
No edit summary
adding === dry runs === section
Line 1: Line 1:
== Access rights ==
{| style="width: 100%" class="leftalign-table messagebox"
!style="width:100px"| Boxes
| [[Server roles]]
|-
! Servers
| [[Apaches]] '''·''' [[Squids]] '''·''' [[Image scalers|Scalers]] '''·''' [[NFS]] '''·''' [[DNS]] '''·''' [[PowerDNS]] '''·''' [[Memcached]] '''·''' [[MySQL]] '''·''' [[LDAP]] '''·''' [[Multicast HTCP purging]] '''·''' [[Virtualization]] '''·''' [[Https]] '''·''' [[Build_a_new_server]] '''·''' [[PartMan]]
|-
! Backups
| [[Backup status chart|CurrentStatus]] '''&middot;''' [[Disaster Recovery]] '''&middot;''' [[Dumps|XMLDatabaseDumps]] '''&middot;''' [[Offsite Backups|Offsite]]<br>
OSs: [http://www.ubuntu.com/ Ubuntu] ([[:Category:Ubuntu|Ubuntu]]) '''&middot;''' [[Automated installation]] '''&middot;''' [[Distribution upgrades]] '''&middot;''' [[Puppet]] '''&middot;''' [[APT repository]] '''&middot;''' [[Solaris]]
|-
! Inner
| [[Sensors]] '''&middot;''' [[console server]] '''&middot;''' [[switches]] '''&middot;''' [[APC]] <small>(remote power strip)</small> '''&middot;''' [[Ipmi]] '''&middot;''' [[SSL Certificates]]
|-
! War
| [[Security]] '''&middot;''' [[spider blocks]]
|-
! Maps
| [[batch jobs]] '''&middot;''' [[Locations]] <small>of backups, mirrors, etc.</small> '''&middot;''' [[Scripts]]
|-
! Email
| [[Mail]] '''&middot;''' [[IMAP]] '''&middot;''' [[Mailing lists]] '''&middot;''' [[OTRS]]
|-
! Guides
| [[How-To|How-Tos]] '''&middot;''' [[Misc scripts]] '''&middot;''' [[Wiki farm]] '''&middot;''' [[Profiling]] ([http://noc.wikimedia.org/cgi-bin/ng/report.py web interface]) '''&middot;''' [[Using the local certificate authority]]
|-
! Network
| [[Network design|Design]] '''&middot;''' [[Switches]] '''&middot;''' [[BGP]] '''&middot;''' [[IP addresses|IPs]] '''&middot;''' [[Network utils|Utils]] '''&middot;''' [[802.1Q]] '''&middot;''' [[RANCID]] '''&middot;''' [http://puck.nether.net/netops/ NOC Phones] '''&middot;''' [[LVS]]
|-
! Other
| [[Volunteer Squid Sites]] '''&middot;''' [[Collected Status]] '''&middot;''' [[Platform-specific documentation]]
|-
! Wiki
| [[:Category:Main|Browse root category]] '''&middot;''' [[:Category:Wiki]] '''&middot;''' [[:Category:Templates]]
|}
* [[:Category:Bot and monitoring]]
* [[:Category:Cluster]]
* [[Presentations]]
* [[Software deployments]]


=== Anonymous users ===
* Please add general MediaWiki documentation at [http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide MediaWiki User's Guide].


You'll need to have an account created for you. If you currently have SVN access, then you have an account, but need to have it linked to Labs. We are still working out the account activation process, but hope to have it done soon.
==Links==

<div class="plainlinks">
=== Logged-in users ===
* Mark's Request Stats: [http://wiki.wikked.net/wiki/Wikimedia_statistics/Daily Combined] [http://www.nedworks.org/~mark/reqstats/ raw]

* Ganglia [http://ganglia.wikimedia.org graphs]
After creating an account, you can:
* [http://meta.wikimedia.org/wiki/Wikimedia_servers Meta:Wikimedia servers]

</div>
* [[Special:NovaKey|Add and manage your public SSH keys]]
[[Category:Wiki]]

Once you add a key, you'll be able to log into any existing instance in the main project '''testlabs''': <code>ssh <nameofinstance></code>. It may take up to 30 minutes for your key to be propagated to all instances.

To create instances, you'll need to have an admin add you to a project, and to the sysadmin role in that project.

You can make [[Resource query examples|queries]] for nova resources; currently Nova instances have semantic properties enabled.

After logging in, you can also access [https://gerrit.wikimedia.org Gerrit]; if you wish to do git checkouts of the puppet repositories, you'll need to log into [https://gerrit.wikimedia.org Gerrit], and add your SSH key there as well. Note: it would be nice if Gerrit could use LDAP for its SSH keystore, instead of its database; I've opened a [http://code.google.com/p/gerrit/issues/detail?id=1124 bug for this], if you'd like to help, please add that feature to Gerrit!

=== Admins ===

==== Wiki Admin ====

If you are a wiki admin, you can:

* [[Special:NovaProject|Create/delete Nova projects and manage project and project role membership]]
* [[Special:NovaRole|Manage global role membership]].
* [[Special:NovaSudoer|Manage sudo policies]].

==== Net Admins ====

If you are a NetAdmin, you can:

* [[Special:NovaAddress|Allocate and associate public IP addresses, and add public DNS entries to instances]]
* [[Special:NovaSecurityGroup|Manage security groups and rules]].

==== Sys Admins ====

If you are a sysadmin, you can:

* [[Special:NovaInstance|Create or manage instances]].
* [[Special:NovaVolume|Create or manage volumes]].

After creating an instance, you'll get an email notifying you that it is ready to be logged into. If you did not add an SSH key prior to creating the instance, you'll need to wait until your key is propagated to the instances (which can take an additional 30 minutes).

==== Cloud Admins ====

In addition to all actions that sysadmins and netadmins, you can:

* [[Special:NovaDomain|Create or manage DNS domains]].

=== Access FAQ ===

* '''Q:''' I was added to a group that gives me access to something in git, but it isn't working, what's wrong?
** '''A:''' Once you have been added to the group, you need to log out of gerrit, then back in. Gerrit pulls its groups from LDAP, but caches them. Logging out, then back in re-synchronizes your groups, and thus clears the cache.

== Git/Gerrit and the puppet repositories ==

Note: Push access is currently limited to staff developers and operations engineers. This will change soon. To pull the repository anonymously for read access use the following command:

git clone https://gerrit.wikimedia.org/r/p/operations/puppet

=== Set up your ssh key in Gerrit ===

Log into the [https://gerrit.wikimedia.org web interface for gerrit]. Click on Settings then SSH Public Keys then add your key.

=== Checking out the puppet repositories ===

We have the following main repositories and branches:

* operations/puppet
** production (HEAD)
*** used in production
** test
*** used in the testlabs project
* labs/private
** master (HEAD)
*** only used in testlabs project

To check out the production branch of the puppet repo, you can clone it like so (if they're different, shell-username is your unix shell name, not the wiki username.):

git clone ssh://<shell-username>@gerrit.wikimedia.org:29418/operations/puppet.git

To check out the labs/private branch, you can clone it like so:

git clone ssh://<shell-username>@gerrit.wikimedia.org:29418/labs/private.git

=== Git configuration required to commit ===

==== Use git-setup ====

After the initial clone of the git repository, you can use the git-setup script (in the root level of the repository). It will set your user name, email, and will pull hooks required for proper use of gerrit.

==== ...or do initial git configuration manually ====

First, you should set your name and email address in your local git configuration. The email address and wiki username are the same as what you use to log into this wiki:

git config --global user.email "<email-address>"
git config --global user.name "<wiki-username>"

Next you'll need to add a commit-msg hook to your local repository. This hook is required for pushing changes to the Gerrit server.

curl "https://gerrit.wikimedia.org/r/tools/hooks/commit-msg" > .git/hooks/commit-msg && chmod u+x .git/hooks/commit-msg

(*) You may need to rename "commit-msg.sample" to "commit.msg" before.

=== Updating your local repository ===

After you do the initial repository clone, git will automatically set up a remote tracking branch for you. You simply need to fetch/merge or pull:

git fetch
git diff origin/<branch>
git merge origin/<branch>

or:

git pull

=== Making changes ===

After cloning the repo, you can make changes the normal git way:

<make changes>
git add <newfiles>
git commit -a

After doing so, you'll need to push the changes for review; for instance, here's how to push to the test branch of the puppet repository:

git push ssh://<username>@gerrit.wikimedia.org:29418/operations/puppet HEAD:refs/for/test

You can shorten that by adding a remote:

git remote add puppet ssh://<username>@gerrit.wikimedia.org:29418/operations/puppet

Now you can push for review like so:

git push puppet HEAD:refs/for/test

You can shorten this further by making an alias:

git config alias.push-for-review-test "push puppet HEAD:refs/for/test"

Now you can push for review like so:

git push-for-review-test

Here's the alias for production:

git config alias.push-for-review-production "push puppet HEAD:refs/for/production"

Also, staff operations members have the ability to (but shouldn't!) skip the review step; to do so, simply do a push:

git push puppet

Here's the remotes and aliases for the private repo:

git remote add private ssh://<username>@gerrit.wikimedia.org:29418/labs/private
git config alias.push-for-review-private "push private HEAD:refs/for/master"

=== Review ===
Review your change (or someone elses!) in Gerrit.

# Go to https://gerrit.wikimedia.org
#* if it's your own change, you will see it listed on the first screen
#* if it's someone else's, click on 'All' then 'open' to see all unreviewed changes
# click on the change you want to review
# click on "Diff all side by side" to examine the diff
#* this will open each changed file in a new tab
# when you're done reviewing, go back to the parent tab
# click 'Review'
## check +1 Verified
## check +2 Reviewed
## click "Publish and Submit"

You're done! The change is now merged.

=== Amending a change ===

Occasionally your change may fail a lint test, or someone may review your change and ask you to fix something. In this case, you'll need to amend your change. To do this:

# Checkout the change (you can find this line in Gerrit, on the change, in Download -> checkout, ssh):
#: git fetch ssh://<username>@gerrit.wikimedia.org:29418/operations/puppet <ref> && git checkout FETCH_HEAD
# Make changes
# Commit the change, ensuring you are amending the commit
#: git commit --amend -a
# Push the change
#: git push-for-review production

The above assumes you are pushing to the production branch, change commands appropriately for other branches.

=== Making the changes live in puppet ===

==== Test ====

Changes merged in the test branch will go live in puppet within a minute.

==== Production ====

===== Public repo =====

Changes for production need to be pulled manually; this is done for security purposes. Here's the procedure you should use:

cd ~/puppet
git fetch
git diff HEAD origin/production | less
git merge origin/production

===== Private repo =====

cd ~/private
<make changes>
git add <newfiles>
git commit -a

On commit, the changes will go live.

=== Merging changes from test into production ===

git pull
git merge --squash origin/test
git commit -a
git push-for-review-production

The above assumes you are in the production branch.

=== Merging changes from production to test ===

git pull
git merge --squash origin/production
git commit -a
git push-for-review-test

The above assumes you are in the test branch.

=== dry runs ===

git push has "--dry-run" ("will do everything except for the actually sending of the data.")
git merge has "--no-commit --no-ff"
git pull - "does not really need it ('git fetch origin', then a 'git log master..origin/master', before a git merge origin/master)"

[http://stackoverflow.com/questions/3636914/how-can-you-see-what-you-are-about-to-push-with-git],[http://stackoverflow.com/questions/2573905/do-all-git-commands-have-a-dry-run-option], [http://stackoverflow.com/questions/501407/is-there-a-git-merge-dry-run-option]

=== Books, guides, tutorials, documentation, etc. ===

* [http://gerrit.googlecode.com/svn/documentation/2.2.1/index.html Gerrit documentation]
* [http://book.git-scm.com/index.html Community git book]
* [http://www.ibm.com/developerworks/linux/library/l-git-subversion-1/ Git for Subversion users]
* [http://longair.net/blog/2009/04/16/git-fetch-and-merge/ Why to fetch/merge instead of pull]
* [http://sandofsky.com/blog/git-workflow.html Git workflow]

Revision as of 12:59, 25 October 2011

Access rights

Anonymous users

You'll need to have an account created for you. If you currently have SVN access, then you have an account, but need to have it linked to Labs. We are still working out the account activation process, but hope to have it done soon.

Logged-in users

After creating an account, you can:

Once you add a key, you'll be able to log into any existing instance in the main project testlabs: ssh <nameofinstance>. It may take up to 30 minutes for your key to be propagated to all instances.

To create instances, you'll need to have an admin add you to a project, and to the sysadmin role in that project.

You can make queries for nova resources; currently Nova instances have semantic properties enabled.

After logging in, you can also access Gerrit; if you wish to do git checkouts of the puppet repositories, you'll need to log into Gerrit, and add your SSH key there as well. Note: it would be nice if Gerrit could use LDAP for its SSH keystore, instead of its database; I've opened a bug for this, if you'd like to help, please add that feature to Gerrit!

Admins

Wiki Admin

If you are a wiki admin, you can:

Net Admins

If you are a NetAdmin, you can:

Sys Admins

If you are a sysadmin, you can:

After creating an instance, you'll get an email notifying you that it is ready to be logged into. If you did not add an SSH key prior to creating the instance, you'll need to wait until your key is propagated to the instances (which can take an additional 30 minutes).

Cloud Admins

In addition to all actions that sysadmins and netadmins, you can:

Access FAQ

  • Q: I was added to a group that gives me access to something in git, but it isn't working, what's wrong?
    • A: Once you have been added to the group, you need to log out of gerrit, then back in. Gerrit pulls its groups from LDAP, but caches them. Logging out, then back in re-synchronizes your groups, and thus clears the cache.

Git/Gerrit and the puppet repositories

Note: Push access is currently limited to staff developers and operations engineers. This will change soon. To pull the repository anonymously for read access use the following command:

git clone https://gerrit.wikimedia.org/r/p/operations/puppet

Set up your ssh key in Gerrit

Log into the web interface for gerrit. Click on Settings then SSH Public Keys then add your key.

Checking out the puppet repositories

We have the following main repositories and branches:

  • operations/puppet
    • production (HEAD)
      • used in production
    • test
      • used in the testlabs project
  • labs/private
    • master (HEAD)
      • only used in testlabs project

To check out the production branch of the puppet repo, you can clone it like so (if they're different, shell-username is your unix shell name, not the wiki username.):

git clone ssh://<shell-username>@gerrit.wikimedia.org:29418/operations/puppet.git

To check out the labs/private branch, you can clone it like so:

git clone ssh://<shell-username>@gerrit.wikimedia.org:29418/labs/private.git

Git configuration required to commit

Use git-setup

After the initial clone of the git repository, you can use the git-setup script (in the root level of the repository). It will set your user name, email, and will pull hooks required for proper use of gerrit.

...or do initial git configuration manually

First, you should set your name and email address in your local git configuration. The email address and wiki username are the same as what you use to log into this wiki:

git config --global user.email "<email-address>"
git config --global user.name "<wiki-username>"

Next you'll need to add a commit-msg hook to your local repository. This hook is required for pushing changes to the Gerrit server.

curl "https://gerrit.wikimedia.org/r/tools/hooks/commit-msg" > .git/hooks/commit-msg && chmod u+x .git/hooks/commit-msg

(*) You may need to rename "commit-msg.sample" to "commit.msg" before.

Updating your local repository

After you do the initial repository clone, git will automatically set up a remote tracking branch for you. You simply need to fetch/merge or pull:

git fetch
git diff origin/<branch>
git merge origin/<branch>

or:

git pull

Making changes

After cloning the repo, you can make changes the normal git way:

<make changes>
git add <newfiles>
git commit -a

After doing so, you'll need to push the changes for review; for instance, here's how to push to the test branch of the puppet repository:

git push ssh://<username>@gerrit.wikimedia.org:29418/operations/puppet HEAD:refs/for/test

You can shorten that by adding a remote:

git remote add puppet ssh://<username>@gerrit.wikimedia.org:29418/operations/puppet

Now you can push for review like so:

git push puppet HEAD:refs/for/test

You can shorten this further by making an alias:

git config alias.push-for-review-test "push puppet HEAD:refs/for/test"

Now you can push for review like so:

git push-for-review-test

Here's the alias for production:

git config alias.push-for-review-production "push puppet HEAD:refs/for/production"

Also, staff operations members have the ability to (but shouldn't!) skip the review step; to do so, simply do a push:

git push puppet

Here's the remotes and aliases for the private repo:

git remote add private ssh://<username>@gerrit.wikimedia.org:29418/labs/private
git config alias.push-for-review-private "push private HEAD:refs/for/master"

Review

Review your change (or someone elses!) in Gerrit.

  1. Go to https://gerrit.wikimedia.org
    • if it's your own change, you will see it listed on the first screen
    • if it's someone else's, click on 'All' then 'open' to see all unreviewed changes
  2. click on the change you want to review
  3. click on "Diff all side by side" to examine the diff
    • this will open each changed file in a new tab
  4. when you're done reviewing, go back to the parent tab
  5. click 'Review'
    1. check +1 Verified
    2. check +2 Reviewed
    3. click "Publish and Submit"

You're done! The change is now merged.

Amending a change

Occasionally your change may fail a lint test, or someone may review your change and ask you to fix something. In this case, you'll need to amend your change. To do this:

  1. Checkout the change (you can find this line in Gerrit, on the change, in Download -> checkout, ssh):
    git fetch ssh://<username>@gerrit.wikimedia.org:29418/operations/puppet <ref> && git checkout FETCH_HEAD
  2. Make changes
  3. Commit the change, ensuring you are amending the commit
    git commit --amend -a
  4. Push the change
    git push-for-review production

The above assumes you are pushing to the production branch, change commands appropriately for other branches.

Making the changes live in puppet

Test

Changes merged in the test branch will go live in puppet within a minute.

Production

Public repo

Changes for production need to be pulled manually; this is done for security purposes. Here's the procedure you should use:

cd ~/puppet
git fetch
git diff HEAD origin/production | less
git merge origin/production
Private repo
cd ~/private
<make changes>
git add <newfiles>
git commit -a

On commit, the changes will go live.

Merging changes from test into production

git pull
git merge --squash origin/test
git commit -a
git push-for-review-production

The above assumes you are in the production branch.

Merging changes from production to test

git pull
git merge --squash origin/production
git commit -a
git push-for-review-test

The above assumes you are in the test branch.

dry runs

git push has "--dry-run" ("will do everything except for the actually sending of the data.") git merge has "--no-commit --no-ff" git pull - "does not really need it ('git fetch origin', then a 'git log master..origin/master', before a git merge origin/master)"

[1],[2], [3]

Books, guides, tutorials, documentation, etc.