[flannel/f20] Initial commit to repo - resolves: #1165688
by Jan Chaloupka
commit 9418ac253f33c76063eec550b93df368cadae6bc
Author: Jan Chaloupka <jchaloup(a)redhat.com>
Date: Sat Nov 22 10:58:16 2014 +0100
Initial commit to repo
- resolves: #1165688
.gitignore | 1 +
0001-remove-third-party-dependency-on-Godeps.patch | 151 +++++++++++++++++++
flannel-slice-type.patch | 155 ++++++++++++++++++++
flannel-vxlan-subnetfix.patch | 12 ++
flannel.spec | 149 +++++++++++++++++++
flanneld.service | 15 ++
flanneld.sysconf | 12 ++
sources | 1 +
8 files changed, 496 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..28e2cf8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/flannel-071d778.tar.gz
diff --git a/0001-remove-third-party-dependency-on-Godeps.patch b/0001-remove-third-party-dependency-on-Godeps.patch
new file mode 100644
index 0000000..e2c0eb4
--- /dev/null
+++ b/0001-remove-third-party-dependency-on-Godeps.patch
@@ -0,0 +1,151 @@
+From e9097f81f65a1596ab79989de0e0ae8d0d031012 Mon Sep 17 00:00:00 2001
+From: Jan Chaloupka <jchaloup(a)redhat.com>
+Date: Wed, 19 Nov 2014 14:18:08 +0100
+Subject: [PATCH] remove third party dependency on Godeps
+
+---
+ backend/udp/cproxy.go | 2 +-
+ backend/udp/udp.go | 4 ++--
+ backend/vxlan/device.go | 6 +++---
+ backend/vxlan/vxlan.go | 4 ++--
+ main.go | 4 ++--
+ pkg/ip/iface.go | 2 +-
+ subnet/registry.go | 4 ++--
+ subnet/subnet.go | 4 ++--
+ subnet/subnet_test.go | 2 +-
+ 9 files changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/backend/udp/cproxy.go b/backend/udp/cproxy.go
+index 062d277..f1cce26 100644
+--- a/backend/udp/cproxy.go
++++ b/backend/udp/cproxy.go
+@@ -9,7 +9,7 @@ import (
+ "reflect"
+ "unsafe"
+
+- log "github.com/coreos/flannel/Godeps/_workspace/src/github.com/golang/glog"
++ log "github.com/golang/glog"
+
+ "github.com/coreos/flannel/pkg/ip"
+ )
+diff --git a/backend/udp/udp.go b/backend/udp/udp.go
+index 90f8617..782f7d3 100644
+--- a/backend/udp/udp.go
++++ b/backend/udp/udp.go
+@@ -9,8 +9,8 @@ import (
+ "sync"
+ "syscall"
+
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/vishvananda/ne..."
+- log "github.com/coreos/flannel/Godeps/_workspace/src/github.com/golang/glog"
++ "github.com/vishvananda/netlink"
++ log "github.com/golang/glog"
+
+ "github.com/coreos/flannel/backend"
+ "github.com/coreos/flannel/pkg/ip"
+diff --git a/backend/vxlan/device.go b/backend/vxlan/device.go
+index a15b067..9764189 100644
+--- a/backend/vxlan/device.go
++++ b/backend/vxlan/device.go
+@@ -7,9 +7,9 @@ import (
+ "syscall"
+ "time"
+
+- log "github.com/coreos/flannel/Godeps/_workspace/src/github.com/golang/glog"
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/vishvananda/ne..."
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/vishvananda/ne..."
++ log "github.com/golang/glog"
++ "github.com/vishvananda/netlink"
++ "github.com/vishvananda/netlink/nl"
+
+ "github.com/coreos/flannel/pkg/ip"
+ )
+diff --git a/backend/vxlan/vxlan.go b/backend/vxlan/vxlan.go
+index b47eea2..4a878ce 100644
+--- a/backend/vxlan/vxlan.go
++++ b/backend/vxlan/vxlan.go
+@@ -6,8 +6,8 @@ import (
+ "net"
+ "sync"
+
+- log "github.com/coreos/flannel/Godeps/_workspace/src/github.com/golang/glog"
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/vishvananda/ne..."
++ log "github.com/golang/glog"
++ "github.com/vishvananda/netlink"
+
+ "github.com/coreos/flannel/backend"
+ "github.com/coreos/flannel/subnet"
+diff --git a/main.go b/main.go
+index 5f81923..0955fc7 100644
+--- a/main.go
++++ b/main.go
+@@ -12,8 +12,8 @@ import (
+ "syscall"
+ "time"
+
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/coreos/go-syst..."
+- log "github.com/coreos/flannel/Godeps/_workspace/src/github.com/golang/glog"
++ "github.com/coreos/go-systemd/daemon"
++ log "github.com/golang/glog"
+
+ "github.com/coreos/flannel/backend"
+ "github.com/coreos/flannel/pkg/ip"
+diff --git a/pkg/ip/iface.go b/pkg/ip/iface.go
+index 077feec..dee69a6 100644
+--- a/pkg/ip/iface.go
++++ b/pkg/ip/iface.go
+@@ -5,7 +5,7 @@ import (
+ "net"
+ "syscall"
+
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/vishvananda/ne..."
++ "github.com/vishvananda/netlink"
+ )
+
+ func GetIfaceIP4Addr(iface *net.Interface) (net.IP, error) {
+diff --git a/subnet/registry.go b/subnet/registry.go
+index 8c6797e..ccfee74 100644
+--- a/subnet/registry.go
++++ b/subnet/registry.go
+@@ -5,8 +5,8 @@ import (
+ "sync"
+ "time"
+
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/coreos/go-etcd..."
+- log "github.com/coreos/flannel/Godeps/_workspace/src/github.com/golang/glog"
++ "github.com/coreos/go-etcd/etcd"
++ log "github.com/golang/glog"
+ )
+
+ type subnetRegistry interface {
+diff --git a/subnet/subnet.go b/subnet/subnet.go
+index 465952f..1208dfd 100644
+--- a/subnet/subnet.go
++++ b/subnet/subnet.go
+@@ -9,8 +9,8 @@ import (
+ "strconv"
+ "time"
+
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/coreos/go-etcd..."
+- log "github.com/coreos/flannel/Godeps/_workspace/src/github.com/golang/glog"
++ "github.com/coreos/go-etcd/etcd"
++ log "github.com/golang/glog"
+
+ "github.com/coreos/flannel/pkg/ip"
+ "github.com/coreos/flannel/pkg/task"
+diff --git a/subnet/subnet_test.go b/subnet/subnet_test.go
+index 803fdc7..2ee58d5 100644
+--- a/subnet/subnet_test.go
++++ b/subnet/subnet_test.go
+@@ -5,7 +5,7 @@ import (
+ "testing"
+ "time"
+
+- "github.com/coreos/flannel/Godeps/_workspace/src/github.com/coreos/go-etcd..."
++ "github.com/coreos/go-etcd/etcd"
+
+ "github.com/coreos/flannel/pkg/ip"
+ )
+--
+1.9.3
+
diff --git a/flannel-slice-type.patch b/flannel-slice-type.patch
new file mode 100644
index 0000000..0298dab
--- /dev/null
+++ b/flannel-slice-type.patch
@@ -0,0 +1,155 @@
+diff -up ./backend/alloc/alloc.go.orig ./backend/alloc/alloc.go
+--- ./backend/alloc/alloc.go.orig 2014-11-05 13:17:20.000000000 -0500
++++ ./backend/alloc/alloc.go 2014-11-07 14:12:08.879116011 -0500
+@@ -39,6 +39,7 @@ func (m *AllocBackend) Init(extIface *ne
+
+ return &backend.SubnetDef{
+ Net: sn,
++ Slice: sn,
+ MTU: extIface.MTU,
+ }, nil
+ }
+diff -up ./backend/common.go.orig ./backend/common.go
+--- ./backend/common.go.orig 2014-11-05 13:17:20.000000000 -0500
++++ ./backend/common.go 2014-11-07 14:12:08.879116011 -0500
+@@ -8,6 +8,7 @@ import (
+
+ type SubnetDef struct {
+ Net ip.IP4Net
++ Slice ip.IP4Net
+ MTU int
+ }
+
+diff -up ./backend/slice/slice.go.orig ./backend/slice/slice.go
+--- ./backend/slice/slice.go.orig 2014-11-07 14:12:08.880116040 -0500
++++ ./backend/slice/slice.go 2014-11-07 14:12:08.879116011 -0500
+@@ -0,0 +1,57 @@
++package slice
++
++import (
++ "fmt"
++ "net"
++
++ "github.com/coreos/flannel/backend"
++ "github.com/coreos/flannel/pkg/ip"
++ "github.com/coreos/flannel/pkg/task"
++ "github.com/coreos/flannel/subnet"
++)
++
++
++type SliceBackend struct {
++ sm *subnet.SubnetManager
++ stop chan bool
++}
++
++func New(sm *subnet.SubnetManager) backend.Backend {
++ return &SliceBackend{
++ sm: sm,
++ stop: make(chan bool),
++ }
++}
++
++func (m *SliceBackend) Init(extIface *net.Interface, extIP net.IP, ipMasq bool) (*backend.SubnetDef, error) {
++ attrs := subnet.LeaseAttrs{
++ PublicIP: ip.FromIP(extIP),
++ }
++
++ sl, err := m.sm.AcquireLease(&attrs, m.stop)
++ if err != nil {
++ if err == task.ErrCanceled {
++ return nil, err
++ } else {
++ return nil, fmt.Errorf("failed to acquire lease: %v", err)
++ }
++ }
++
++ return &backend.SubnetDef{
++ Net: m.sm.GetConfig().Network,
++ Slice: sl,
++ MTU: extIface.MTU,
++ }, nil
++}
++
++func (m *SliceBackend) Run() {
++ m.sm.LeaseRenewer(m.stop)
++}
++
++func (m *SliceBackend) Stop() {
++ close(m.stop)
++}
++
++func (m *SliceBackend) Name() string {
++ return "allocation"
++}
+diff -up ./backend/udp/udp.go.orig ./backend/udp/udp.go
+--- ./backend/udp/udp.go.orig 2014-11-05 13:17:20.000000000 -0500
++++ ./backend/udp/udp.go 2014-11-07 14:12:08.880116040 -0500
+@@ -97,6 +97,7 @@ func (m *UdpBackend) Init(extIface *net.
+
+ return &backend.SubnetDef{
+ Net: sn,
++ Slice: sn,
+ MTU: m.mtu,
+ }, nil
+ }
+diff -up ./main.go.orig ./main.go
+--- ./main.go.orig 2014-11-05 13:17:20.000000000 -0500
++++ ./main.go 2014-11-07 14:12:28.061657949 -0500
+@@ -22,6 +22,7 @@ import (
+ "github.com/coreos/flannel/backend/alloc"
+ "github.com/coreos/flannel/backend/udp"
+ "github.com/coreos/flannel/backend/vxlan"
++ "github.com/coreos/flannel/backend/slice"
+ )
+
+ type CmdLineOpts struct {
+@@ -71,7 +72,7 @@ func flagsFromEnv(prefix string, fs *fla
+ func writeSubnetFile(sn *backend.SubnetDef) error {
+ // Write out the first usable IP by incrementing
+ // sn.IP by one
+- sn.Net.IP += 1
++ sn.Net.IP = sn.Slice.IP + 1
+
+ dir, _ := path.Split(opts.subnetFile)
+ os.MkdirAll(dir, 0755)
+@@ -88,6 +89,9 @@ func writeSubnetFile(sn *backend.SubnetD
+ if _, err = fmt.Fprintf(f, "FLANNEL_MTU=%d\n", sn.MTU); err != nil {
+ return err
+ }
++ if _, err = fmt.Fprintf(f, "FLANNEL_SLICE=%s\n", sn.Slice); err != nil {
++ return err
++ }
+ return nil
+ }
+
+@@ -162,6 +166,8 @@ func newBackend() (backend.Backend, erro
+ return alloc.New(sm), nil
+ case "vxlan":
+ return vxlan.New(sm, config.Backend), nil
++ case "slice":
++ return slice.New(sm), nil
+ default:
+ return nil, fmt.Errorf("'%v': unknown backend type", bt.Type)
+ }
+diff -up ./README.md.orig ./README.md
+--- ./README.md.orig 2014-11-05 13:17:20.000000000 -0500
++++ ./README.md 2014-11-07 14:12:08.879116011 -0500
+@@ -76,6 +76,9 @@ of available backends and the keys that
+ * ```Type``` (string): ```vxlan```
+ * ```VNI``` (number): VXLAN Identifier (VNI) to be used. Defaults to 1
+
++* slice: similar to alloc, but allocate only a slice of the larger subnet (effects FLANNEL_SUBNET value)
++ * ```Type``` (string): ```slice```
++
+ ### Example configuration JSON
+
+ The following configuration illustrates the use of most options.
+@@ -134,7 +137,7 @@ a file, the script starting Docker daemo
+
+ ```bash
+ source /run/flannel/subnet.env
+-docker -d --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}
++docker -d --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} --fixed-cidr=${FLANNEL_SLICE}
+ ```
+
+ Systemd users can use ```EnvironmentFile``` directive in the .service file to pull in ```/run/flannel/subnet.env```
diff --git a/flannel-vxlan-subnetfix.patch b/flannel-vxlan-subnetfix.patch
new file mode 100644
index 0000000..7832d20
--- /dev/null
+++ b/flannel-vxlan-subnetfix.patch
@@ -0,0 +1,12 @@
+diff -up ./backend/vxlan/vxlan.go.orig ./backend/vxlan/vxlan.go
+--- ./backend/vxlan/vxlan.go.orig 2014-11-05 13:17:20.000000000 -0500
++++ ./backend/vxlan/vxlan.go 2014-11-07 15:01:29.107694323 -0500
+@@ -108,7 +108,7 @@ func (vb *VXLANBackend) Init(extIface *n
+ return nil, err
+ }
+
+- return &backend.SubnetDef{sn, vb.dev.MTU()}, nil
++ return &backend.SubnetDef{sn, sn, vb.dev.MTU()}, nil
+ }
+
+ func (vb *VXLANBackend) Run() {
diff --git a/flannel.spec b/flannel.spec
new file mode 100644
index 0000000..a3cbcb4
--- /dev/null
+++ b/flannel.spec
@@ -0,0 +1,149 @@
+%global debug_package %{nil}
+%global provider github
+%global provider_tld com
+%global project coreos
+%global repo flannel
+%global import_path %{provider}.%{provider_tld}/%{project}/%{repo}
+%global commit 071d7786cfae6a9ef6f8b83a60858d34aa8f8749
+%global shortcommit %(c=%{commit}; echo ${c:0:7})
+
+Name: flannel
+Version: 0.1.0
+Release: 7.git%{shortcommit}%{?dist}
+Summary: Etcd address management agent for overlay networks
+License: ASL 2.0
+URL: https://%{import_path}
+Source0: https://%{import_path}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
+Source1: flanneld.service
+Source2: flanneld.sysconf
+ExclusiveArch: %{ix86} x86_64 %{arm}
+
+Patch0: flannel-slice-type.patch
+Patch1: flannel-vxlan-subnetfix.patch
+Patch2: 0001-remove-third-party-dependency-on-Godeps.patch
+
+BuildRequires: golang >= 1.2.7
+BuildRequires: golang-cover
+BuildRequires: golang(github.com/coreos/go-systemd) >= 2-2
+BuildRequires: golang(github.com/coreos/go-etcd)
+BuildRequires: golang(github.com/golang/glog)
+BuildRequires: golang(github.com/vishvananda/netns)
+BuildRequires: golang(github.com/vishvananda/netlink)
+BuildRequires: pkgconfig(systemd)
+Requires: pkgconfig(systemd)
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+
+%description
+Flannel is an etcd driven address management agent. Most commonly it is used to
+manage the ip addresses of overlay networks between systems running containers
+that need to communicate with one another.
+
+%package devel
+BuildRequires: golang >= 1.2.7
+BuildRequires: golang-cover
+BuildRequires: golang(github.com/coreos/go-systemd) >= 2-2
+BuildRequires: golang(github.com/coreos/go-etcd)
+BuildRequires: golang(github.com/golang/glog)
+BuildRequires: golang(github.com/vishvananda/netns)
+BuildRequires: golang(github.com/vishvananda/netlink)
+BuildRequires: pkgconfig(systemd)
+Requires: golang >= 1.2.7
+Requires: golang-cover
+Requires: golang(github.com/coreos/go-systemd) >= 2-2
+Requires: golang(github.com/coreos/go-etcd)
+Requires: golang(github.com/golang/glog)
+Requires: golang(github.com/vishvananda/netns)
+Requires: golang(github.com/vishvananda/netlink)
+Summary: %{summary}
+Provides: golang(%{import_path}/subnet) = %{version}-%{release}
+Provides: golang(%{import_path}/pkg/ip) = %{version}-%{release}
+Provides: golang(%{import_path}/backend) = %{version}-%{release}
+Provides: golang(%{import_path}/backend/vxlan) = %{version}-%{release}
+Provides: golang(%{import_path}/backend/udp) = %{version}-%{release}
+Provides: golang(%{import_path}/backend/alloc) = %{version}-%{release}
+
+%description devel
+Flannel is an etcd driven address management agent. Most commonly it is used to
+manage the ip addresses of overlay networks between systems running containers
+that need to communicate with one another.
+
+This package contains library source intended for
+building other packages which use %{project}/%{repo}.
+
+%prep
+%setup -q -n %{repo}-%{commit}
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+
+%build
+rm -rf Godeps
+
+mkdir _build
+pushd _build
+ mkdir -p src/github.com/coreos
+ ln -s $(dirs +1 -l) src/github.com/coreos/flannel
+popd
+
+mkdir bin
+GOPATH=${PWD}/_build:%{gopath} go build -o bin/flanneld .
+
+%install
+# package with binary
+install -D -p -m 755 bin/flanneld %{buildroot}%{_bindir}/flanneld
+install -D -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/flanneld.service
+install -D -p -m 644 %{SOURCE2} %{buildroot}/etc/sysconfig/flanneld
+# devel package
+install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
+cp -pav {backend,pkg,subnet} %{buildroot}/%{gopath}/src/%{import_path}/
+
+%post
+%systemd_post flanneld.service
+
+%preun
+# clean tempdir and workdir on removal or upgrade
+%systemd_preun flanneld.service
+
+%postun
+%systemd_postun_with_restart flanneld.service
+
+%files
+%doc CONTRIBUTING.md LICENSE MAINTAINERS README.md DCO NOTICE
+%{_bindir}/flanneld
+%{_unitdir}/flanneld.service
+%config(noreplace) %{_sysconfdir}/sysconfig/flanneld
+
+%files devel
+%doc CONTRIBUTING.md LICENSE MAINTAINERS README.md DCO NOTICE
+%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
+%dir %{gopath}/src/%{import_path}/
+%{gopath}/src/%{import_path}/
+
+%changelog
+* Thu Nov 20 2014 jchaloup <jchaloup(a)redhat.com> - 0.1.0-7.git071d778
+- Removing deps on Godeps and adding deps on golang-github packages
+- Removing wait-online service and changing Type of flannel.service from simple to notify
+- Adding README and other doc files
+- Adding spec file header with commit, import_path, ...
+- Adding devel subpackage
+- spec polished based on Lokesh' notes (3 lines below)
+- modify summary in specfile as in bug description (capitalize if needed)
+- might need to enforce NVR for coreos/go-systemd in deps
+- pkgconfig(systemd) is preferable to systemd in BR (I think)
+ resolves: #1165688
+
+* Fri Nov 07 2014 - Neil Horman <nhoramn(a)tuxdriver.com>
+- Updating to latest upstream
+
+* Fri Nov 07 2014 - Neil Horman <nhoramn(a)tuxdriver.com>
+- Added wait-online service to sync with docker
+
+* Thu Nov 06 2014 - Neil Horman <nhoramn(a)tuxdriver.com>
+- Fixed flanneld.service file
+- Added linvilles slice type patch
+
+* Tue Nov 04 2014 - Neil Horman <nhorman(a)tuxdriver.com> - 0.1.0-20141104gitdc530ce
+- Initial Build
+
diff --git a/flanneld.service b/flanneld.service
new file mode 100644
index 0000000..8df5713
--- /dev/null
+++ b/flanneld.service
@@ -0,0 +1,15 @@
+#Systemd unit file for running flanneld
+
+ [Unit]
+Description=Flanneld overlay address etcd agent
+After=network.target
+
+[Service]
+Type=simple
+EnvironmentFile=/etc/sysconfig/flanneld
+ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD} -etcd-prefix=${FLANNEL_ETCD_KEY}
+
+
+[Install]
+WantedBy=docker.service
+
diff --git a/flanneld.sysconf b/flanneld.sysconf
new file mode 100644
index 0000000..082e335
--- /dev/null
+++ b/flanneld.sysconf
@@ -0,0 +1,12 @@
+# Flanneld configuration options
+
+# etcd url location. Point this to the server where etcd runs
+FLANNEL_ETCD="http://127.0.0.1:4001"
+
+# etcd config key. This is the configuration key that flannel queries
+# For address range assignment
+FLANNEL_ETCD_KEY="/coreos.com/network"
+
+# Any additional options that you want to pass
+#FLANNEL_OPTIONS=""
+
diff --git a/sources b/sources
index e69de29..8c351cc 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+e5dedc1a99e8531ef6a7bd968f89f8f6 flannel-071d778.tar.gz
9 years, 7 months