spinnaker: Error 500 from gate when listing pipeline templates

Issue Summary:

Encountering an http 500 error when attempting to list or save pipeline templates using spin cli, after upgrade to 1.22.

Cloud Provider(s):

AWS, Kubernetes

Environment:

Spinnaker deployed via hal, spin-cli 1.18

Feature Area:

Spin CLI, Gate

Description:

Command: spin pipeline-template list

Resulting gate log:

2020-08-26 13:01:25.718 ERROR 1 --- [0.0-8084-exec-9] c.n.s.k.w.e.GenericExceptionHandlers     : Internal Serve
r Error

java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.String; ([Ljava.lan
g.Object; and [Ljava.lang.String; are in module java.base of loader 'bootstrap')
        at com.netflix.spinnaker.gate.services.V2PipelineTemplateService.findByScope(V2PipelineTemplateService.
java:55) ~[gate-web.jar:1.0.0]
        at com.netflix.spinnaker.gate.controllers.V2PipelineTemplatesController.list(V2PipelineTemplatesControl
ler.java:75) ~[gate-web.jar:1.0.0]

Additional Details:

Seems to have been introduced somewhere between 1.20 and 1.22; I was not seeing this issue on 1.20.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 13
  • Comments: 55

Commits related to this issue

Most upvoted comments

Jürgen indicated on Slack that they’ve built a binary with this commit f088bd6bb46a00e959b1dfabc1d6b6a2addab497. Doing a git-bisect from HEAD to that commit indicates that this is the commit at which the pipeline-templates list command began failing: 2b364bb5214e521a74faed8723341a2164a090d0

Even after generating swagger info for Gate from master and rebuilding spin-cli I wasn’t able to get a clean build.

Just going to post some findings here:

Previously there was a type assertion *[]string on the optional value containing the scopes.

https://github.com/spinnaker/spin/blob/master/gateapi/api_v2_pipeline_templates_controller.go#L458

Which is generated by:

https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/go/api.mustache#L111

Meaning this type check doesn’t evaluate to true (as the obj isn’t a Slice). This results in an invalid string representation of the array of scopes (beginning with a pointer &, something like “&[foo=bar]”).

Conclusion:

It looks like the swagger auto generated code is incorrect (maybe some golang experts can confirm)? It looks like the version of swagger-gen was bumped at the same time the v2 api was introduced (introducing the bug mentioned above, and this issue with the cli caused by the template change). Fixing the class cast exception will only fix the 500, the api will now return an empty list of templates as the scope query isn’t formatted correctly.

Should the scope parameter default to an empty list even when not specified? If this behaviour is changed the issue can be resolved for the case where no scope param is provided. At least while we wait for the swagger templates to be fixed/reviewed.

@nerddelphi have you tried with Spin CLI 1.18.1? you should be able to save pipelines again.

I’ve begun investigating it but my last PR doesn’t entirely fix this issue. Spin is correctly returning the 500 it’s receiving…still trying to understand why the 500 is being returned in the first place.