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

[Draft] feat: add Windows support #553

Closed
wants to merge 16 commits into from

Conversation

vsiravar
Copy link
Contributor

@vsiravar vsiravar commented Sep 1, 2023

Draft
Issue #, if available:
#492

Description of changes:
Finch changes to support finch on windows using WSL2.

  • Refactor main package and add build constraints.
  • Refactor config package and add build constraints and checks for host configuration.
  • Add handlers to handle path conversion from windows path to wsl path for nerdctl commands.
  • Add wrappers for filepath functions in system package for NerdctlCommandSystemDeps.

TODO

  • Handle filepaths for copy command
  • Add windows specific unit tests in nerdctl_test.go
  • Refactor Makefile
  • Add e2e tests for VM specific to WSL2.

Testing done:

Yes, e2e tests have errors related to copy command.

  • I've reviewed the guidance in CONTRIBUTING.md

License Acceptance

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@vsiravar vsiravar changed the title feat: Vsiravar/windev [Draft] feat: Vsiravar/windev Sep 1, 2023
Copy link
Member

@pendo324 pendo324 left a comment

Choose a reason for hiding this comment

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

Looks great to me, just left some minor comments

Comment on lines 31 to 36
optionalDepGroups := []*dependency.Group{
credhelper.NewDependencyGroup(ecc, fs, fp, logger, fc, system.NewStdLib().Env("USER"),
system.NewStdLib().Arch()),
}

optionalDepGroups = append(optionalDepGroups, vmnet.NewDependencyGroup(ecc, lcc, fs, fp, logger))
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to only extract the depGroups into a new platform specific file? Seems like everything else is the same

@@ -79,6 +79,7 @@ func (sva *startVMAction) run() error {
return err
}

// TODO: don't run this on Windows
Copy link
Member

Choose a reason for hiding this comment

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

Working on implementing that in Lima now, so hopefully only a temporary todo

Comment on lines +23 to +25
cpuDefault(cfg, deps)

memoryDefault(cfg, mem)
Copy link
Member

Choose a reason for hiding this comment

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

These settings actually aren't configurable with current versions of WSL2

Copy link
Member

Choose a reason for hiding this comment

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

Once disks are implemented for Windows in Lima, we'll need this to be back to an all-platform file

Comment on lines +99 to +100
.PHONY: finch-core-local
finch-core-local:
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO on removing this rule. IIRC we added this to make lima.exe and the guestagent sourcing the WSL PR to lima:

But once lima is released with WSL support, we should source similar to how we do on macOS via LIMA_URL: https://github.com/vsiravar/finch-core-public/blob/b82c007d22d4d99f8a78a3db7c6252ce9c5afcc8/Makefile#L36C14-L36C14

FINCH_ROOTFS_URL ?= https://deps.runfinch.com/common/x86-64/finch-rootfs-production-amd64-1690920103.tar.zst
FINCH_ROOTFS_BASENAME := $(notdir $(FINCH_ROOTFS_URL))
FINCH_ROOTFS_BASENAME := $(subst .zst,,$(FINCH_ROOTFS_BASENAME))
# TODO ROOTFS URL
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can remove

FINCH_ROOTFS_URL ?= https://deps.runfinch.com/common/aarch64/finch-rootfs-production-arm64-1690920104.tar.zst
FINCH_ROOTFS_BASENAME := $(notdir $(FINCH_ROOTFS_URL))
FINCH_ROOTFS_BASENAME := $(subst .zst,,$(FINCH_ROOTFS_BASENAME))
# TODO ROOTFS URL
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can remove

sed -i.bak -e "s/<finch_image_digest>/$(FINCH_IMAGE_DIGEST)/g" $(OUTDIR)/os/finch.yaml

# TODO: Windows PoC - clean this up / consolidate
.PHONY: finch.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: finch.windows.yaml

Comment on lines 148 to +155
finch.yaml: finch-core
mkdir -p $(OUTDIR)/os
cp finch.yaml $(OUTDIR)/os
# using -i.bak is very intentional, it allows the following commands to succeed for both GNU / BSD sed
# this sed command uses the alternative separator of "|" because the image location uses "/"
sed -i.bak -e "s|<finch_image_location>|$(FINCH_OS_IMAGE_LOCATION)|g" $(OUTDIR)/os/finch.yaml
sed -i.bak -e "s|<finch_image_location>|$(FINCH_IMAGE_LOCATION)|g" $(OUTDIR)/os/finch.yaml
sed -i.bak -e "s/<finch_image_arch>/$(LIMA_ARCH)/g" $(OUTDIR)/os/finch.yaml
sed -i.bak -e "s/<finch_image_digest>/$(FINCH_IMAGE_DIGEST)/g" $(OUTDIR)/os/finch.yaml
Copy link
Contributor

@ginglis13 ginglis13 Sep 1, 2023

Choose a reason for hiding this comment

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

maybe we can consolidate finch.yaml and finch.windows.yaml rules to be something like:

WINDOWS ?=
CONF_FILE ?=
ifeq ($(GOOS),windows)
    WINDOWS=.windows
    CONF_FILE=finch.windows.yaml
else
    CONF_FILE=finch.yaml
endif

finch$(WINDOWS).yaml: finch-core
	mkdir -p $(OUTDIR)/os
	cp $(CONF_FILE) $(OUTDIR)/os
	# using -i.bak is very intentional, it allows the following commands to succeed for both GNU / BSD sed
	# this sed command uses the alternative separator of "|" because the image location uses "/"
	sed -i.bak -e "s|<finch_image_location>|$(FINCH_IMAGE_LOCATION)|g" $(OUTDIR)/os/finch.yaml
	sed -i.bak -e "s/<finch_image_arch>/$(LIMA_ARCH)/g" $(OUTDIR)/os/finch.yaml
	sed -i.bak -e "s/<finch_image_digest>/$(FINCH_IMAGE_DIGEST)/g" $(OUTDIR)/os/finch.yaml

@@ -254,7 +311,7 @@ check-licenses:

.PHONY: test-unit
test-unit:
go test $(shell go list ./... | grep -v e2e) -shuffle on -race
go test $(shell go list ./... | grep -v e2e) -shuffle on
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove race condition checks?

"strings"
)

func convertToWSLPath(systemDeps NerdctlCommandSystemDeps, winPath string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment here with an example or two of what this conversion looks like?

@@ -5,6 +5,8 @@
# Default values in this YAML file are specified by `null` instead of Lima's "builtin default" values,
# so they can be overridden by the $LIMA_HOME/_config/default.yaml mechanism documented at the end of this file.

#vmType: null
Copy link
Contributor

@ginglis13 ginglis13 Sep 1, 2023

Choose a reason for hiding this comment

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

nit: uncomment - this was leftover from my poc :)

@@ -1,6 +1,9 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//go:build darwin
// +build darwin
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: // +build <tag> tags obsolete after Go 1.18 https://tip.golang.org/doc/go1.18 . this applies to a few other places in this PR. go fix should remove them automatically for you

pendo324 pushed a commit to runfinch/finch-core that referenced this pull request Sep 15, 2023
install packages
* qemu-user-static-aarch64
* qemu-user-static-arm
* qemu-user-static-x86
* iptables
* fuse-sshfs 

depended on by lima to decrease boot time of Finch VM on Windows

Issue #, if available:

*Description of changes:*


*Testing done:*

* EC2 Windows dev instance 
* build rootfs locally, scp up
* run Finch w/ changes in runfinch/finch#553
* basic commands tests -> `finch vm init`, `finch vm pull
alpine:latest`, etc.

- [x] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Signed-off-by: Gavin Inglis <[email protected]>
@pendo324 pendo324 changed the title [Draft] feat: Vsiravar/windev [Draft] feat: add Windows support Sep 18, 2023
Signed-off-by: Justin Alvarez <[email protected]>
# The vmType can be specified only on creating the instance.
# The vmType of existing instances cannot be changed.
# 🟢 Builtin default: "qemu"
vmType: wsl2

Choose a reason for hiding this comment

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

@pendo324
Copy link
Member

Closed by merging #649

@pendo324 pendo324 closed this Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants