Skip to content

Fixes crash when writing kubeconfig with tctl auth sign --tar#34612

Merged
tcsc merged 5 commits intomasterfrom
tcsc/tar-writer-support-remove
Nov 21, 2023
Merged

Fixes crash when writing kubeconfig with tctl auth sign --tar#34612
tcsc merged 5 commits intomasterfrom
tcsc/tar-writer-support-remove

Conversation

@tcsc
Copy link
Copy Markdown
Contributor

@tcsc tcsc commented Nov 15, 2023

Prior this patch, using the --format=kubernetes option with
tctl auth sign --tar would crash due to the filesystem abstraction
used to capture the tctl output files did not support removing or
stating files.

In addition, the kubeconfig file writer did not use the filesystem
abstraction given to the identity file writer, but would only write
files out to the host filesystem. This means that any kubeconfig
file oututs would not be included in the output tarfile stream.

This patch:

  • Updates the tarfile filesystem abstraction to buffer files created
    by tctl until the write is complete, and then stream the archive
    out at the end. This gives sensible semabtics to the remove and
    stat operations.
  • Updates the kubeconfig writer to take a filesystem abstraction
    compatible with the one used by the identity file writer, so that
    the kubeconfg file output is correctly caught by the tarfile writer.

Fixes: #34371
Changelog: Fixes crash when writing kubeconfig with tctl auth sign --tar

Prior this patch, using the `--format=kubernetes` option with
`tctl auth sign --tar` would crash due to the filesystem abstraction
used to capture the `tctl` output files did not support removing or
`stat`ing files.

In addition, the kubeconfig file writer did not use the filesystem
abstraction given to the identity file writer, but would only write
files out to the host filesystem. This means that any kubeconfig
file oututs would not be included in the output tarfile stream.

This patch:
 * Updates the tarfile filesystem abstraction to buffer files created
   by `tctl` until the write is complete, and then stream the archive
   out at the end. This gives sensible semabtics to the remove and
   stat operations.
 * Updates the kubeconfig writer to take a filesystem abstraction
   compatible with the one used by the identity file writer, so that
   the kubeconfg file output is correctly caught by the tarfile writer.

Fixes: #34371
Changelog: Fixes crash when writing kubeconfig with `tctl auth sign --tar`
@github-actions github-actions Bot added kubernetes-access size/md tctl tctl - Teleport admin tool labels Nov 15, 2023
@tcsc tcsc marked this pull request as draft November 15, 2023 10:10
@tcsc tcsc marked this pull request as ready for review November 15, 2023 12:00
@github-actions github-actions Bot requested a review from strideynet November 15, 2023 12:01
return os.WriteFile(name, data, perm)
}

// ReadFile reads the file at tpath `name`, returning
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfinished comment.

@r0mant r0mant requested review from hugoShaka and removed request for gabrielcorado and probakowski November 20, 2023 21:24
@r0mant
Copy link
Copy Markdown
Collaborator

r0mant commented Nov 20, 2023

@tcsc Please backport this to v14 and v13.

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from strideynet November 20, 2023 21:49
@tcsc tcsc enabled auto-merge November 21, 2023 05:41
@tcsc tcsc added this pull request to the merge queue Nov 21, 2023
Merged via the queue into master with commit 34a5ab7 Nov 21, 2023
@tcsc tcsc deleted the tcsc/tar-writer-support-remove branch November 21, 2023 06:21
@public-teleport-github-review-bot
Copy link
Copy Markdown

@tcsc See the table below for backport results.

Branch Result
branch/v10 Failed
branch/v13 Failed
branch/v14 Failed

github-merge-queue Bot pushed a commit that referenced this pull request Nov 21, 2023
…#34822)

* [v13] Fixes crash when writing kubeconfig with `tctl auth sign --tar`

Backports #34612

Prior this patch, using the `--format=kubernetes` option with
`tctl auth sign --tar` would crash due to the filesystem abstraction
used to capture the `tctl` output files did not support removing or
`stat`ing files.

In addition, the kubeconfig file writer did not use the filesystem
abstraction given to the identity file writer, but would only write
files out to the host filesystem. This means that any kubeconfig
file oututs would not be included in the output tarfile stream.

This patch:
 * Updates the tarfile filesystem abstraction to buffer files created
   by `tctl` until the write is complete, and then stream the archive
   out at the end. This gives sensible semabtics to the remove and
   stat operations.
 * Updates the kubeconfig writer to take a filesystem abstraction
   compatible with the one used by the identity file writer, so that
   the kubeconfg file output is correctly caught by the tarfile writer.

Fixes: #34371
Changelog: Fixes crash when writing kubeconfig with `tctl auth sign --tar`

* Fix backport test detritus
github-merge-queue Bot pushed a commit that referenced this pull request Dec 5, 2023
…#34874)

Backports #34612

Prior this patch, using the `--format=kubernetes` option with
`tctl auth sign --tar` would crash due to the filesystem abstraction
used to capture the `tctl` output files did not support removing or
`stat`ing files.

In addition, the kubeconfig file writer did not use the filesystem
abstraction given to the identity file writer, but would only write
files out to the host filesystem. This means that any kubeconfig
file oututs would not be included in the output tarfile stream.

This patch:
 * Updates the tarfile filesystem abstraction to buffer files created
   by `tctl` until the write is complete, and then stream the archive
   out at the end. This gives sensible semabtics to the remove and
   stat operations.
 * Updates the kubeconfig writer to take a filesystem abstraction
   compatible with the one used by the identity file writer, so that
   the kubeconfg file output is correctly caught by the tarfile writer.

Fixes: #34371
Changelog: Fixes crash when writing kubeconfig with `tctl auth sign --tar`

* Fix backport test detritus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tctl sign auth --tar is failing to run with kubernetes output format

3 participants