Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if environment settings are achieved #2763

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mantissahz
Copy link
Contributor

Which issue(s) this PR fixes:

Issue # longhorn/longhorn#7571

What this PR does / why we need it:

Check if the environment settings are achieved, ref: environment_check.sh

Special notes for your reviewer:

Additional documentation or context

@mantissahz mantissahz requested review from innobead, derekbit and a team April 29, 2024 03:45
@mantissahz mantissahz self-assigned this Apr 29, 2024
ref: longhorn/longhorn#7571

Signed-off-by: James Lu <james.lu@suse.com>
ref: longhorn/longhorn#7571

Signed-off-by: James Lu <james.lu@suse.com>
ref: longhorn/longhorn#7571

Signed-off-by: James Lu <james.lu@suse.com>
ref: longhorn/longhorn#7571

Signed-off-by: James Lu <james.lu@suse.com>
ref: longhorn/longhorn#7571

Signed-off-by: James Lu <james.lu@suse.com>

kernelConfigPath := "/boot/config-" + kernelVersion
args := []string{kernelConfigPath}
if _, err := nsexec.Execute(nil, "ls", args, lhtypes.ExecuteDefaultTimeout); err != nil {
Copy link
Contributor

@c3y1huang c3y1huang Apr 29, 2024

Choose a reason for hiding this comment

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

Need to be careful about invoking binaries with nsenter, this could be blocking when installing on Talos Linux.

Copy link
Contributor

@c3y1huang c3y1huang Apr 29, 2024

Choose a reason for hiding this comment

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

Consider utilizing ReadDirectory.

Also, need to check other binary invocations introduced in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is great, thank you.
That is a file, and I would use GetFileInfo.

@mantissahz mantissahz marked this pull request as draft April 29, 2024 13:41
@mantissahz mantissahz requested a review from a team April 29, 2024 13:41
Copy link
Contributor

@james-munson james-munson left a comment

Choose a reason for hiding this comment

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

Just one nit.

currentNodeID, err := util.GetRequiredEnv(types.EnvNodeName)
if err != nil {
return fmt.Errorf("failed to detect the node name")
}

if err := environmentCheck(kubeconfigPath, currentNodeID); err != nil {
return errors.Wrap(err, "Failed environment check, please make sure you have iscsiadm/open-iscsi installed on the host")
Copy link
Contributor

Choose a reason for hiding this comment

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

Since environmentCheck() checks everything, not just iscsi, this error message may be misleading.

Copy link
Member

Choose a reason for hiding this comment

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

Agree with @james-munson's comment.
You can combine the errors in environmentCheck and just do

return errors.Wrap(err, "Failed environment check")

here.

@@ -244,8 +253,54 @@ func startManager(c *cli.Context) error {
return nil
}

func environmentCheck() error {
func environmentCheck(kubeconfigPath, currentNodeID string) error {
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
func environmentCheck(kubeconfigPath, currentNodeID string) error {
func environmentCheck(kubeconfigPath, nodeID string) error {

}

// Check if kernel version is recommended
if err := checkKernelVersion(kubeNode, currentNodeID); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

kubeNode already contains the nodeID. Can we remove the parameter currentNodeID?

Suggested change
if err := checkKernelVersion(kubeNode, currentNodeID); err != nil {
if err := checkKernelVersion(kubeNode); err != nil {

namespaces := []lhtypes.Namespace{lhtypes.NamespaceMnt, lhtypes.NamespaceNet}
// Check if necessary packages are installed
if err := checkPackagesInstalled(kubeNode, namespaces, currentNodeID); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

}

// Check if nfs client versions are supported
if err := checkNFSClientVersion(kubeNode, namespaces, currentNodeID); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

}
}

return fmt.Errorf("NFS clients %v not found. At least one should be enabled", nfsClientVersions)
Copy link
Member

Choose a reason for hiding this comment

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

If a cluster doesn't require RWX volumes, then NFS server and client are not necessary. Should we error out in this use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants