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

fix(service update): Retry an update in case of a conflict. #240

Merged
merged 2 commits into from
Jul 10, 2019

Conversation

rhuss
Copy link
Contributor

@rhuss rhuss commented Jul 8, 2019

Is related to #224 and should fix one flake.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 8, 2019
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 8, 2019
@rhuss rhuss added this to the v0.2.0 milestone Jul 8, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: navidshaikh, rhuss

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

@rhuss
Copy link
Contributor Author

rhuss commented Jul 8, 2019

/assign sixolet
/assign cppforlife

if err != nil {
return err
var retries = 0
for true {

Choose a reason for hiding this comment

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

for true should just be for

fmt.Fprintf(out, "Service '%s' successfully replaced in namespace '%s'.\n", service.Name, namespace)
return nil
// This line will be never reached, but go insists on having it
return fmt.Errorf("can not update service '%s' in namespace '%s'", service.Name, namespace)

Choose a reason for hiding this comment

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

common convention in go in such cases is to use panic("Unreachable")

if err != nil {
return err
}
service = service.DeepCopy()

Choose a reason for hiding this comment

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

i dont think we need DeepCopy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not introduced in this PR, but happy to remove if safe. it was just my general understanding to copy objects before working on them to not compromise shared caches and other data structures which hold a reference.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm with rhuss.

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/commands/service/service_create.go 79.7% 77.4% -2.4
pkg/kn/commands/service/service_update.go 76.0% 70.0% -6.0

@rhuss
Copy link
Contributor Author

rhuss commented Jul 9, 2019

  • Change to for { } loop, now the final statement is not necessary anymore
  • Kept DeepCopy as I think it doesn't harm. Happy to remove in a subsequent PR (wasn't introduced by this PR)

// @cppforlife

@mattmoor mattmoor removed their request for review July 10, 2019 00:57
@sixolet
Copy link
Contributor

sixolet commented Jul 10, 2019

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2019
@rhuss
Copy link
Contributor Author

rhuss commented Jul 10, 2019

/retest

@knative-prow-robot knative-prow-robot merged commit e1614f9 into knative:master Jul 10, 2019
navidshaikh added a commit to navidshaikh/client that referenced this pull request Jan 21, 2020
- Update Dockerfile to use rhel8/go-toolset:1.13.4 builder image
 - Update 'version' label in Dockerfile as 'v0.11.0' (earlier it was without 'v')
coryrc pushed a commit to coryrc/client that referenced this pull request May 14, 2020
AKA "display a banner when tests failed for a release, instead of just silently aborting the release"

Bonus: factor out common code in tests.
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 Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. 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.

7 participants