Skip to content

Commit

Permalink
Remove log/dir before unmount ephemeral disk
Browse files Browse the repository at this point in the history
Also idempotently create /var/log during bootstrap

[#128333917]

Signed-off-by: Ming Xiao <[email protected]>
  • Loading branch information
zaksoup authored and Ming Xiao committed Aug 24, 2016
1 parent 7491ddd commit 8e1c458
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Vagrant.configure('2') do |config|
config.vm.provision :shell, inline: "chmod 777 /var/vcap/sys/log/cpi"

config.vm.provision :shell, inline: "sudo #{agent_dir}/integration/assets/install-go.sh"
config.vm.provision :shell, inline: "sudo cp #{agent_dir}/integration/assets/start_logging_and_auditing.sh /var/vcap/bosh/bin/start_logging_and_auditing.sh"
config.vm.provision :shell, inline: "sudo #{agent_dir}/integration/assets/install-agent.sh"
config.vm.provision :shell, inline: "sudo #{agent_dir}/integration/assets/install-fake-registry.sh"
config.vm.provision :shell, inline: "sudo #{agent_dir}/integration/assets/disable_growpart.sh"
Expand Down
3 changes: 3 additions & 0 deletions integration/assets/start_logging_and_auditing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exit 0
19 changes: 14 additions & 5 deletions integration/test_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ sudo umount /tmp/config-drive
return err
}

func (t *TestEnvironment) CleanupDataDir() error {
t.RunCommand(`sudo /var/vcap/bosh/bin/monit stop all`)

mountPoints, err := t.RunCommand(`sudo mount | grep "on /var/vcap/data" | cut -d ' ' -f 3`)
func (t *TestEnvironment) unmountDir(dir string) error {
mountPoints, err := t.RunCommand(fmt.Sprintf(`sudo mount | grep "on %s" | cut -d ' ' -f 3`, dir))
if err != nil {
return err
}
Expand All @@ -72,10 +70,21 @@ func (t *TestEnvironment) CleanupDataDir() error {
}
}

_, err = t.RunCommand("sudo rm -rf /var/vcap/data")
_, err = t.RunCommand(fmt.Sprintf("sudo rm -rf %s", dir))
return err
}

func (t *TestEnvironment) CleanupDataDir() error {
t.RunCommand(`sudo /var/vcap/bosh/bin/monit stop all`)

err := t.unmountDir("/var/log")
if err != nil {
return err
}

return t.unmountDir("/var/vcap/data")
}

// ConfigureAgentForGenericInfrastructure executes the agent_runit.sh asset.
// Required for reverse-compatibility with older bosh-lite
// (remove once a new warden stemcell is built).
Expand Down
10 changes: 8 additions & 2 deletions platform/linux_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,17 @@ func (p linux) SetupTmpDir() error {

func (p linux) SetupLogDir() error {
logDir := "/var/log"

err := p.fs.MkdirAll(logDir, userRootLogDirPermissions)
if err != nil {
return bosherr.WrapError(err, "Creating system log dir")
}

boshRootLogPath := path.Join(p.dirProvider.DataDir(), "root_log")

err := p.fs.MkdirAll(boshRootLogPath, userRootLogDirPermissions)
err = p.fs.MkdirAll(boshRootLogPath, userRootLogDirPermissions)
if err != nil {
return bosherr.WrapError(err, "Creating root tmp dir")
return bosherr.WrapError(err, "Creating root log dir")
}

auditDirPath := path.Join(boshRootLogPath, "audit")
Expand Down

0 comments on commit 8e1c458

Please sign in to comment.