Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

preflight before start operation #360

Merged
merged 10 commits into from
Sep 9, 2019

Conversation

najeal
Copy link
Contributor

@najeal najeal commented Aug 25, 2019

This adds preflight checks before start operation.

Fixes #184

@najeal najeal requested a review from twelho as a code owner August 25, 2019 20:46
Copy link
Contributor

@luxas luxas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @najeal for your contribution 💯!

This looks really good to be the first draft 👍

I made a couple of suggestions, let me know what you think

return "ExistingFile"
}

type AvailablePathChecker struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unused?

vmDir := filepath.Join(constants.VM_DIR, vm.GetUID().String())
kernelDir := filepath.Join(constants.KERNEL_DIR, kernelUID.String())
log.Println(vm.GetUID().String())
checks = append(checks, ExistingFileChecker{filePath: path.Join(vmDir, constants.METADATA)})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check for the metadata and kernel files, they are gonna be created on the fly.

}
vmDir := filepath.Join(constants.VM_DIR, vm.GetUID().String())
kernelDir := filepath.Join(constants.KERNEL_DIR, kernelUID.String())
log.Println(vm.GetUID().String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this?

for _, port := range vm.Spec.Network.Ports {
checks = append(checks, PortOpenChecker{port: port.HostPort})
}
return runChecks(checks, ignoredPreflightErrors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other things that could be added:

  • make sure that the docker/containerd socket exists?
    • this could be done by extending runtime.Interface with a PreflightChecker() preflight.Checker method. when invoked, it would make sure docker / containerd sockets exist
    • here in this method you'd do checks = append(checks, providers.Runtime.PreflightChecker())
  • make sure all the binaries listed in https://ignite.readthedocs.io/en/stable/dependencies.html are present in PATH

Copy link
Contributor

@twelho twelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @najeal! 💯
Some small nits, otherwise LGTM 👍
Does need rebasing though before we can merge.

"strings"

"k8s.io/apimachinery/pkg/util/sets"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this newline

checks = append(checks, ExistingFileChecker{filePath: "/dev/mapper/control"})
checks = append(checks, ExistingFileChecker{filePath: "/dev/net/tun"})
checks = append(checks, ExistingFileChecker{filePath: "/dev/kvm"})
checks = append(checks, providers.Runtime.PreflightChecker())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be an inline constructor instead of 4 allocations

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@najeal could you please address this per @twelho comment.

The start operation preflight checks files exists and ports are available
…+ alloc properly the checkers array

The package was not using the interface from the preflight package. We use it now and we deleted the interface in the checkers package.
Multiple re-allocation was occuring when appending checkers to the array. Now, allocation is done at the beginning by calculating the total number of checkers we will store in the array.
@najeal
Copy link
Contributor Author

najeal commented Sep 1, 2019

Done.
I can squash if needed

@chanwit
Copy link
Member

chanwit commented Sep 4, 2019

This preflight would be a life saver, thank you @najeal !!

It seems that we have some changes since last time, like

  • containerd detection
  • git should be optionally detected.
    But I think this could be addressed by another PR.

Small things left to be addressed. /cc @stealthybox

Copy link
Contributor

@luxas luxas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked to @chanwit and @stealthybox, this will be very valuable in v0.6.1.
Merging to unblock @chanwit.

LGTM, thanks @najeal 👍

@luxas luxas merged commit b5561ff into weaveworks:master Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide "Preflight checks" to Ignite
4 participants