Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
container: Rename addDrive to hotplugDrive
Browse files Browse the repository at this point in the history
We no longer do cold plug.

Fixes #435

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Samuel Ortiz committed Oct 22, 2017
1 parent e848de5 commit c490764
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
18 changes: 5 additions & 13 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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)
}()
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 2 additions & 12 deletions container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit c490764

Please sign in to comment.