Skip to content
This repository was archived by the owner on May 3, 2023. It is now read-only.

Conversation

@Ryan-Rose-Bose
Copy link
Contributor

I've been attempting to use go-cache in conjunction with a gin service instrumented with prometheus and have been running up against the following issue described in this issue:

panic: mismatching message name: got k8s.io.kubernetes.pkg.watch.versioned.Event, want github.com/ericchiang.k8s.watch.versioned.Event

goroutine 1 [running]:
google.golang.org/protobuf/internal/impl.legacyLoadMessageDesc(0x55ba9b96e7e0, 0x55ba9b8f6140, 0x55ba9b735203, 0x2f, 0x0, 0x0)
	/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go:136 +0x884
google.golang.org/protobuf/internal/impl.legacyLoadMessageInfo(0x55ba9b96e7e0, 0x55ba9b8f6140, 0x55ba9b735203, 0x2f, 0x55ba9b171219)
	/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go:48 +0xbf
google.golang.org/protobuf/internal/impl.Export.LegacyMessageTypeOf(0x55ba9b963e60, 0x0, 0x55ba9b735203, 0x2f, 0xc00003c9a0, 0xc000109450)
	/vendor/google.golang.org/protobuf/internal/impl/legacy_export.go:33 +0xa7
github.com/golang/protobuf/proto.RegisterType(0x55ba9b963e60, 0x0, 0x55ba9b735203, 0x2f)
	/vendor/github.com/golang/protobuf/proto/registry.go:186 +0x4f
github.com/ericchiang/k8s/watch/versioned.init.0()
	/vendor/github.com/ericchiang/k8s/watch/versioned/generated.pb.go:76 +0x4d

This is due to the github.com/ericchiang/k8s package used in redispool.go -> inCluster() using v1.2 of github.com/golang/protobuf. After version v1.4, there's some changes that result in the above error, and v1.4 is a requirement of github.com/prometheus/client_golang. The issue on github.com/ericchiang/k8s has been open for a couple months, so I do not think it is likely it will be addressed in a timely fashion.
Comparing rest.InClusterConfig() to k8s.NewInClusterClient()/k8s.newCluster(), they both behave similarly and should be equivalent in determining cluster presence.

I've solved this by replacing the protobuf-based k8s client with a portion of the official k8s client that has near-equivalent functionality.

The downside of this is that github.com/kubernetes/client-go has more dependencies than the github.com/ericchiang/k8s client.

(Useful bookmark to hide vendor files: javascript:document.querySelectorAll("*[data-path*='vendor']").forEach(el => el.parentElement.remove()); undefined;)

Copy link

@Peter-Tanski-Bose Peter-Tanski-Bose left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link

@Alex-Grant-Bose Alex-Grant-Bose left a comment

Choose a reason for hiding this comment

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

@Ryan-Rose-Bose I think this PR change is good. In consort I ran into this issue and overrode the single line in the generated PB. Another option would be to fork https://github.com/ericchiang/k8s and fix it ourselves. I know for Consort we wanted to keep dependencies down so sticking with the other library met our needs.

@Ryan-Rose-Bose
Copy link
Contributor Author

Yeah, that makes sense. Is it worth keeping this change on a separate branch?

And/or, would it be possible to share the way you mitigated the PB in Consort? Is it programmatic, or are you vendoring and just edited a file?

@Ryan-Rose-Bose Ryan-Rose-Bose marked this pull request as draft August 4, 2020 15:19
@Ryan-Rose-Bose
Copy link
Contributor Author

After talking with @Alex-Grant-Bose, I've made this a draft and in my own code applied the fix to github.com/ericchiang/k8s. I hope to come up with a better solution eventually :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants