Skip to content

Same chart saved at different times has different digest #8212

@pmengelbert

Description

@pmengelbert

After investigating this issue, I have tracked it down to a change that was made in release v.3.0.3. Here is a demonstration and a way you can reproduce:

export HELM_EXPERIMENTAL_OCI=1
curl -s https://get.helm.sh/helm-v3.0.3-linux-amd64.tar.gz | tar xzvf - -C /tmp/
rm -rf "${HOME}/.cache/helm/registry"
/tmp/linux-amd64/helm create /tmp/mychart
/tmp/linux-amd64/helm chart save /tmp/mychart first:latest
sleep 1
/tmp/linux-amd64/helm chart save /tmp/mychart second:latest

The output is like so:

$ /tmp/linux-amd64/helm chart save /tmp/mychart first:latest
ref:     first:latest
digest:  470a1e836bbef03577c15cf44c80f6d17fd3f9a953beba4789ff4fe081a9e3fa
...

$ /tmp/linux-amd64/helm chart save /tmp/mychart second:latest
ref:     second:latest
digest:  9b0f939702799c192221d8bb1baffbfca0ec006a4144fbae27d828746a804717
...

This is a result of the timestamp being included in pkg/chartutil/save.go:

func writeToTar(out *tar.Writer, name string, body []byte) error {
	// TODO: Do we need to create dummy parent directory names if none exist?
	h := &tar.Header{
		Name:    name,
		Mode:    0644,
		Size:    int64(len(body)),
		ModTime: time.Now(),   // <-------- this line was added in release 3.0.3
	}
	if err := out.WriteHeader(h); err != nil {
		return err
	}
	_, err := out.Write(body)
	return err
}

The timestamp was added as a fix to #4158, so that archives created with helm package would bear the correct timestamp. However, this breaks the correct functioning of helm chart save, which should produce identical digests for identical content. I am preparing a PR to resolve this issue, which will leave the functionality for helm package in tact while fixing it for helm chart save.

helm version
version.BuildInfo{Version:"v3.1.1", GitCommit:"afe70585407b420d0097d07b21c47dc511525ac8", GitTreeState:"clean", GoVersion:"go1.13.8"}
kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:23:11Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
error: You must be logged in to the server (the server has asked for the client to provide credentials)

Cloud provider is irrelevant in this case

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions