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

Call gcloud auth activate-service-account if GOOGLE_APPLICATION_CREDENTIALS is set #1757

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

imjasonh
Copy link
Member

This used to be done by our own gsutil image. When that image was replaced
by the vanilla google/cloud-sdk image, this documented behavior broke.

By adding this as a step added by the resource, the behavior is
maintained without needing to maintain our own image to perform
activation.

Fixes #1748
/hold needs e2e test
cc @dustym

Changes

Submitter Checklist

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

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Fix regression in v0.9 whereby GOOGLE_APPLICATION_CREDENTIALS were ignored when using the GCS resource

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Dec 16, 2019
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 16, 2019
@@ -26,7 +26,14 @@ import (
corev1 "k8s.io/api/core/v1"
)

func Test_Invalid_NewStorageResource(t *testing.T) {
const activateServiceAccountScript = `#!/usr/bin/env bash
Copy link
Member Author

Choose a reason for hiding this comment

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

NB: This is copied here because the other version is not exported (and shouldn't be), and tests are in package v1alpha1_test.

Is there a preferred way to maintain these invariants together?

Copy link
Member

Choose a reason for hiding this comment

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

Should this be in an external package ? (as it's solely related to gcs, maybe it should be in the apis package at all ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like it not to be exported anywhere at all. But I guess if I have to, a separate package is better.

At least when resources are pluggable all this will leave this repo, right?

Copy link
Member

Choose a reason for hiding this comment

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

@imjasonh that's kinda my thought yeah 👼

Copy link
Member

Choose a reason for hiding this comment

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

+1 for separate package. Seems like the best option for now!

Copy link
Member Author

Choose a reason for hiding this comment

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

In the end I decided to make the resource add a single step with a script that activates the SA then calls gsutil cp/gsutil rsync, and to just put the full details of the script into each test.

When this gets extensible-ized this will all get cleaner tests will be split out with the code.

@ghost
Copy link

ghost commented Dec 16, 2019

/lgtm

@tekton-robot tekton-robot assigned ghost Dec 16, 2019
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 16, 2019
Copy link
Member

@dibyom dibyom left a comment

Choose a reason for hiding this comment

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

LGTM once the tests pass!
/approve

@@ -226,14 +261,14 @@ func Test_GetInputSteps(t *testing.T) {
if tc.wantErr && err == nil {
t.Fatalf("Expected error to be %t but got %v:", tc.wantErr, err)
}
if d := cmp.Diff(gotSpec.GetStepsToPrepend(), tc.wantSteps); d != "" {
t.Errorf("Error mismatch between download containers spec: %s", d)
if d := cmp.Diff(tc.wantSteps, gotSpec.GetStepsToPrepend()); d != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@@ -26,7 +26,14 @@ import (
corev1 "k8s.io/api/core/v1"
)

func Test_Invalid_NewStorageResource(t *testing.T) {
const activateServiceAccountScript = `#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

+1 for separate package. Seems like the best option for now!

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 17, 2019
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 17, 2019
@imjasonh imjasonh force-pushed the activate-sa branch 3 times, most recently from 902e539 to a5b2cd5 Compare December 17, 2019 17:39
…DENTIALS is set

This used to be done by the gsutil image. When that image was replaced
by the vanilla google/cloud-sdk image, this documented behavior broke.

By adding this to the step added by the resource, the behavior is
maintained without needing to maintain our own image to perform
activation.
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Just one naive question 👼

@@ -50,7 +51,7 @@ require (
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20191110163157-d32e6e3b99c4 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
google.golang.org/api v0.10.0 // indirect
google.golang.org/api v0.10.0
Copy link
Member

Choose a reason for hiding this comment

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

why is this not indirect anymore ? same for cloud.google.com/go/storage above, I don't see any imports in our code for those, shouldn't this mean they should be indirect ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have no idea. I just build and commit whatever Go thinks is right. 🤷‍♂️

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom, 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

@vdemeester
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 18, 2019
@tekton-robot tekton-robot merged commit cf8705b into tektoncd:master Dec 18, 2019
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. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insufficient Permission error when using a gcs PipelineResource
5 participants