State file unpacking fails if an empty state file exists
Describe the bug
I'm getting the following error when trying to use a porter bundle that has "state" provided in the manifest when running in the operator: could not create a new gzip reader for the statefile: unexpected EOF This is when using "state" to store off terraform tfstate files ex:
state:
- name: tfstate path: terraform/terraform.tfstate
- name: tfvars path: terraform/terraform.tfvars.json This works when setting the tfstate file as a bundle output and using it that way. Running this on beta.2 in the operator
To Reproduce
Steps to reproduce the behavior:
- Install a porter bundle in the operator that has "state" defined in the porter.yaml
Expected behavior
Porter should install successfully for bundles with "state" in the porter.yaml that run in the operator
Version
Copy the output of porter version below
porter v1.0.0-beta.2 (b2f23785)
Hey @sgettys , I just created a simple bundle just to make sure that I understand the scenario. Is this what you are trying to do? If not, do you mind to share your use case with me?
schemaVersion: 1.0.0-alpha.1
name: examples/porter-hello
version: 0.2.0
description: "An example Porter configuration"
registry: ghcr.io/getporter
state:
- name: magic_file
path: magic.txt
mixins:
- exec
install:
- exec:
description: "Install Hello World"
command: touch
arguments:
- /cnab/app/magic.txt
- exec:
description: "Print magic"
command: cat
arguments:
- magic.txt
This bundle seems to be working for me locally
Hey @sgettys , I just created a simple bundle just to make sure that I understand the scenario. Is this what you are trying to do? If not, do you mind to share your use case with me?
schemaVersion: 1.0.0-alpha.1 name: examples/porter-hello version: 0.2.0 description: "An example Porter configuration" registry: ghcr.io/getporter state: - name: magic_file path: magic.txt mixins: - exec install: - exec: description: "Install Hello World" command: touch arguments: - /cnab/app/magic.txt - exec: description: "Print magic" command: cat arguments: - magic.txtThis bundle seems to be working for me locally
This only occurs when trying to install in the operator. The behavior can be replicated locally if you are able to get the /porter/state.tgz into the bundle environment, I haven't tried manually creating that in the docker file but that would probably recreate this as well. Basically the kubernetes driver mounts the /porter/state.tgz into the pod as a volume mount which seems to create a blank file in the pod. If the state keyword is in the porter.yaml then porter will try to read in that tar and hit the various error conditions around it being an empty or blank file. I can try to figure out a local repro for this as well but that would be outside of the normal porter workflow for sure and would probably require manually creating the state.tgz in the docker file template for the bundle at build time.
Closed by #2306.