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

Support Windows-based images for build #739

Merged
merged 2 commits into from
Aug 11, 2020
Merged

Support Windows-based images for build #739

merged 2 commits into from
Aug 11, 2020

Conversation

ameyer-pivotal
Copy link
Contributor

@ameyer-pivotal ameyer-pivotal commented Jul 10, 2020

  • Supports Windows-based images for pack build (under experimental flag)

Resolves #470

@ameyer-pivotal
Copy link
Contributor Author

cc: @aemengo

Copy link
Member

@dfreilich dfreilich left a comment

Choose a reason for hiding this comment

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

Overall, this looks great!

One general thought - would it be better to move some of the common variables/Windows changes (i.e. the change from root to ContainerAdministrator) to be injected build-time variables (like we use here), or would that make it more complicated? I'm not recommending necessarily that we use it, I just wonder what people think. (cc @simonjjones )

acceptance/acceptance_test.go Outdated Show resolved Hide resolved
acceptance/acceptance_test.go Outdated Show resolved Hide resolved
build.go Outdated Show resolved Hide resolved
internal/archive/archive.go Show resolved Hide resolved
internal/build/container_ops.go Show resolved Hide resolved
internal/build/container_ops.go Show resolved Hide resolved
internal/build/build.go Outdated Show resolved Hide resolved
rebase.go Outdated Show resolved Hide resolved
@ameyer-pivotal
Copy link
Contributor Author

ameyer-pivotal commented Jul 13, 2020

Overall, this looks great!

One general thought - would it be better to move some of the common variables/Windows changes (i.e. the change from root to ContainerAdministrator) to be injected build-time variables (like we use here), or would that make it more complicated? I'm not recommending necessarily that we use it, I just wonder what people think. (cc @simonjjones )

@dfreilich It seems to me that the reason for build-time injection would be for values that are subject to change on a build-by-build basis (pack version, etc.). I'm not seeing the value for these particular variables, but open to others' thoughts.

For root vs ContainerAdministrator, it's important to note that the value chosen still needs to be dynamic at runtime, based on the docker host OS being targeted. The actual content of the ContainerAdministrator string could be moved into a build-time variable, but per the above paragraph, I'm not sure what that buys you.

@codecov
Copy link

codecov bot commented Jul 15, 2020

Codecov Report

Merging #739 into main will increase coverage by 1.37%.
The diff coverage is 64.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #739      +/-   ##
==========================================
+ Coverage   76.05%   77.41%   +1.37%     
==========================================
  Files          78       78              
  Lines        5301     4443     -858     
==========================================
- Hits         4031     3439     -592     
+ Misses        973      698     -275     
- Partials      297      306       +9     
Flag Coverage Δ
#os_linux 77.41% <64.93%> (-0.96%) ⬇️
#os_macos 73.40% <52.88%> (-0.87%) ⬇️
#os_windows 100.00% <ø> (+25.64%) ⬆️
#unit 77.41% <64.93%> (+1.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@natalieparellano natalieparellano left a comment

Choose a reason for hiding this comment

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

This is awesome! Given the magnitude of the impact the number of changes is relatively small and it's very clean. Looking forward to seeing the final PR :)

.github/workflows/build.yml Outdated Show resolved Hide resolved
@@ -901,6 +867,8 @@ func testAcceptance(
var buildpackTgz, tempVolume string

it.Before(func() {
h.SkipIf(t, os.Getenv("DOCKER_HOST") != "", "cannot mount volume when DOCKER_HOST is set")
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a README or something that explains the use of DOCKER_HOST in local development?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not currently, but since it's a docker usage concern, I wonder if we should link to the docker docs somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this could be covered in buildpacks/docs#180?

Copy link
Member

Choose a reason for hiding this comment

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

You might add "pack developer" to the "target audience" list in that issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that audience covered by buildpacks.io??

Copy link
Member

@jromero jromero Aug 11, 2020

Choose a reason for hiding this comment

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

It's not and I don't think it should. "pack developers" should be looking at the repo *.md or wiki.

cmd := subjectPack("build", repoName, "-p", filepath.Join("testdata", "mock_app"), "--publish", "--network", "host")

if dockerHostOS() == "windows" {
cmd = subjectPack("build", repoName, "-p", filepath.Join("testdata", "mock_app"), "--publish")
Copy link
Member

Choose a reason for hiding this comment

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

A comment here explaining the underlying limitation might be helpful.

acceptance/acceptance_test.go Show resolved Hide resolved
@@ -2028,7 +2046,7 @@ func waitForResponse(t *testing.T, port string, timeout time.Duration) string {
for {
select {
case <-ticker.C:
resp, err := h.HTTPGetE("http://localhost:"+port, map[string]string{})
resp, err := h.HTTPGetE("http://"+h.RegistryHost(port), map[string]string{})
Copy link
Member

Choose a reason for hiding this comment

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

Rooting for this to be from imgutil one day :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We created an issue in our backlog to port this to imgutil after this story is complete (that way it's easier to validate the implementation first).

internal/builder/lifecycle.go Outdated Show resolved Hide resolved
@dfreilich
Copy link
Member

For tracking purposes, would you mind also creating a docs issues for documenting building Windows images?

@ameyer-pivotal
Copy link
Contributor Author

ameyer-pivotal commented Aug 4, 2020

For tracking purposes, would you mind also creating a docs issues for documenting building Windows images?

@dfreilich Done. buildpacks/docs#180

@ameyer-pivotal ameyer-pivotal marked this pull request as ready for review August 6, 2020 19:17
@ameyer-pivotal ameyer-pivotal requested a review from a team as a code owner August 6, 2020 19:17
Copy link
Member

@jromero jromero left a comment

Choose a reason for hiding this comment

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

This is great!!! I'm excited to see Windows support!

Didn't get to comb through everything but I thought I'd provide some partial feedback to minimize the feedback loop.

.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
acceptance/acceptance_test.go Show resolved Hide resolved
internal/archive/archive.go Show resolved Hide resolved
internal/build/container_ops.go Show resolved Hide resolved
build.go Outdated Show resolved Hide resolved
testhelpers/testhelpers.go Outdated Show resolved Hide resolved
@jromero jromero linked an issue Aug 7, 2020 that may be closed by this pull request
Copy link
Member

@dfreilich dfreilich left a comment

Choose a reason for hiding this comment

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

Looks really great! I agree with Javier that it can use a bit of cleaning up to make build.go a bit more elegant, but this is super impressive.

Makefile Show resolved Hide resolved
acceptance/acceptance_test.go Outdated Show resolved Hide resolved
acceptance/acceptance_test.go Show resolved Hide resolved
acceptance/acceptance_test.go Show resolved Hide resolved
build.go Outdated Show resolved Hide resolved
build_test.go Show resolved Hide resolved
build.go Outdated Show resolved Hide resolved
internal/build/phase_config_provider.go Show resolved Hide resolved
Copy link
Member

@natalieparellano natalieparellano left a comment

Choose a reason for hiding this comment

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

This is looking great! Added a few comments.

internal/cache/volume_cache_test.go Outdated Show resolved Hide resolved
testhelpers/testhelpers.go Outdated Show resolved Hide resolved
internal/build/phase_config_provider_test.go Show resolved Hide resolved
acceptance/acceptance_test.go Show resolved Hide resolved
@@ -901,6 +867,8 @@ func testAcceptance(
var buildpackTgz, tempVolume string

it.Before(func() {
h.SkipIf(t, os.Getenv("DOCKER_HOST") != "", "cannot mount volume when DOCKER_HOST is set")
Copy link
Member

Choose a reason for hiding this comment

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

You might add "pack developer" to the "target audience" list in that issue.

@@ -1561,18 +1590,29 @@ include = [ "*.jar", "media/mountain.jpg", "media/person.png" ]
var buildRunImage func(string, string, string)

it.Before(func() {
pack.JustRunSuccessfully("trust-builder", builderName)
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing this was needed because we don't support untrusted builder workflows on Windows yet (though I'm confused how it relates to rebase, could you explain?).

I'm a bit concerned about this setup because it could potentially pollute other tests (it modifies that pack config file). Is there any way to pass --trust-builder instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand the confusion. Trusting the builder is needed for the reason you mentioned, but we added this line because when("rebase") is a sibling to the when("build") where this normally happens (under when("default builder is set"), so we duplicated it here. I don't feel strongly one way or the other regarding --trust-builder instead, though the pollution argument would be a problem already (due to the when("build").

Copy link
Member

Choose a reason for hiding this comment

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

Oh, ha! I guess I'm wondering, if you remove the setup, do the rebase tests still pass? I would assume so, but maybe I'm wrong...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@natalieparellano If this were removed, the tests would pass in the Linux container case and fail in the Windows container case

Copy link
Member

Choose a reason for hiding this comment

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

Ohhh... I think I get it now. I was struggling to see how "trusted builder" has anything to do with rebase - but it looks like the test setup has a pack build that would fail if the builder is not trusted. Maybe it's worth adding a comment, so that others don't also get confused. Or you could use --trust-builder just where it's needed.

internal/build/phases.go Show resolved Hide resolved
build_test.go Show resolved Hide resolved
build.go Outdated Show resolved Hide resolved
build.go Outdated Show resolved Hide resolved
@jromero jromero added this to the 0.13.0 milestone Aug 11, 2020
@jromero jromero added the type/enhancement Issue that requests a new feature or improvement. label Aug 11, 2020
Signed-off-by: Andrew Meyer <meyeran@vmware.com>
Signed-off-by: Malini Valliath <mvalliath@pivotal.io>
Signed-off-by: Micah Young <ymicah@vmware.com>
Signed-off-by: Anthony Emengo <aemengo@vmware.com>
Signed-off-by: Victoria Henry <vhenry@pivotal.io>
Signed-off-by: Andrew Meyer <meyeran@vmware.com>
Copy link
Member

@jromero jromero left a comment

Choose a reason for hiding this comment

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

windows

@jromero jromero merged commit 03503c9 into buildpacks:main Aug 11, 2020
@ameyer-pivotal ameyer-pivotal deleted the feature/470-build-windows-images branch August 11, 2020 18:26
@jromero jromero added the experimental Issue or PR refers to an experimental feature. label Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental Issue or PR refers to an experimental feature. type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
5 participants