introducing gitfs

71
developers users

Upload: temian-vlad

Post on 16-Jul-2015

341 views

Category:

Technology


0 download

TRANSCRIPT

| open source

developers users

| open source

whoamiand what do I do

| open source

| open source

| open source

the problemproblem?

| open source

once upon a time...

| open source

in one student dorm

| open source

| open source

| open source

CHAOS!

| open source

| open source

introducing gitfs

| open source

gitfswhat is it?

| open source

demo

gitfs

| open source

easy!as 1, 2, 3

gitfs

| open source gitfs

| open source

open-source

gitfs

| open source

how was it made?

gitfs

| open source

research

gitfs

| open source

for git

gitfs

| open source

git = pygit2

gitfs

| open source

from pygit2 import clone_repository, Keypair

| open source

from pygit2 import clone_repository, Keypair

credentials = Keypair("git", "/home/wok/.ssh/ unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")

gitfs

| open source

from pygit2 import clone_repository, Keypair

credentials = Keypair("git", "/home/wok/.ssh/ unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")

repository = clone_repository("[email protected]:vtemian/gitfs-demo","/home/wok/gitfs-demo", credentials=credentials)

gitfs

| open source

from pygit2 import clone_repository, Keypair

credentials = Keypair("git", "/home/wok/.ssh/ unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")

repository = clone_repository("[email protected]:vtemian/gitfs-demo","/home/wok/gitfs-demo", credentials=credentials)

remote = [remote for remote in repo.remotes if remote.name == "origin"] remote[0].credentials = credentials

gitfs

| open source

from pygit2 import clone_repository, Keypair

credentials = Keypair("git", "/home/wok/.ssh/ unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")

repository = clone_repository("[email protected]:vtemian/gitfs-demo","/home/wok/gitfs-demo", credentials=credentials)

remote = [remote for remote in repo.remotes if remote.name == "origin"] remote[0].credentials = credentials remote[0].push("refs/heads/master")

gitfs

| open source

for the file system

gitfs

| open source

file system = fusepy

gitfs

| open source

class Memory(Operations):

gitfs

| open source

class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd

gitfs

| open source

class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd

def read(self, path, size, offset, fh): return self.data[path][offset:offset + size]

gitfs

| open source

class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd

def read(self, path, size, offset, fh): return self.data[path][offset:offset + size]

def rename(self, old, new): self.files[new] = self.files.pop(old)

gitfs

| open source

class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd

def read(self, path, size, offset, fh): return self.data[path][offset:offset + size]

def rename(self, old, new): self.files[new] = self.files.pop(old)

def rmdir(self, path): self.files.pop(path) self.files['/']['st_nlink'] -= 1

gitfs

| open source

class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd

def read(self, path, size, offset, fh): return self.data[path][offset:offset + size]

def rename(self, old, new): self.files[new] = self.files.pop(old)

def rmdir(self, path): self.files.pop(path) self.files['/']['st_nlink'] -= 1

def write(self, path, data, offset, fh): self.data[path] = self.data[path][:offset] + data self.files[path]['st_size'] = len(self.data[path]) return len(data)

gitfs

| open source

first iteration

gitfs

| open source

very dirty

def rename(self, old, new): if "history" in old or new: # raise EROFS elif old == "/" or new == "/": # raise EROFS else: # do the actual rename

gitfs

| open source

second iteration

gitfs

| open source

read()

Router

CurrentView HistoryView CommitView IndexView

gitfs

| open source

read('/history/2014-10-18/14-01-04-fg34asc4/Readme.md')

CommitView

gitfs

| open source

back to the drawing board

>$ █gitfs

| open source

upstream synchronization

gitfs

| open source

solve conflicts

gitfs

| open source

solve conflicts

1 2 37 8

4 5 6remote

local

gitfs

| open source

1 2 3 4 5 6merging_remote

1 2 3 7 8merging_local

gitfs

solve conflicts

| open source

1 2 3 4 5 7'6 8'merging_remote

1 2 3 7 8merging_local

gitfs

solve conflicts

| open source

1 2 3 4 5 7'6 8'local

gitfs

solve conflicts

| open source

back to the drawing board

>$ █gitfs

| open source

third iteration

gitfs

| open source

cache

gitfs

| open source

back to the drawing board

>$ █gitfs

| open source

upstream synchronization

gitfs

| open source

Fuse threads

gitfs

| open source

Fuse threads

commits

gitfs

| open source

Fuse threads Commit queue

commits

gitfs

| open source

Fuse threads Commit queue Sync worker

commits

gitfs

| open source

Fuse threads Commit queue Sync worker

commits

want to sync

don't open for write

gitfs

| open source

Fuse threads Commit queue Sync worker

commits

commit

want to sync

don't open for write

gitfs

| open source

Fuse threads Commit queue Sync worker

commits

commit

want to sync

sync done

don't open for write

gitfs

| open source

Fuse threads Commit queue Sync worker Fetch worker

commits

commit

want to sync

sync done

don't open for write

FETCH

FETCH

FETCH

gitfs

| open source

Fuse threads Commit queue Sync worker Fetch worker

commits

commit

want to sync

sync done

don't open for write

Nothing happens FETCH

FETCH

FETCH

gitfs

| open source

Fuse threads Commit queue Sync worker Fetch worker

commits

commit

want to sync

sync done

don't open for write

Nothing happens

Nothing happens but somebody is still writing

FETCH

FETCH

FETCH

gitfs

| open source

Fuse threads Commit queue Sync worker Fetch worker

commits

commit

want to sync

sync done

don't open for write

Nothing happens

Nothing happens but somebody is still writing

Nothing happens but somebody is still writing so we can merge and push

FETCH

FETCH

FETCH

gitfs

| open source

back to the drawing board

>$ █gitfs

| open source

pytest

gitfs

| open source

$ sudo add-apt-repository ppa:presslabs/gitfs $ sudo apt-get update $ sudo apt-get install gitfs

gitfs

| open source

720 commits4215 lines of code187 tests

4 contributers 3½ months

| open source

github.com/PressLabs/gitfs

| open source

inspiration

| open source

Q/A?

| open source

thank you

| open source