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

Docker service import crash - unexpected eof #258

Open
brandonbumgarner opened this issue Apr 1, 2020 · 8 comments
Open

Docker service import crash - unexpected eof #258

brandonbumgarner opened this issue Apr 1, 2020 · 8 comments

Comments

@brandonbumgarner
Copy link

Terraform version

0.11.14

Affected Resource(s)

  • docker_service

Terraform Configuration Files

terraform {
  backend "s3" {
    bucket                      = "bucket"
    region                      = "region"
    profile                     = "profile"
    shared_credentials_file     = "credentials"
  }
}

provider "docker" {
  version = "~> 2.7.0"
  host                          = "tcp://${var.environment}.${var.domain}:9999/"
}

variable "domain" {
  default           = "domain"
}

variable "environment" {}

resource "docker_service" "service" {}

Panic Output

https://gist.github.com/brandonbumgarner/163a3145f7d1613a4d55dadc5dd0d0f2

Expected Behavior

The service should be imported into a state file stored in S3.

Actual Behavior

Terraform crashes. It seems like the state is captured, but when the state is refreshed, it crashes. The crash.log shows the docker inspect command output(stripped from gist, but in the actual it is there). So it seems that it is communicating with the docker node and getting the data.

Please keep in mind I have stripped the service id and any "sensitive" information from the logs and output. In the actual logs and output it has the specific environment, domain, service id, etc. For example: service-id is actually the id of a service that exists in that environment

terraform import -var "environment=env" docker_service.service service-id
docker_service.service: Importing from ID "service-id"...
docker_service.service: Import complete!
  Imported docker_service (ID: service-id)
docker_service.service: Refreshing state... (ID: service-id)

Error: docker_service.service (import id: service-id): 1 error occurred:
	* import docker_service.service result: service-id: docker_service.service: unexpected EOF

Steps to Reproduce

terraform init -var "environment=env" -backend-config="key=folder/service.state"
terraform import -var "environment=env" docker_service.service service-id

Important Factoids

Right now I have the Docker provider pinned to 2.7.0, but have also tried 2.6.0. This had been working for most of our other services, but stopped working last week without any changes to the tf file.

@mavogel
Copy link
Contributor

mavogel commented Apr 13, 2020

Hmm, strange, so it did not work with 2.6.0 either?

@brandonbumgarner
Copy link
Author

That is correct. It had been working up until about 3 weeks ago with no changes to the files I had been using for the service imports. Now, it crashes consistently no matter what service I try to import.

@Novex
Copy link
Contributor

Novex commented Apr 20, 2020

I just tried upgrading to 2.7.0 and hit the same error as well on state refresh during a terraform apply

 Error: Error refreshing state: 1 error occurred:
 	* docker_container.iis_services: 1 error occurred:
 	* docker_container.iis_services: docker_container.iis_services: unexpected EOF

Terraform 0.11.14 as well, though I moved back a version to 2.6.0 and that is working for me.

We're connecting to docker on Windows Server 2016 as well if that helps, the server version is pretty old.

Server Version: 1.12.2-cs2-ws-beta
Default Isolation: process
Kernel Version: 10.0 14393 (14393.3630.amd64fre.rs1_release.200407-1730)
Operating System: Windows Server 2016 Datacenter
OSType: windows

@sujith-apivista
Copy link

In the following line, I believe Go will throw a panic if either of those values have not been initialized.

if string(service.Endpoint.Spec.Mode) == "" && string(service.Spec.EndpointSpec.Mode) == "" {

Could that be the issue?

@brandonbumgarner
Copy link
Author

@Novex I tried to roll back to 2.6.0 and that did not work for me. This was actually one of the first things that I had tried, but thanks for providing this info.

@sujith-apivista Thanks for pointing this out! It seems that none of the services I had left to import had endpoints specified. After adding the endpoint spec mode to the service json, it imported successfully. I would suggest that a fix be implemented in the provider to handle a condition where endpoint spec might not be specified since it is not required by Docker. Thanks for your comments everyone!

  "EndpointSpec": {
    "Mode": "vip"
  }

@Novex
Copy link
Contributor

Novex commented Apr 23, 2020

I could have hit a different issue - is there any way to see the actual panic error thrown by the provider?

@brandonbumgarner
Copy link
Author

@Novex I provided the crash log which has the panic error shown. Are you looking for that or something different?

@Novex
Copy link
Contributor

Novex commented Apr 27, 2020

Thanks for clarifying - I didn't realise the 'unexpected eof' was a generic something's wrong error. The error I found in my log file is different to yours so I've definitely got a different problem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants