From c49076410d7d804a72adb5ab6ec6b1652f759afd Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 23 Oct 2017 00:33:24 +0200 Subject: [PATCH] container: Rename addDrive to hotplugDrive We no longer do cold plug. Fixes #435 Signed-off-by: Samuel Ortiz --- container.go | 18 +++++------------- container_test.go | 14 ++------------ pod.go | 2 +- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/container.go b/container.go index e274a3ba..d9b405ac 100644 --- a/container.go +++ b/container.go @@ -521,7 +521,7 @@ func (c *Container) start() error { hypervisorCaps := c.pod.hypervisor.capabilities() if agentCaps.isBlockDeviceSupported() && hypervisorCaps.isBlockDeviceHotplugSupported() { - if err := c.addDrive(false); err != nil { + if err := c.hotplugDrive(); err != nil { return err } } @@ -738,7 +738,7 @@ func newProcess(token string, pid int) Process { } } -func (c *Container) addDrive(create bool) error { +func (c *Container) hotplugDrive() error { defer func() { c.setStateRootfsBlockChecked(true) }() @@ -787,18 +787,10 @@ func (c *Container) addDrive(create bool) error { ID: devID, } - // if pod in create stage - if create { - if err := c.pod.hypervisor.addDevice(drive, blockDev); err != nil { - return err - } - c.setStateHotpluggedDrive(false) - } else { - if err := c.pod.hypervisor.hotplugAddDevice(drive, blockDev); err != nil { - return err - } - c.setStateHotpluggedDrive(true) + if err := c.pod.hypervisor.hotplugAddDevice(drive, blockDev); err != nil { + return err } + c.setStateHotpluggedDrive(true) driveIndex, err := c.pod.getAndSetPodBlockIndex() if err != nil { diff --git a/container_test.go b/container_test.go index 36f83189..8790b76e 100644 --- a/container_test.go +++ b/container_test.go @@ -213,22 +213,12 @@ func TestContainerAddDriveDir(t *testing.T) { checkStorageDriver = savedFunc }() - err = container.addDrive(true) - if err != nil { - t.Fatalf("Error with addDrive :%v", err) - } - - if container.state.Fstype == "" || container.state.HotpluggedDrive { - t.Fatal() - } - container.state.Fstype = "" container.state.HotpluggedDrive = false - // hotplugged case, when create is passed as false - err = container.addDrive(false) + err = container.hotplugDrive() if err != nil { - t.Fatalf("Error with addDrive :%v", err) + t.Fatalf("Error with hotplugDrive :%v", err) } if container.state.Fstype == "" || !container.state.HotpluggedDrive { diff --git a/pod.go b/pod.go index ea8c59f0..186c47dd 100644 --- a/pod.go +++ b/pod.go @@ -1192,7 +1192,7 @@ func (p *Pod) hotplugDrives() error { } for _, c := range p.containers { - if err := c.addDrive(false); err != nil { + if err := c.hotplugDrive(); err != nil { return err } }