Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally save logs as output #243

Merged
merged 5 commits into from
Mar 10, 2021
Merged

Optionally save logs as output #243

merged 5 commits into from
Mar 10, 2021

Conversation

carolynvs
Copy link
Contributor

@carolynvs carolynvs commented Mar 2, 2021

When action.SaveLogs is set, a copy of the invocation image logs are saved as an output named io.cnab.outputs.invocationImageLogs. The logs are copied as they are written to a logfile, which after the bundle completes, are saved as an output when the claim result is saved.

CNAB tools control if logs are saved or not, defaulting to false.

This is very useful for "remote" bundle execution, like when it's run by the kubernetes driver. The user can see the logs from a run without having to figure out which pod to log, and its stored with the other installation data.

This PR also fixes a bug in the FileSystemStore where listing outputs was not returning any outputs with a period in the name.

When action.SaveLogs is set, a copy of the invocation image logs are
saved as an output named io.cnab.outputs.invocationImageLogs.

The logs are copied as they are written to a logfile, which after the
bundle completes, are saved as an output when the claim result is saved.

Signed-off-by: Carolyn Van Slyck <[email protected]>
If an output was generated that isn't defined in the bundle, e.g. the
driver or tool added the output, then do not throw an error when it is
read. When reading through the claimstore only sensitive values are
encrypted, so if it doesn't have a definition, it was stored without
being encrypted.

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs carolynvs marked this pull request as ready for review March 3, 2021 17:11
Copy link
Member

@vdice vdice left a comment

Choose a reason for hiding this comment

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

LGTM!

})

t.Run("output has no digest", func(t *testing.T) {
t.Run("output has no meatdata", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this is an easter egg for PR reviewers 🥩 and I almost don't want to change it buuut... s/meatdata/metadata?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am pro meatdata

@carolynvs
Copy link
Contributor Author

I found a bug with how the filesytem store lists outputs. You wouldn't have noticed unless you were working with an output with a period in the name. So this PR works but if you are using filesystem store, then there's a bug. I'm fixing now.

When listing documents in FileSystemStore with the file extension filter
set to "", any document with an extension was being filtered out. This
causes problems when an output (which doesn't require an extension) has
a period in the name, such as the logs output, or mydata.json.

I'v changed the logic so that when no filter is set for the file
extension, we return all files in the directory.

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs
Copy link
Contributor Author

@vdice Can you take one more look? I just fixed that bug in FileSystemStore. Seemed like it should be fixed here since without it, when you list outputs on the filesystem, it was missing the logs.

@carolynvs
Copy link
Contributor Author

Oh my goodness, sorry one more fix for this FileSystemStore bug. 🤦‍♀️

The FileSystemStore was removing the file extension from output names
but outputs can be generated with file extensions. So when there isn't a
file extension filter specified for an item, such as outputs, leave the
file extension as-is.

We will still remove the .json extension for documents such as claims.

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs
Copy link
Contributor Author

Sorry about that, there were a few changes needed to the test and FileSystemStore so that when you list outputs, you get the original filenames. For example, if I save an output named "users.json", when I list outputs, I should see "users.json" as the output name.

I can't spell but we shall miss you meatdata...

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs carolynvs merged commit 47accd8 into cnabio:main Mar 10, 2021
@carolynvs carolynvs deleted the save-logs branch March 10, 2021 20:59
simongdavies pushed a commit to simongdavies/cnab-go that referenced this pull request Mar 31, 2021
* Optionally save logs as output

When action.SaveLogs is set, a copy of the invocation image logs are
saved as an output named io.cnab.outputs.invocationImageLogs.

The logs are copied as they are written to a logfile, which after the
bundle completes, are saved as an output when the claim result is saved.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Handle reading undefined outputs

If an output was generated that isn't defined in the bundle, e.g. the
driver or tool added the output, then do not throw an error when it is
read. When reading through the claimstore only sensitive values are
encrypted, so if it doesn't have a definition, it was stored without
being encrypted.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Fix empty file extension bug in FileSystemStore

When listing documents in FileSystemStore with the file extension filter
set to "", any document with an extension was being filtered out. This
causes problems when an output (which doesn't require an extension) has
a period in the name, such as the logs output, or mydata.json.

I'v changed the logic so that when no filter is set for the file
extension, we return all files in the directory.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Do not remove file extension from output names

The FileSystemStore was removing the file extension from output names
but outputs can be generated with file extensions. So when there isn't a
file extension filter specified for an item, such as outputs, leave the
file extension as-is.

We will still remove the .json extension for documents such as claims.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Fix meatdata

I can't spell but we shall miss you meatdata...

Signed-off-by: Carolyn Van Slyck <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants