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

Fixed panic when traffic split to unavailable revision #1533

Merged
merged 4 commits into from
Nov 30, 2021

Conversation

vyasgun
Copy link
Contributor

@vyasgun vyasgun commented Nov 30, 2021

Description

Panic during updating traffic to a revision that is not ready

Before:

$ kn service update hello-example-3 --env TARGET="pqr" --traffic abcd=50,hello-example-3-00002=50

E1130 00:13:13.786017   76154 runtime.go:78] Observed a panic: runtime.boundsError{x:0, y:0, signed:true, code:0x0} (runtime error: index out of range [0] with length 0)
goroutine 1 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic({0x246a6a0, 0xc0006ac570})
	/home/prow/go/src/knative.dev/client/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:74 +0x85
k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0x5a0})
	/home/prow/go/src/knative.dev/client/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:48 +0x75
panic({0x246a6a0, 0xc0006ac570})
	/root/.gvm/gos/go1.17.2/src/runtime/panic.go:1038 +0x215
knative.dev/client/pkg/serving.ContainerStatus(...)
	/home/prow/go/src/knative.dev/client/pkg/serving/revision_template.go:71
knative.dev/client/pkg/serving.PinImageToDigest(0xc00011a118, 0xc000192700)
	/home/prow/go/src/knative.dev/client/pkg/serving/config_changes.go:147 +0x293
knative.dev/client/pkg/kn/commands/service.(*ConfigurationEditFlags).Apply(0xc00012e780, 0xc00011a000, 0x23376a0, 0xc00069cb00)
	/home/prow/go/src/knative.dev/client/pkg/kn/commands/service/configuration_edit_flags.go:242 +0x252
knative.dev/client/pkg/kn/commands/service.NewServiceUpdateCommand.func1.1(0xc00011a000)
	/home/prow/go/src/knative.dev/client/pkg/kn/commands/service/update.go:100 +0x1d9

Now:

$ ./kn service update hello-example-3 --env TARGET="pqr" --traffic abcd=50,hello-example-3-00002=50

Updating Service 'hello-example-3' in namespace 'default':

  0.033s Revision "hello-example-3-00002" failed to become ready.
  0.093s ...
Error: RevisionMissing: Revision "hello-example-3-00002" failed to become ready.

Changes

  • Added nil pointed check
  • Added array length check

Reference

Fixes #

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 30, 2021
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@vyasgun: 0 warnings.

In response to this:

Description

Panic during updating traffic to a revision that is not ready

Before:

$ kn service update hello-example-3 --env TARGET="pqr" --traffic abcd=50,hello-example-3-00002=50

E1130 00:13:13.786017   76154 runtime.go:78] Observed a panic: runtime.boundsError{x:0, y:0, signed:true, code:0x0} (runtime error: index out of range [0] with length 0)
goroutine 1 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic({0x246a6a0, 0xc0006ac570})
  /home/prow/go/src/knative.dev/client/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:74 +0x85
k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0x5a0})
  /home/prow/go/src/knative.dev/client/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:48 +0x75
panic({0x246a6a0, 0xc0006ac570})
  /root/.gvm/gos/go1.17.2/src/runtime/panic.go:1038 +0x215
knative.dev/client/pkg/serving.ContainerStatus(...)
  /home/prow/go/src/knative.dev/client/pkg/serving/revision_template.go:71
knative.dev/client/pkg/serving.PinImageToDigest(0xc00011a118, 0xc000192700)
  /home/prow/go/src/knative.dev/client/pkg/serving/config_changes.go:147 +0x293
knative.dev/client/pkg/kn/commands/service.(*ConfigurationEditFlags).Apply(0xc00012e780, 0xc00011a000, 0x23376a0, 0xc00069cb00)
  /home/prow/go/src/knative.dev/client/pkg/kn/commands/service/configuration_edit_flags.go:242 +0x252
knative.dev/client/pkg/kn/commands/service.NewServiceUpdateCommand.func1.1(0xc00011a000)
  /home/prow/go/src/knative.dev/client/pkg/kn/commands/service/update.go:100 +0x1d9

Now:

$ ./kn service update hello-example-3 --env TARGET="pqr" --traffic abcd=50,hello-example-3-00002=50

Updating Service 'hello-example-3' in namespace 'default':

 0.033s Revision "hello-example-3-00002" failed to become ready.
 0.093s ...
Error: RevisionMissing: Revision "hello-example-3-00002" failed to become ready.

Changes

  • Added nil pointed check
  • Added array length check

Reference

Fixes #

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.

@knative-prow-robot knative-prow-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 30, 2021
@codecov
Copy link

codecov bot commented Nov 30, 2021

Codecov Report

Merging #1533 (c80052f) into main (8fd19e6) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1533      +/-   ##
==========================================
+ Coverage   79.52%   79.56%   +0.03%     
==========================================
  Files         162      162              
  Lines        8553     8553              
==========================================
+ Hits         6802     6805       +3     
+ Misses       1073     1071       -2     
+ Partials      678      677       -1     
Impacted Files Coverage Δ
pkg/serving/config_changes.go 91.30% <100.00%> (+1.44%) ⬆️
pkg/serving/revision_template.go 95.45% <100.00%> (+4.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8fd19e6...c80052f. Read the comment docs.

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 30, 2021
Comment on lines 168 to 174
{
"no container",
&servingv1.Revision{
Spec: servingv1.RevisionSpec{},
},
nil,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a duplicate? Maybe that should be No ImageDigest?

Copy link
Contributor

@dsimansk dsimansk Nov 30, 2021

Choose a reason for hiding this comment

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

Anyway lets add not empty status without image digest. That'd be in config_change_test.go I suppose. That was my initial thought. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, yes. Removed the duplicate test case and modified the no container case with a non-empty Status field.

@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/serving/config_changes.go 94.5% 95.9% 1.4
pkg/serving/revision_template.go 95.3% 97.7% 2.3

Copy link
Contributor

@dsimansk dsimansk left a comment

Choose a reason for hiding this comment

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

Thanks!

/approve
/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 30, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, vyasgun

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 30, 2021
@knative-prow-robot knative-prow-robot merged commit 972eec2 into knative:main Nov 30, 2021
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/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.

4 participants