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

Add Support for storing logs to Google Cloud Storage #552

Merged
merged 2 commits into from
Aug 14, 2023

Conversation

khrm
Copy link
Contributor

@khrm khrm commented Aug 7, 2023

Changes

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you review them:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Tested your changes locally (if this is a code change)
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user-facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contain the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Add Support for storing logs to Google Cloud Storage. Set LogType to "GCS",
pass `GOOGLE_APPLICATION_CREDENTIALS` environment variable  and attach 
the file in the location pointed by `GOOGLE_APPLICATION_CREDENTIALS` variable.

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Aug 7, 2023
@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesnt merit a release note. labels Aug 7, 2023
Copy link
Contributor Author

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 7, 2023
@khrm
Copy link
Contributor Author

khrm commented Aug 7, 2023

/assign @enarha @sayan-biswas

@khrm khrm force-pushed the f/gcs branch 3 times, most recently from 76f86d0 to fd39398 Compare August 8, 2023 08:03
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 8, 2023
@khrm khrm force-pushed the f/gcs branch 2 times, most recently from 19048db to 6884a65 Compare August 10, 2023 10:56
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 10, 2023
@khrm khrm force-pushed the f/gcs branch 3 times, most recently from 7bb8862 to 1d53de3 Compare August 10, 2023 12:17
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 10, 2023
Copy link
Contributor

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

Generally looks good - my comments are mainly nits on function names and log messages. It took me a while to understand what a lot of the test code was doing.

As a follow up, we should update https://github.com/tektoncd/results/blob/main/docs/DEVELOPMENT.md to include guidance on how to emulate the different log storage providers. Alternatively, we could add a separate doc that focuses on this topic.

EDIT: filed #559 for the follow up.

@@ -29,6 +29,9 @@ type Config struct {
LOGS_BUFFER_SIZE int `mapstructure:"LOGS_BUFFER_SIZE"`
LOGS_PATH string `mapstructure:"LOGS_PATH"`

GCS_BUCKET_NAME string `mapstructure:"GCS_BUCKET_NAME"`
STORAGE_EMULATOR_HOST string `mapstructure:"STORAGE_EMULATOR_HOST"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intended to be GCS specific? If so, please prefix this config item with GCS:

Suggested change
STORAGE_EMULATOR_HOST string `mapstructure:"STORAGE_EMULATOR_HOST"`
GCS_STORAGE_EMULATOR_HOST string `mapstructure:"GCS_STORAGE_EMULATOR_HOST"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GCS driver uses this exact value. It uses the STORAGE_EMULATOR_HOST environment variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment above with this information.

pkg/api/server/v1alpha2/log/gcs.go Outdated Show resolved Hide resolved
pkg/api/server/v1alpha2/log/gcs.go Outdated Show resolved Hide resolved
pkg/api/server/v1alpha2/log/gcs_test.go Show resolved Hide resolved
pkg/api/server/v1alpha2/log/gcs_test.go Outdated Show resolved Hide resolved
pkg/api/server/v1alpha2/log/gcs_test.go Outdated Show resolved Hide resolved
pkg/api/server/v1alpha2/log/gcs_test.go Outdated Show resolved Hide resolved
Comment on lines +72 to +74
if cfg.STORAGE_EMULATOR_HOST != "" {
creds, _ = google.CredentialsFromJSON(ctx, []byte(`{"type": "service_account", "project_id": "my-project-id"}`))
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a project that emulates GCS storage (unauthenticated)? Is this something useful for contributors who want to test this without launching on GCP/GKE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. There is one storage emulator in python. A couple of storage in go.
This one works fine: https://github.com/fullstorydev/emulators

@khrm khrm force-pushed the f/gcs branch 2 times, most recently from 77656fc to be8a16e Compare August 11, 2023 10:01
Logs can be stored to GCS. GOOGLE_APPLICATION_CREDENTIALS environment
variable needs to be passed to api-server alongwith bucketname.
Copy link
Contributor

@enarha enarha left a comment

Choose a reason for hiding this comment

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

Apart from the test issue, the rest is LGTM.

)

// This function is to create a replay or record http client depending
// upon whether a -record flag was passed durin testing
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: during

pkg/api/server/v1alpha2/log/gcs_test.go Show resolved Hide resolved
@enarha
Copy link
Contributor

enarha commented Aug 14, 2023

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 14, 2023
@tekton-robot tekton-robot merged commit 876bbf2 into tektoncd:main Aug 14, 2023
5 checks passed
@khrm khrm deleted the f/gcs branch September 6, 2023 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants