[lxc-devel] [lxd/master] migration: Keep snapshot timestamps in migration

stgraber on Github lxc-bot at linuxcontainers.org
Sat Mar 24 22:53:45 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180324/71b25f16/attachment.bin>
-------------- next part --------------
From 05211aa4a9cc554a2edb4c7f85564084be797545 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sat, 24 Mar 2018 18:51:53 -0400
Subject: [PATCH] migration: Keep snapshot timestamps in migration
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4362

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/db/containers.go        |   9 ++-
 lxd/migrate_container.go    |   5 ++
 lxd/migration/migrate.pb.go | 133 +++++++++++++++++++++++++-------------------
 lxd/migration/migrate.proto |  12 ++--
 lxd/storage_migration.go    |  13 ++++-
 5 files changed, 107 insertions(+), 65 deletions(-)

diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index 4712246ba..4cfa83d1b 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -447,8 +447,13 @@ func (c *Cluster) ContainerCreate(args ContainerArgs) (int, error) {
 		statefulInt = 1
 	}
 
-	args.CreationDate = time.Now().UTC()
-	args.LastUsedDate = time.Unix(0, 0).UTC()
+	if args.CreationDate.IsZero() {
+		args.CreationDate = time.Now().UTC()
+	}
+
+	if args.LastUsedDate.IsZero() {
+		args.LastUsedDate = time.Unix(0, 0).UTC()
+	}
 
 	str := fmt.Sprintf("INSERT INTO containers (node_id, name, architecture, type, ephemeral, creation_date, last_use_date, stateful) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")
 	stmt, err := tx.Prepare(str)
diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go
index 4618d704d..9e1bd8aca 100644
--- a/lxd/migrate_container.go
+++ b/lxd/migrate_container.go
@@ -101,6 +101,9 @@ func snapshotToProtobuf(c container) *migration.Snapshot {
 	arch := int32(c.Architecture())
 	stateful := c.IsStateful()
 
+	creationDate := c.CreationDate().UTC().Unix()
+	lastUsedDate := c.LastUsedDate().UTC().Unix()
+
 	return &migration.Snapshot{
 		Name:         &parts[len(parts)-1],
 		LocalConfig:  config,
@@ -109,6 +112,8 @@ func snapshotToProtobuf(c container) *migration.Snapshot {
 		LocalDevices: devices,
 		Architecture: &arch,
 		Stateful:     &stateful,
+		CreationDate: &creationDate,
+		LastUsedDate: &lastUsedDate,
 	}
 }
 
diff --git a/lxd/migration/migrate.pb.go b/lxd/migration/migrate.pb.go
index 9e9f4a465..ad752ff8e 100644
--- a/lxd/migration/migrate.pb.go
+++ b/lxd/migration/migrate.pb.go
@@ -220,6 +220,8 @@ type Snapshot struct {
 	LocalDevices     []*Device `protobuf:"bytes,5,rep,name=localDevices" json:"localDevices,omitempty"`
 	Architecture     *int32    `protobuf:"varint,6,req,name=architecture" json:"architecture,omitempty"`
 	Stateful         *bool     `protobuf:"varint,7,req,name=stateful" json:"stateful,omitempty"`
+	CreationDate     *int64    `protobuf:"varint,8,req,name=creation_date,json=creationDate" json:"creation_date,omitempty"`
+	LastUsedDate     *int64    `protobuf:"varint,9,req,name=last_used_date,json=lastUsedDate" json:"last_used_date,omitempty"`
 	XXX_unrecognized []byte    `json:"-"`
 }
 
@@ -277,6 +279,20 @@ func (m *Snapshot) GetStateful() bool {
 	return false
 }
 
+func (m *Snapshot) GetCreationDate() int64 {
+	if m != nil && m.CreationDate != nil {
+		return *m.CreationDate
+	}
+	return 0
+}
+
+func (m *Snapshot) GetLastUsedDate() int64 {
+	if m != nil && m.LastUsedDate != nil {
+		return *m.LastUsedDate
+	}
+	return 0
+}
+
 type MigrationHeader struct {
 	Fs               *MigrationFSType `protobuf:"varint,1,req,name=fs,enum=migration.MigrationFSType" json:"fs,omitempty"`
 	Criu             *CRIUType        `protobuf:"varint,2,opt,name=criu,enum=migration.CRIUType" json:"criu,omitempty"`
@@ -567,61 +583,64 @@ func init() {
 func init() { proto.RegisterFile("lxd/migration/migrate.proto", fileDescriptor0) }
 
 var fileDescriptor0 = []byte{
-	// 894 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x5b, 0x6f, 0xdb, 0x36,
-	0x14, 0x9e, 0x64, 0xf9, 0xa2, 0x23, 0x3b, 0x75, 0xd9, 0x60, 0x10, 0xda, 0x5d, 0x3c, 0xb5, 0xc3,
-	0x3c, 0x3f, 0x24, 0x9d, 0x8b, 0x01, 0xdb, 0xe3, 0xe2, 0x2c, 0x6b, 0x81, 0x36, 0x0b, 0xe8, 0x14,
-	0xc3, 0xf6, 0x22, 0x70, 0xd2, 0x91, 0x43, 0x44, 0x37, 0x90, 0x72, 0x52, 0xe7, 0x65, 0x2f, 0xdb,
-	0x4f, 0xd9, 0x4f, 0xda, 0xff, 0x19, 0x48, 0x4a, 0x8a, 0xbc, 0x15, 0xe8, 0x1b, 0xcf, 0x77, 0x3e,
-	0x9e, 0xef, 0xdc, 0x48, 0x78, 0x92, 0xbe, 0x8b, 0x8f, 0x33, 0xbe, 0x11, 0xac, 0xe2, 0x45, 0x5e,
-	0x9f, 0xf0, 0xa8, 0x14, 0x45, 0x55, 0x10, 0xb7, 0x75, 0x04, 0x7f, 0x80, 0xfb, 0xea, 0xf4, 0x0d,
-	0x2b, 0x2f, 0x77, 0x25, 0x92, 0x43, 0xe8, 0x73, 0xb9, 0xe5, 0xb1, 0x6f, 0xcd, 0xec, 0xf9, 0x88,
-	0x1a, 0xc3, 0xa0, 0x1b, 0x1e, 0xfb, 0x76, 0x83, 0x6e, 0x78, 0x4c, 0x3e, 0x86, 0xc1, 0x55, 0x21,
-	0x2b, 0x1e, 0xfb, 0xbd, 0x99, 0x3d, 0xef, 0xd3, 0xda, 0x22, 0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0xc0, 0x39, 0xff, 0xf9, 0xfc, 0xc7, 0xa9, 0xfd,
-	0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa0, 0x86, 0x78, 0x5b, 0x16, 0x07, 0x00, 0x00,
+	// 935 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 0x4d, 0x6f, 0xdb, 0x46,
+	0x13, 0xc7, 0x1f, 0x51, 0x94, 0x2d, 0x0e, 0x65, 0x47, 0xd9, 0x18, 0x0f, 0x88, 0xa4, 0x2f, 0x2a,
+	0x93, 0xa2, 0xaa, 0x0f, 0x76, 0xaa, 0xa0, 0x40, 0x7b, 0xac, 0xe5, 0xba, 0x09, 0x90, 0xb8, 0xc6,
+	0xca, 0x46, 0xd1, 0x5e, 0x88, 0x2d, 0x39, 0x94, 0x17, 0xe6, 0x1b, 0x76, 0x49, 0x3b, 0xf2, 0xa5,
+	0xa7, 0x7e, 0x94, 0x7e, 0x9e, 0x9e, 0xfa, 0x7d, 0x8a, 0xdd, 0xe5, 0xd2, 0x54, 0x1b, 0xa0, 0xb7,
+	0x9d, 0xff, 0xfc, 0x38, 0xb3, 0xf3, 0xc2, 0x85, 0x67, 0xd9, 0xfb, 0xe4, 0x38, 0xe7, 0x6b, 0xc1,
+	0x6a, 0x5e, 0x16, 0xed, 0x09, 0x8f, 0x2a, 0x51, 0xd6, 0x25, 0xf1, 0x3a, 0x47, 0xf8, 0x1b, 0x78,
+	0x6f, 0x4e, 0xdf, 0xb1, 0xea, 0x72, 0x53, 0x21, 0x39, 0x80, 0x11, 0x97, 0x0d, 0x4f, 0x82, 0xc1,
+	0xcc, 0x99, 0x8f, 0xa9, 0x31, 0x8c, 0xba, 0xe6, 0x49, 0xe0, 0x58, 0x75, 0xcd, 0x13, 0xf2, 0x7f,
+	0xd8, 0xb9, 0x2e, 0x65, 0xcd, 0x93, 0x60, 0x38, 0x73, 0xe6, 0x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a, 0x0e, 0xc8, 0x2e,
+	0x0c, 0x7f, 0x39, 0x5b, 0x4d, 0x1d, 0x75, 0xa0, 0x27, 0xa7, 0xd3, 0xe1, 0xe1, 0x31, 0x8c, 0xed,
+	0x13, 0x43, 0xf6, 0x01, 0xd4, 0x39, 0xea, 0x7d, 0x78, 0xf1, 0xfa, 0xbb, 0xab, 0xb7, 0xd3, 0x01,
+	0x19, 0x83, 0x7b, 0xfe, 0xe3, 0xf9, 0xf7, 0x53, 0xe7, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8d,
+	0x00, 0xf4, 0x67, 0x61, 0x07, 0x00, 0x00,
 }
diff --git a/lxd/migration/migrate.proto b/lxd/migration/migrate.proto
index bfb35eca2..e887c3504 100644
--- a/lxd/migration/migrate.proto
+++ b/lxd/migration/migrate.proto
@@ -35,13 +35,15 @@ message Device {
 }
 
 message Snapshot {
-	required string			name		= 1;
-	repeated Config 		localConfig	= 2;
-	repeated string			profiles	= 3;
-	required bool			ephemeral	= 4;
+	required string			name			= 1;
+	repeated Config 		localConfig		= 2;
+	repeated string			profiles		= 3;
+	required bool			ephemeral		= 4;
 	repeated Device			localDevices	= 5;
 	required int32			architecture	= 6;
-	required bool			stateful	= 7;
+	required bool			stateful		= 7;
+	required int64			creation_date	= 8;
+	required int64			last_used_date	= 9;
 }
 
 message MigrationHeader {
diff --git a/lxd/storage_migration.go b/lxd/storage_migration.go
index 6c699c111..61c6e2ff0 100644
--- a/lxd/storage_migration.go
+++ b/lxd/storage_migration.go
@@ -2,6 +2,7 @@ package main
 
 import (
 	"fmt"
+	"time"
 
 	"github.com/gorilla/websocket"
 
@@ -142,7 +143,7 @@ func snapshotProtobufToContainerArgs(containerName string, snap *migration.Snaps
 	}
 
 	name := containerName + shared.SnapshotDelimiter + snap.GetName()
-	return db.ContainerArgs{
+	args := db.ContainerArgs{
 		Name:         name,
 		Ctype:        db.CTypeSnapshot,
 		Config:       config,
@@ -152,6 +153,16 @@ func snapshotProtobufToContainerArgs(containerName string, snap *migration.Snaps
 		Architecture: int(snap.GetArchitecture()),
 		Stateful:     snap.GetStateful(),
 	}
+
+	if snap.GetCreationDate() != 0 {
+		args.CreationDate = time.Unix(snap.GetCreationDate(), 0)
+	}
+
+	if snap.GetLastUsedDate() != 0 {
+		args.LastUsedDate = time.Unix(snap.GetLastUsedDate(), 0)
+	}
+
+	return args
 }
 
 func rsyncStorageMigrationSink(conn *websocket.Conn, op *operation, storage storage) error {


More information about the lxc-devel mailing list