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

Switch away from gcloud deprecated flags in compute resource listings #50398

Merged
merged 1 commit into from
Aug 30, 2017

Conversation

pci
Copy link

@pci pci commented Aug 9, 2017

What is fixed

Remove deprecated gcloud compute flags, see linked issue.

Which issue this PR fixes:

fixes #49673

Special notes for your reviewer:

The change in gcloudComputeResourceList in test/e2e/framework/ingress_utils.go isn't strictly needed as currently no affected resources are called on within that file, however the function has the potential to access affected resources so I covered it as well. Happy to change if deemed unnecessary.

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 9, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @pci. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 9, 2017
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels Aug 9, 2017
@pci pci force-pushed the gcloud-compute-list branch 2 times, most recently from 4fa18d5 to 60825f9 Compare August 9, 2017 21:37
@liggitt
Copy link
Member

liggitt commented Aug 10, 2017

/unassign
/assign @cjcullen

@k8s-ci-robot k8s-ci-robot assigned cjcullen and unassigned liggitt Aug 10, 2017
@ncdc
Copy link
Member

ncdc commented Aug 10, 2017

/unassign

@dims
Copy link
Member

dims commented Aug 17, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 17, 2017
@cblecker
Copy link
Member

/cc @shyamjvs

@cblecker
Copy link
Member

/assign @ixdy

@@ -75,10 +75,10 @@ echo "Provider: ${KUBERNETES_PROVIDER:-}"
# provided.
gcloud-compute-list instance-templates --regexp="${INSTANCE_PREFIX}.*"
gcloud-compute-list instance-groups ${ZONE:+"--zones=${ZONE}"} --regexp="${INSTANCE_PREFIX}.*"
gcloud-compute-list instances ${ZONE:+"--zones=${ZONE}"} --regexp="${INSTANCE_PREFIX}.*"
gcloud-compute-list instances --filter="${ZONE:+"zone=(${ZONE}) AND"} name ~ '${INSTANCE_PREFIX}.*'"
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this works with the first double apostrophe closed by the immediate next one?

Copy link
Author

Choose a reason for hiding this comment

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

Here are the tests I ran:

$ test="${ZONE:+"zone=(${ZONE}) AND"} name ~ '${INSTANCE_PREFIX}.*'"; echo $test
name ~ '.*'
$ ZONE=foo; test="${ZONE:+"zone=(${ZONE}) AND"} name ~ '${INSTANCE_PREFIX}.*'"; echo $test
zone=(foo) AND name ~ '.*'
$ INSTANCE_PREFIX=bar; test="${ZONE:+"zone=(${ZONE}) AND"} name ~ '${INSTANCE_PREFIX}.*'"; echo $test
name ~ 'bar.*'
$ ZONE=foo;INSTANCE_PREFIX=bar; test="${ZONE:+"zone=(${ZONE}) AND"} name ~ '${INSTANCE_PREFIX}.*'"; echo $test
zone=(foo) AND name ~ 'bar.*'

run on my local machine:

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.

@@ -761,9 +761,20 @@ func (cont *GCEIngressController) deleteStaticIPs() error {
func gcloudComputeResourceList(resource, regex, project string, out interface{}) {
// gcloud prints a message to stderr if it has an available update
// so we only look at stdout.
var regexFlag string
Copy link
Member

Choose a reason for hiding this comment

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

nit: s/regexFlag/regexpFlag/

Copy link
Author

@pci pci Aug 17, 2017

Choose a reason for hiding this comment

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

Absolutely, sorry for the typo.

Also as this is my first kubernetes' PR, do reviewers prefer changes as a second commit, or squashed into the first and rebased on an up-to-date master ?

Copy link
Member

Choose a reason for hiding this comment

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

Usually it's better to add a new commit on each review round, so previous comments are not lost and also it's easier to verify if comments have been addressed.
However, it's ok to squash for simple PRs.

Copy link
Author

Choose a reason for hiding this comment

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

If an additional commit is the standard way, I'll go with that.

Update pushed, I realised filterFlag is a better name for the flag given it's the flag applying the filter and not always a regex.

@@ -761,9 +761,20 @@ func (cont *GCEIngressController) deleteStaticIPs() error {
func gcloudComputeResourceList(resource, regex, project string, out interface{}) {
// gcloud prints a message to stderr if it has an available update
// so we only look at stdout.
var regexFlag string

// --regex flag is deprecated for these resources:
Copy link
Member

Choose a reason for hiding this comment

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

--regexp

Copy link
Author

Choose a reason for hiding this comment

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

👍 Same as above

@shyamjvs
Copy link
Member

Also there are usages of the regexp flag in cluster/gce/util.sh. Can you fix them also?

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 17, 2017
@pci
Copy link
Author

pci commented Aug 17, 2017

@shyamjvs How did I miss those?! My ag skills let me down. Thanks for the spot, update pushed.

Will the automated tests cover these lines or is there some manual testing I could do?

@shyamjvs
Copy link
Member

The automated tests should likely cover it (though I'm not sure if they'd pass as the gcloud version currently being used for those tests has been pinned at 163.0.0).
Anyway, testing it locally shouldn't be hard - just try starting a small cluster (using cluster/kube-up.sh) and then stopping it (using cluster/kube-down.sh).

@pci
Copy link
Author

pci commented Aug 29, 2017

@shyamjvs Ah, thanks. The logs looked like a timeout.

@shyamjvs
Copy link
Member

/lgtm
@ixdy Wanna take a final look?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 29, 2017
@ixdy
Copy link
Member

ixdy commented Aug 29, 2017

/retest

@pci
Copy link
Author

pci commented Aug 30, 2017

/test pull-kubernetes-e2e-gce-etcd3

(failed due to "Backend Error" in gcloud.compute.instance-groups.managed.create call)

Copy link
Member

@ixdy ixdy left a comment

Choose a reason for hiding this comment

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

thanks for taking this on!

--zones "${ZONE}" --project "${PROJECT}" \
--regexp "${NODE_INSTANCE_PREFIX}-.+" \
--project "${PROJECT}" \
--filter "name ~ '${NODE_INSTANCE_PREFIX}-.+' AND zone:(${ZONE})" \
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 it sometimes zone:(${ZONE}) and sometimes zone=(${ZONE})?

Copy link
Member

Choose a reason for hiding this comment

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

ah, I guess :( matches patterns, whereas =( matches exactly, per https://cloud.google.com/sdk/gcloud/reference/topic/filters.

this is probably fine, though I'm guessing =( is maybe more correct?

Copy link
Author

@pci pci Aug 30, 2017

Choose a reason for hiding this comment

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

@ixdy the reasoning in full is here but : seems to be the way gcloud pushes as = flat out doesn't work for zones

Copy link
Author

Choose a reason for hiding this comment

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

@ixdy Very sorry - I missed one zone here I'll fix that

Copy link
Author

Choose a reason for hiding this comment

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

ok, there now shouldn't be any occurrences of zone= inside a filter

@ixdy
Copy link
Member

ixdy commented Aug 30, 2017

/lgtm

@ixdy
Copy link
Member

ixdy commented Aug 30, 2017

/test pull-kubernetes-e2e-gce-bazel

@roberthbailey
Copy link
Contributor

/approve

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 30, 2017
@pci
Copy link
Author

pci commented Aug 30, 2017

@ixdy No problem, thank you (and shyamjvs & roberthbailey) for your efforts in reviewing and moving this forward.

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 30, 2017
@pci
Copy link
Author

pci commented Aug 30, 2017

@ixdy @shyamjvs @roberthbailey Once again my apologies - There was still a zone= filter here which would have returned zero rows for EXPECTED_NUM_NODES which isn't correct, I've updated it to use zone: as per this comment.

Famous last words but I hope that's the last one.

@ixdy
Copy link
Member

ixdy commented Aug 30, 2017

ok, so zone: is correct, but so is region=?
I love gcloud so much. :)

@pci
Copy link
Author

pci commented Aug 30, 2017

@ixdy that definitely seems to be the case, although the deprecation warning is the only documentation I've found on it! Even if they fix the behaviour of zone= in the future, zone: should continue to work so we're covered from that side.

@ixdy
Copy link
Member

ixdy commented Aug 30, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 30, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ixdy, pci, roberthbailey, shyamjvs

Associated issue: 49673

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@pci
Copy link
Author

pci commented Aug 30, 2017

/test pull-kubernetes-e2e-gce-bazel

Failed with "no such file"

@ixdy
Copy link
Member

ixdy commented Aug 30, 2017

yeah. :\

the good news is that gce-bazel isn't blocking at the moment.

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 47054, 50398, 51541, 51535, 51545)

@k8s-github-robot k8s-github-robot merged commit 04bc4ec into kubernetes:master Aug 30, 2017
@pci
Copy link
Author

pci commented Aug 30, 2017

Woo! Thanks all.

I'll look to open the cherry-pick PRs to 1.7, 1.6 and 1.5 tonight (UK time), let me know if that isn't the right next step.

k8s-github-robot pushed a commit that referenced this pull request Sep 2, 2017
…stream-release-1.7

Automatic merge from submit-queue

Automated cherry pick of #50398

Cherry pick of #50398 on release-1.7.

#50398: Switch away from gcloud deprecated flags in compute resource
k8s-github-robot pushed a commit that referenced this pull request Sep 5, 2017
…stream-release-1.6

Automatic merge from submit-queue

Automated cherry pick of #50398

Cherry pick of #50398 on release-1.6.

#50398: Switch away from gcloud deprecated flags in compute resource
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. area/platform/gce cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update gcloud compute calls to remove --zones and --regexp