Upgrade to Pro — share decks privately, control downloads, hide ads and more …

なめらかにGHEに移行する方法

 なめらかにGHEに移行する方法

GHEのリポジトリと既存のリポジトリをうまく共存する方法について解説します

hakobe (Yohei Fushii)

January 23, 2013
Tweet

More Decks by hakobe (Yohei Fushii)

Other Decks in Technology

Transcript

  1. Gradual Transition
    to GitHub Enterprise
    hakobe (Yohei Fushii)
    1
    ͳΊΒ͔ʹ()&ʹҠߦ͢Δํ๏

    View full-size slide

  2. • @hakobe / id:hakobe932
    • Yohei Fushii
    • Web Engineer
    ‣Perl/JavaScript/Objective-C/Java
    ‣Hatena-Bookmark
    ‣GitHub Enterprise maintenance
    Self Introduction

    View full-size slide

  3. Why do we need
    Gradual Transition?
    ͳΜͰͳΊΒ͔ʹҠߦ͠ͳ͍ͱ
    ͍͚ͳ͍ͷ

    View full-size slide

  4. ྺ࢙తܦҢ
    Historical
    background!

    View full-size slide

  5. Git @ Hatena Inc.
    •Switched from SVN around 2008/05
    •Over 700 repositories
    • projects/submodules/server configs/
    experiments etc...
    •Self hosting
    • Every alive developing projects
    uses Git.

    View full-size slide

  6. Workflow around Git
    •Repository viewers (in-house)
    • Neo Ashika
    • Hatena::CodeFridge
    ‣Git repos. browser
    ‣Task management system
    •Blog-based Groupware
    • Hatena::Group

    View full-size slide

  7. But ...
    This is GitHub era..

    View full-size slide

  8. I want to make a
    Pull Request!

    View full-size slide

  9. has been a
    GitHub Enterprise
    User

    View full-size slide

  10. Problems
    •We cannot move all projects to GHE
    • We have over 700 repositories
    • To choose projects to move is difficult
    and boring...
    •Some teams do not want GHE

    We need a way
    to Switch to GHE Gradually

    View full-size slide

  11. Goals
    •Both GHE and existing repos can be
    used for production.
    •Anyone can start using GHE easily.
    •GHE failure should not cause to
    stop deployment.

    View full-size slide

  12. GHE Server
    •Spec
    • VMWare ESXi
    • Active/Standby configuration
    • 8 core/500GB SSD
    • High-spec!

    View full-size slide

  13. Before GHE
    16
    developer
    developer
    developer
    git push
    git push
    git push
    Hatena
    Repos Server
    App server
    deploy
    3FQPT"
    3FQPT#

    View full-size slide

  14. After GHE

    developer
    developer
    developer
    git push
    git push
    git push
    GHE
    Mirroring
    App server
    deploy
    Hatena
    Repos Server
    3FQPT"
    3FQPT#
    3FQPT"

    View full-size slide

  15. Mirroring

    developer
    git push
    Hatena
    Repos
    GHE
    ghm
    (later)
    Web Hook
    call
    git remote update
    replace all refs
    by git remote update
    Mirrors changes on GHE to Hatena’s Repos

    View full-size slide

  16. Setting up Mirroring
    1.Register Hatena repos
    and GHE repos as a Mirroring Pair
    2.Set mirroring config to Hatena repos
    3.Set push-denial hook to Hatena repos
    4.Register WebHook for mirroring to
    GHE repos

    View full-size slide

  17. 1. Register Hatena repos and
    GHE repos as a Mirroring Pair
    •Mirroring Pair

    hatena.repos:/path/to/projects/Hatena-Bookmark.git
    ghe.repos/hatena/Hatena-Bookmark.git
    [email protected]
    Register the mirroring pair to ghm (next).
    [email protected]
    .JSSPS

    View full-size slide

  18. ghm
    •in-house Web Application for
    mirroring pairs management
    • Stores mirroring pairs
    • Has WebHook API that invoke mirroring
    (later)
    • Provides some APIs

    View full-size slide

  19. 2. Set mirroring config to
    Hatena repos
    • refs/ on the remote will be directly mirrored
    into refs/
    → “git remote update“ replaces everything
    under refs/ by GHE repos’s refs/
    • This is the same as “git clone --mirror”

    [remote "origin"]
    fetch = +refs/*:refs/*
    mirror = true
    url = [email protected]:/hatena/Hatena-Bookmark
    DPOpH!NJSSPSETU )BUFOB`TSFQPT

    View full-size slide

  20. • “git remote update” destroy changes in dst
    repos(Hatena repos)
    • Confirm the repos has mirroring config at pre-
    receive hook by ghm API
    3. Set push-denial hook to
    Hatena repos

    http://ghm/api/repos?mirror=projects/Hatena-Bookmark
    HINSFQPT"1*
    Returns repos info if the repos pair is registered.

    View full-size slide

  21. • “git remote update” replaces dst(Hatena repos)
    contents by latest src(GHE repos) contents
    4.Register WebHook for
    mirroring to GHE repos

    ssh hatena.repos.host \
    'env GIT_DIR="/path/to/HatenaBookmark.git" git remote update'
    HIN8FC)PPL"1*SVOT

    View full-size slide

  22. Mirroring behavior

    developer
    git push
    Hatena
    Repos
    GHE
    ghm
    Web Hook
    call
    git remote update
    replace all refs
    by git remote update

    View full-size slide

  23. Mirroring settings are
    too difficult to me..
    ϛϥʔϦϯάͷઃఆ΍΍͗͜͢͠ΔͩΖ

    View full-size slide

  24. git-hatena
    •repository setting tools
    • git hatena mirror
    ‣Set up mirroring
    • git hatena sync
    ‣Change current repository setting
    • Easy install (1file & few dependencies)

    View full-size slide

  25. git hatena mirror
    • Automatic settings for mirroring and
    project generation

    $ git hatena mirror \
    hatena/Hatena-Bookmark projects/Hatena-Bookmark
    hatena.repos:/path/to/projects/Hatena-Bookmark.git
    ghe.repos/hatena/Hatena-Bookmark.git
    .JSSPS

    View full-size slide

  26. git hatena sync
    • Reflect the mirroring setting to local
    repository setting
    ‣ghm API can returns corresponding
    repos of mirroring pairs

    $ cd /path/to/local/repos
    $ git hatena sync

    View full-size slide

  27. Goals & Solutions
    •Both GHE and existing repos can be
    used for production.
    → mirroring
    •Anyone can start using GHE easily
    → git-hatena
    •GHE failure should not cause to stop
    deployment.
    → mirroring, rich server

    View full-size slide

  28. GHE and Hatena
    •from 2012/8
    •80% teams are using GHE
    •25% active repositories are on GHE
    • many submodules are’t on GHE
    • Gradually increasing

    View full-size slide

  29. Dev flow workshop (in-house)
    •We are GHE newbies
    •Sharing the workflow of development
    • from spec definition to production release
    • Issues, Pull Request, Code Review, Test, CI,
    deploy, etc...

    View full-size slide

  30. Conclusion
    •git and Hatena
    • We are heavy git users
    • 700 over repositories
    •Environment for Gradual Switches
    • Mirroring (ghm)
    • Automation tool (git-hatena)
    • High-spec server
    •GHE and Hatena

    View full-size slide