porter icon indicating copy to clipboard operation
porter copied to clipboard

State file unpacking fails if an empty state file exists

Open sgettys opened this issue 3 years ago • 1 comments

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:

  1. 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)

sgettys avatar Aug 17 '22 17:08 sgettys

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

VinozzZ avatar Aug 17 '22 20:08 VinozzZ

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

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.

sgettys avatar Aug 17 '22 22:08 sgettys

Closed by #2306.

github-actions[bot] avatar Aug 19 '22 15:08 github-actions[bot]