Skip to content

Conversation

howardjohn
Copy link
Member

@howardjohn howardjohn commented Oct 7, 2025

See
kubernetes/enhancements#5590 (comment); we use a lot of very questionable gogoproto on k8s type operations.

The good news is, as far as I can every single one of these is on code paths that never actually touch k8s types (anymore), or are on entirely dead code paths.

My plan is to split this into two PRs to make things simpler/safer.

This PR removes strictly dead code that is in this area. There is a surprising amount here! I think this is as we moved more and more stuff away from these legacy config.Config paths towards kclient/krt the cruft just stayed around.

In the next PRs I will remove the gogo proto handling (TBD how, if we want to fail or fallback).

I've analyzed the remaining usages:

DeepCopy
  UpdateHealth, DeleteHealthCondition (WE only)
  mergeVirtualServicesIfNeeded (on VS spec)
  mergeDestinationRule
  mergeHTTPRoutes (its a VirtualService though, not a HTTPRoute)
  resolveVirtualServiceShortnames (on VS only)
  convertToWasmPluginWrapper (On WasmPlugin)
  In a bunch of tests

ApplyJSON
  FromJSON
    ConvertObject
      webhook.validate (only called for istio types)
      ParseInputs (should be called for everything)
        kube/file.NewController
          Only allows Istio objects but I think its going to read all of them, so we couldn't panic or something?
ApplyJSONStrict
  fromSchemaAndJSONMap
    validateResource (in istioctl, only used on Istio types)

Equals()
  We already explicitly do not use gogoproto.Equals EXCEPT in `needsPush` which only operates on istio.io types

ToProto():
  PilotConfigToResource (I think this will only have Istio types)

ToJSON():
  ToRaw()
    ConvertConfig
      used in configz handler, which should only have Istio types
ToPrettyJSON():
  Not even used on protos, bug in xds/debug.go

Please provide a description of this PR:

@howardjohn howardjohn requested review from a team as code owners October 7, 2025 20:36
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 7, 2025
@howardjohn howardjohn added the release-notes-none Indicates a PR that does not require release notes. label Oct 7, 2025
@howardjohn howardjohn requested a review from keithmattix October 7, 2025 20:40
@howardjohn howardjohn mentioned this pull request Oct 7, 2025
See
kubernetes/enhancements#5590 (comment);
we use a lot of very questionable gogoproto on k8s type operations.

The good news is, as far as I can every single one of these is on code
paths that never actually touch k8s types (anymore), or are on entirely
dead code paths.

My plan is to split this into two PRs to make things simpler/safer.

This PR removes strictly dead code that is in this area. There is a
surprising amount here! I think this is as we moved more and more stuff
away from these legacy `config.Config` paths towards kclient/krt the
cruft just stayed around.

In the next PRs I will remove the gogo proto handling (TBD how, if we
want to fail or fallback).

I've analyzed the remaining usages:

```
DeepCopy
  UpdateHealth, DeleteHealthCondition (WE only)
  mergeVirtualServicesIfNeeded (on VS spec)
  mergeDestinationRule
  mergeHTTPRoutes (its a VirtualService though, not a HTTPRoute)
  resolveVirtualServiceShortnames (on VS only)
  convertToWasmPluginWrapper (On WasmPlugin)
  In a bunch of tests

ApplyJSON
  FromJSON
    ConvertObject
      webhook.validate (only called for istio types)
      ParseInputs (should be called for everything)
        kube/file.NewController
          Only allows Istio objects but I think its going to read all of them, so we couldn't panic or something?
ApplyJSONStrict
  fromSchemaAndJSONMap
    validateResource (in istioctl, only used on Istio types)

Equals()
  We already explicitly do not use gogoproto.Equals EXCEPT in `needsPush` which only operates on istio.io types

ToProto():
  PilotConfigToResource (I think this will only have Istio types)

ToJSON():
  ToRaw()
    ConvertConfig
      used in configz handler, which should only have Istio types
ToPrettyJSON():
  Not even used on protos, bug in xds/debug.go
```
@howardjohn howardjohn force-pushed the dc/cleanup-gogo-proto branch from f0ee51b to 743485f Compare October 7, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. 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.

2 participants