commit c2c0918eb5533cc849c6636ab4561fa80e97ba44
Author: Lokesh Mandvekar <lsm5(a)fedoraproject.org>
Date: Tue Dec 2 09:33:43 2014 -0800
Resolves: rhbz#1169151, rhbz#1169334
NVR: docker-io-1.3.2-4.git353ff40
Signed-off-by: Lokesh Mandvekar <lsm5(a)fedoraproject.org>
docker-io.spec | 7 ++-
initialize-db.patch | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 158 insertions(+), 1 deletions(-)
---
diff --git a/docker-io.spec b/docker-io.spec
index 47d136f..7cd775e 100644
--- a/docker-io.spec
+++ b/docker-io.spec
@@ -16,7 +16,7 @@
Name: %{repo}-io
Version: 1.3.2
-Release: 3.git%{shortcommit}%{?dist}
+Release: 4.git%{shortcommit}%{?dist}
Summary: Automates deployment of containerized applications
License: ASL 2.0
URL:
http://www.docker.com
@@ -27,6 +27,7 @@ Source0:
https://%{import_path}/archive/%{commit}/%{repo}-%{shortcommit}.tar.
Source1: %{repo}.service
Source2: %{repo}.sysconfig
Source3: %{repo}-storage.sysconfig
+Patch0: initialize-db.patch
BuildRequires: glibc-static
BuildRequires: golang >= 1.3.3
# for gorilla/mux and kr/pty
https://github.com/dotcloud/docker/pull/5950
@@ -191,6 +192,7 @@ The import paths of import_path/pkg/...
%prep
%setup -qn %{repo}-%{commit}
+%patch0 -p1
rm -rf
vendor/src/github.com/{coreos,godbus,gorilla,kr,Sirupsen,syndtr,tchap}
find . -name "*.go" \
-print |\
@@ -313,6 +315,9 @@ exit 0
%{gopath}/src/%{import_path}/pkg/*
%changelog
+* Tue Dec 02 2014 Lokesh Mandvekar <lsm5(a)fedoraproject.org> - 1.3.2-4.git353ff40
+- Resolves: rhbz#1169151, rhbz#1169334
+
* Sun Nov 30 2014 Lokesh Mandvekar <lsm5(a)fedoraproject.org> - 1.3.2-3.git353ff40
- Resolves: rhbz#1169035, rhbz#1169151
- bring back golang deps (except libcontainer)
diff --git a/initialize-db.patch b/initialize-db.patch
new file mode 100644
index 0000000..69949a7
--- /dev/null
+++ b/initialize-db.patch
@@ -0,0 +1,152 @@
+From fb06e1c6ebcf5408e6a7d0bfcf9264571eab69a1 Mon Sep 17 00:00:00 2001
+From: Erik Hollensbe <github(a)hollensbe.org>
+Date: Tue, 2 Dec 2014 03:02:25 -0800
+Subject: [PATCH] graphdb: initialize the database semi-idempotently on every
+ connection.
+
+Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github(a)hollensbe.org> (github:
erikh)
+---
+ pkg/graphdb/conn_sqlite3.go | 18 +-----------
+ pkg/graphdb/graphdb.go | 68 ++++++++++++++++++++++++++-------------------
+ pkg/graphdb/graphdb_test.go | 2 +-
+ 3 files changed, 41 insertions(+), 47 deletions(-)
+
+diff --git a/pkg/graphdb/conn_sqlite3.go b/pkg/graphdb/conn_sqlite3.go
+index b6a8027..455790a 100644
+--- a/pkg/graphdb/conn_sqlite3.go
++++ b/pkg/graphdb/conn_sqlite3.go
+@@ -4,31 +4,15 @@ package graphdb
+
+ import (
+ "database/sql"
+- "os"
+
+ _ "code.google.com/p/gosqlite/sqlite3" // registers sqlite
+ )
+
+ func NewSqliteConn(root string) (*Database, error) {
+- initDatabase := false
+-
+- stat, err := os.Stat(root)
+- if err != nil {
+- if os.IsNotExist(err) {
+- initDatabase = true
+- } else {
+- return nil, err
+- }
+- }
+-
+- if stat != nil && stat.Size() == 0 {
+- initDatabase = true
+- }
+-
+ conn, err := sql.Open("sqlite3", root)
+ if err != nil {
+ return nil, err
+ }
+
+- return NewDatabase(conn, initDatabase)
++ return NewDatabase(conn)
+ }
+diff --git a/pkg/graphdb/graphdb.go b/pkg/graphdb/graphdb.go
+index 450bd50..6234203 100644
+--- a/pkg/graphdb/graphdb.go
++++ b/pkg/graphdb/graphdb.go
+@@ -73,45 +73,55 @@ func IsNonUniqueNameError(err error) bool {
+ }
+
+ // Create a new graph database initialized with a root entity
+-func NewDatabase(conn *sql.DB, init bool) (*Database, error) {
++func NewDatabase(conn *sql.DB) (*Database, error) {
+ if conn == nil {
+ return nil, fmt.Errorf("Database connection cannot be nil")
+ }
+ db := &Database{conn: conn}
+
+- if init {
+- if _, err := conn.Exec(createEntityTable); err != nil {
+- return nil, err
+- }
+- if _, err := conn.Exec(createEdgeTable); err != nil {
+- return nil, err
+- }
+- if _, err := conn.Exec(createEdgeIndices); err != nil {
+- return nil, err
+- }
++ if _, err := conn.Exec(createEntityTable); err != nil {
++ return nil, err
++ }
++ if _, err := conn.Exec(createEdgeTable); err != nil {
++ return nil, err
++ }
++ if _, err := conn.Exec(createEdgeIndices); err != nil {
++ return nil, err
++ }
+
+- rollback := func() {
+- conn.Exec("ROLLBACK")
+- }
++ rollback := func() {
++ conn.Exec("ROLLBACK")
++ }
+
+- // Create root entities
+- if _, err := conn.Exec("BEGIN"); err != nil {
+- return nil, err
+- }
+- if _, err := conn.Exec("INSERT INTO entity (id) VALUES (?);",
"0"); err != nil {
+- rollback()
+- return nil, err
+- }
++ // Create root entities
++ if _, err := conn.Exec("BEGIN"); err != nil {
++ return nil, err
++ }
+
+- if _, err := conn.Exec("INSERT INTO edge (entity_id, name) VALUES(?,?);",
"0", "/"); err != nil {
+- rollback()
+- return nil, err
+- }
++ if _, err := conn.Exec("DELETE FROM entity where id = ?", "0"); err
!= nil {
++ rollback()
++ return nil, err
++ }
+
+- if _, err := conn.Exec("COMMIT"); err != nil {
+- return nil, err
+- }
++ if _, err := conn.Exec("INSERT INTO entity (id) VALUES (?);", "0");
err != nil {
++ rollback()
++ return nil, err
++ }
++
++ if _, err := conn.Exec("DELETE FROM edge where entity_id=? and name=?",
"0", "/"); err != nil {
++ rollback()
++ return nil, err
+ }
++
++ if _, err := conn.Exec("INSERT INTO edge (entity_id, name) VALUES(?,?);",
"0", "/"); err != nil {
++ rollback()
++ return nil, err
++ }
++
++ if _, err := conn.Exec("COMMIT"); err != nil {
++ return nil, err
++ }
++
+ return db, nil
+ }
+
+diff --git a/pkg/graphdb/graphdb_test.go b/pkg/graphdb/graphdb_test.go
+index 7568e66..f228285 100644
+--- a/pkg/graphdb/graphdb_test.go
++++ b/pkg/graphdb/graphdb_test.go
+@@ -14,7 +14,7 @@ import (
+ func newTestDb(t *testing.T) (*Database, string) {
+ p := path.Join(os.TempDir(), "sqlite.db")
+ conn, err := sql.Open("sqlite3", p)
+- db, err := NewDatabase(conn, true)
++ db, err := NewDatabase(conn)
+ if err != nil {
+ t.Fatal(err)
+ }