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 Slide

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

    View Slide

  3. ژ౎

    View Slide

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

    View Slide

  5. ྺ࢙తܦҢ
    Historical
    background!

    View Slide

  6. 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 Slide

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

    View Slide

  8. View Slide

  9. View Slide

  10. But ...
    This is GitHub era..

    View Slide

  11. I want to make a
    Pull Request!

    View Slide

  12. has been a
    GitHub Enterprise
    User

    View Slide

  13. 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 Slide

  14. 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 Slide

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

    View Slide

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

    View Slide

  17. After GHE

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

    View Slide

  18. 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 Slide

  19. 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 Slide

  20. 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 Slide

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

    View Slide

  22. View Slide

  23. 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 Slide

  24. • “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 Slide

  25. • “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 Slide

  26. Mirroring behavior

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

    View Slide

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

    View Slide

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

    View Slide

  29. 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 Slide

  30. 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 Slide

  31. 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 Slide

  32. 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 Slide

  33. 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 Slide

  34. 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 Slide