ddelnano / packer-plugin-xenserver

A builder plugin for Packer.IO to support building XenServer images.
Mozilla Public License 2.0
76 stars 37 forks source link

Upgrade builder to latest packer version #5

Closed ddelnano closed 3 years ago

ddelnano commented 3 years ago

This PR upgrades the builder's packer dependency to v1.6.5. This is the most recent release of packer until the packer plugin sdk was introduced (in v1.6.6).

Additional testing

ddelnano commented 3 years ago

The example is almost working. It seems there is a problem ssh'ing to the instance after it has booted and ran kickstart properly

ddelnano@ddelnano-desktop:~/go/src/github.com/xenserver/packer-builder-xenserver$ packer1.6 build -debug  --var sr_name='Local storage' --var sr_iso_name=LocalISO examples/centos8.json
Debug mode enabled. Builds will not be parallelized.
xenserver-iso: output will be in this color.

==> xenserver-iso: XAPI client session established
==> xenserver-iso: Starting HTTP server on port 8000
==> xenserver-iso: Step: Create Instance
...
...
...
==> xenserver-iso:
==> xenserver-iso: Received response: HTTP/1.1 200 OK
==> xenserver-iso: Connection: keep-alive
==> xenserver-iso: Cache-Control: no-cache, no-store
==> xenserver-iso:
==> xenserver-iso:
    xenserver-iso: Found local IP: 192.168.88.254
==> xenserver-iso: Typing boot commands over VNC...
==> xenserver-iso: Finished typing.
==> xenserver-iso: Step: Wait for VM's IP to become known to us.
    xenserver-iso: Got IP '192.168.88.193' from HTTP request
==> xenserver-iso: Got IP address '192.168.88.193'
==> xenserver-iso: Creating a local port forward over SSH on local port 5900
==> xenserver-iso: Port forward setup. 5900 ---> 192.168.88.193:22 on 192.168.88.89
==> xenserver-iso: Using ssh communicator to connect: 127.0.0.1
==> xenserver-iso: Waiting for SSH to become available...
==> xenserver-iso: Connected to SSH!
Build 'xenserver-iso' errored after 25 minutes 2 seconds: unexpected EOF

==> Wait completed after 25 minutes 2 seconds

==> Some builds didn't complete successfully and had errors:
--> xenserver-iso: unexpected EOF

==> Builds finished but no artifacts were created.
ddelnano commented 3 years ago

After debugging this more, I've tracked this down to the provisioner step. If I uncomment it, the packer builder runs fine and the ubuntu and centos examples work as expected. Since that was working prior to this change, that will need to be fixed before this can be merged.

fanuelsen commented 3 years ago

Hi, im still getting this error when using your binary release for linux with packer 1.6.5. Do i need to compile it from source?

Failed to initialize build 'xenserver-iso': error initializing builder 'xenserver-iso': Incompatible API version with plugin. Plugin version: 4, Ours: 5

ddelnano commented 3 years ago

@fanuelsen the builder does not support packer above v0.10.2 until I'm able to merge this PR and build new binaries. You could try this branch out yourself but please be aware that there are still bugs to fix and it is not ready for use.

I will hopefully be addressing the remaining issues over the next week.

fanuelsen commented 3 years ago

Thanks for pointing me in the right direction. I guess winrm is broken at this time?

[ERROR] connection error: unknown error Post http://127.0.0.1:5900/wsman: read tcp 127.0.0.1:45978->127.0.0.1:5900: read: connection reset by peer.

ddelnano commented 3 years ago

@fanuelsen all of my focus has been on linux so far (the examples that exist in master).

I have created #6 to track fixing the winrm issue. Can you please add the packer file and your reproduction steps for that error? I will look into that separately from building packer from the latest version. I'm not familiar with winrm at all so whatever additional context you can provide would be greatly appreciated.

ddelnano commented 3 years ago

After enabling packer logging (through the PACKER_LOG environment variable), I was able to figure out that the provisioners were failing due to a difference to how packer and the xenserver packer builder were doing type assertions.

https://github.com/terra-farm/terraform-provider-xenorchestra/pull/new/allow-ignoring-ssl-errorsJournal has been rotated since unit was started. Log output is incomplete or unavailable.Permanent journal is using
Jan 10 23:42:37 localhost systemd-journal[21475]: Forwarding to syslog missed 1 messages.
Jan 11 00:34:11 localhost systemd-journal[21475]: Forwarding to syslog missed 4 messages.
[root@localhost ~]# df -h
a057898e-a154-ca83-7ceb-528e71f988b9a057898e-a154-ca83-7ceb-528e71f988b9a057898e-a154-ca83-7ceb-528e71f988b9could not connect to local agent socketecho $SSH_AUTH_SOCKBuild 'xenserver-iso' errored after 18 seconds 475 milliseconds: unexpected EOF

==> Wait completed after 18 seconds 475 milliseconds

==> Some builds didn't complete successfully and had errors:
--> xenserver-iso: unexpected EOF

==> Builds finished but no artifacts were created.
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: panic: interface conversion: interface {} is int, not uint
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: goroutine 130 [running]:
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: github.com/xenserver/packer-builder-xenserver/builder/xenserver/common.(*StepTypeBootCommand).Run(0xc0001b9260, 0x195c2c0, 0xc00038e4c0, 0x195c980, 0xc0000ba930, 0x0)
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:        /home/ddelnano/go/src/github.com/xenserver/packer-builder-xenserver/builder/xenserver/common/step_type_boot_command.go:39 +0x18de
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: github.com/hashicorp/packer/helper/multistep.(*BasicRunner).Run(0xc0000baae0, 0x195c2c0, 0xc00038e4c0, 0x195c980, 0xc0000ba930)
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:        /home/ddelnano/.gvm/pkgsets/go1.14.7/global/pkg/mod/github.com/hashicorp/packer@v1.6.5/helper/multistep/basic_runner.go:70 +0x22b
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso.(*Builder).Run(0xc0003ee900, 0x195c2c0, 0xc00038e4c0, 0x1964e80, 0xc0001147e0, 0x193baa0, 0xc000384620, 0x0, 0x0, 0xc000353bd0, ...)
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:        /home/ddelnano/go/src/github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso/builder.go:303 +0xe74
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: github.com/hashicorp/packer/packer/rpc.(*BuilderServer).Run(0xc00038e040, 0x1, 0xc00001e020, 0x0, 0x0)
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:        /home/ddelnano/.gvm/pkgsets/go1.14.7/global/pkg/mod/github.com/hashicorp/packer@v1.6.5/packer/rpc/builder.go:117 +0x1bd
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: reflect.Value.call(0xc000380420, 0xc000096090, 0x13, 0x15e79e3, 0x4, 0xc000353f08, 0x3, 0x3, 0x164a8b0, 0xc00004f800, ...)
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:        /home/ddelnano/.gvm/gos/go1.14.7/src/reflect/value.go:460 +0x8ab
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: reflect.Value.Call(0xc000380420, 0xc000096090, 0x13, 0xc00045d708, 0x3, 0x3, 0xc00041ee98, 0xc00049c238, 0x45f410)
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:        /home/ddelnano/.gvm/gos/go1.14.7/src/reflect/value.go:321 +0xb4
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: net/rpc.(*service).call(0xc00038e080, 0xc0003960f0, 0xc00009a060, 0xc00009a070, 0xc000390200, 0xc00000e680, 0x134f660, 0xc00001e01c, 0x18a, 0x1322da0, ...)
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:        /home/ddelnano/.gvm/gos/go1.14.7/src/net/rpc/server.go:377 +0x17f
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin: created by net/rpc.(*Server).ServeCodec
2021/01/13 21:36:13 packer-builder-xenserver-iso plugin:        /home/ddelnano/.gvm/gos/go1.14.7/src/net/rpc/server.go:474 +0x42b
ddelnano commented 3 years ago

The ssh agent error (which I was investigating before I noticed the type assertion issue) ended up not being an issue. Once the type assertion issue was fixed, I had a successful build even with SSH_AUTH_SOCK set.