Skip to content

Commit

Permalink
Ghost Cache records
Browse files Browse the repository at this point in the history
Signed-off-by: David Vossel <[email protected]>
  • Loading branch information
davidvossel committed Apr 13, 2020
1 parent 99e3146 commit d15cec2
Show file tree
Hide file tree
Showing 15 changed files with 429 additions and 184 deletions.
13 changes: 13 additions & 0 deletions cmd/virt-handler/virt-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type virtHandlerApp struct {
HostOverride string
PodIpAddress string
VirtShareDir string
VirtPrivateDir string
VirtLibDir string
WatchdogTimeoutDuration time.Duration
MaxDevices int
Expand Down Expand Up @@ -197,6 +198,14 @@ func (app *virtHandlerApp) Run() {
panic(err)
}

// We keep a record on disk of every VMI virt-handler starts.
// That record isn't deleted from this node until the VMI
// is completely torn down.
err = virtcache.InitializeGhostRecordCache(filepath.Join(app.VirtPrivateDir, "ghost-records"))
if err != nil {
panic(err)
}

cmdclient.SetPodsBaseDir("/pods")
cmdclient.SetLegacyBaseDir(app.VirtShareDir)
err = os.MkdirAll(cmdclient.LegacySocketsDirectory(), 0755)
Expand Down Expand Up @@ -237,6 +246,7 @@ func (app *virtHandlerApp) Run() {
app.HostOverride,
app.PodIpAddress,
app.VirtShareDir,
app.VirtPrivateDir,
vmSourceSharedInformer,
vmTargetSharedInformer,
domainSharedInformer,
Expand Down Expand Up @@ -359,6 +369,9 @@ func (app *virtHandlerApp) AddFlags() {
flag.StringVar(&app.VirtShareDir, "kubevirt-share-dir", util.VirtShareDir,
"Shared directory between virt-handler and virt-launcher")

flag.StringVar(&app.VirtPrivateDir, "kubevirt-private-dir", util.VirtPrivateDir,
"private directory for virt-handler state")

flag.StringVar(&app.VirtLibDir, "kubevirt-lib-dir", util.VirtLibDir,
"Shared lib directory between virt-handler and virt-launcher")

Expand Down
7 changes: 0 additions & 7 deletions cmd/virt-launcher/virt-launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,6 @@ func main() {
socketPath := cmdclient.SocketOnGuest()
cmdServerDone := startCmdServer(socketPath, domainManager, stopChan, options)

// Set socket info file after starting server
err = cmdclient.SetSocketInfo(socketPath, *uid, *name, *namespace)
if err != nil {
log.Log.Reason(err).Errorf("Unable to write server info file.")
panic(err)
}

gracefulShutdownCallback := func() {
err := wait.PollImmediate(time.Second, 15*time.Second, func() (bool, error) {
err := domainManager.MarkGracefulShutdownVMI(vm)
Expand Down
1 change: 1 addition & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
const ExtensionAPIServerAuthenticationConfigMap = "extension-apiserver-authentication"
const RequestHeaderClientCAFileKey = "requestheader-client-ca-file"
const VirtShareDir = "/var/run/kubevirt"
const VirtPrivateDir = "/var/run/kubevirt-private"
const VirtLibDir = "/var/lib/kubevirt"
const HostRootMount = "/proc/1/root/"
const CPUManagerOS3Path = HostRootMount + "var/lib/origin/openshift.local.volumes/cpu_manager_state"
Expand Down
2 changes: 2 additions & 0 deletions pkg/virt-handler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ go_library(
"//pkg/util/cluster:go_default_library",
"//pkg/util/types:go_default_library",
"//pkg/virt-config:go_default_library",
"//pkg/virt-handler/cache:go_default_library",
"//pkg/virt-handler/cmd-client:go_default_library",
"//pkg/virt-handler/container-disk:go_default_library",
"//pkg/virt-handler/device-manager:go_default_library",
Expand Down Expand Up @@ -49,6 +50,7 @@ go_test(
"//pkg/handler-launcher-com/cmd/v1:go_default_library",
"//pkg/testutils:go_default_library",
"//pkg/virt-config:go_default_library",
"//pkg/virt-handler/cache:go_default_library",
"//pkg/virt-handler/cmd-client:go_default_library",
"//pkg/virt-handler/isolation:go_default_library",
"//pkg/virt-handler/notify-server:go_default_library",
Expand Down
2 changes: 2 additions & 0 deletions pkg/virt-handler/cache/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
importpath = "kubevirt.io/kubevirt/pkg/virt-handler/cache",
visibility = ["//visibility:public"],
deps = [
"//pkg/ephemeral-disk-utils:go_default_library",
"//pkg/virt-handler/cmd-client:go_default_library",
"//pkg/virt-handler/notify-server:go_default_library",
"//pkg/virt-launcher/virtwrap/api:go_default_library",
Expand All @@ -28,6 +29,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//pkg/ephemeral-disk-utils:go_default_library",
"//pkg/virt-handler/cmd-client:go_default_library",
"//pkg/virt-launcher/notify-client:go_default_library",
"//pkg/virt-launcher/virtwrap:go_default_library",
Expand Down
Loading

0 comments on commit d15cec2

Please sign in to comment.