From 070c157f6289ac47c8902c3379a4b5303a962aff Mon Sep 17 00:00:00 2001 From: Brandon Roberson Date: Tue, 4 Jun 2024 17:29:19 +0000 Subject: [PATCH 1/4] SetNofile and SetNproc take pointers now due to protobuf changes --- depot/steps/run_step.go | 2 +- depot/steps/run_step_test.go | 4 ++-- depot/transformer/transformer.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/depot/steps/run_step.go b/depot/steps/run_step.go index d91463b9..aef1af31 100644 --- a/depot/steps/run_step.go +++ b/depot/steps/run_step.go @@ -118,7 +118,7 @@ func (step *runStep) Run(signals <-chan os.Signal, ready chan<- struct{}) error var nofile *uint64 if step.model.ResourceLimits != nil { - nofile = step.model.ResourceLimits.GetNofilePtr() + nofile = step.model.ResourceLimits.GetNofile() } var processIO garden.ProcessIO diff --git a/depot/steps/run_step_test.go b/depot/steps/run_step_test.go index 21678d95..dc25cfcd 100644 --- a/depot/steps/run_step_test.go +++ b/depot/steps/run_step_test.go @@ -53,8 +53,8 @@ var _ = Describe("RunAction", func() { sidecar = steps.Sidecar{} rl := models.ResourceLimits{} - rl.SetNofile(fileDescriptorLimit) - rl.SetNproc(processesLimit) + rl.SetNofile(&fileDescriptorLimit) + rl.SetNproc(&processesLimit) runAction = models.RunAction{ Path: "sudo", diff --git a/depot/transformer/transformer.go b/depot/transformer/transformer.go index 0439578b..aab21b6e 100644 --- a/depot/transformer/transformer.go +++ b/depot/transformer/transformer.go @@ -608,7 +608,7 @@ func (t *transformer) createCheck( } rl := models.ResourceLimits{} - rl.SetNofile(nofiles) + rl.SetNofile(&nofiles) runAction := models.RunAction{ LogSource: sourceName, ResourceLimits: &rl, From bcfc5083ebe5ba92d254b4e915202781eb88ab09 Mon Sep 17 00:00:00 2001 From: Brandon Roberson Date: Fri, 13 Sep 2024 19:46:06 +0000 Subject: [PATCH 2/4] Remove reference to gogo/protobuf --- depot/transformer/transformer_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depot/transformer/transformer_test.go b/depot/transformer/transformer_test.go index a5973043..d6dc3ae0 100644 --- a/depot/transformer/transformer_test.go +++ b/depot/transformer/transformer_test.go @@ -24,12 +24,12 @@ import ( "code.cloudfoundry.org/lager/v3" "code.cloudfoundry.org/lager/v3/lagertest" "code.cloudfoundry.org/workpool" - "github.com/gogo/protobuf/proto" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" "github.com/tedsuo/ifrit" ginkgomon "github.com/tedsuo/ifrit/ginkgomon_v2" + "google.golang.org/protobuf/proto" ) var _ = Describe("Transformer", func() { From e52f9b5f163414b6d69b541a8a8033e125846c81 Mon Sep 17 00:00:00 2001 From: Brandon Roberson Date: Mon, 10 Feb 2025 17:53:57 +0000 Subject: [PATCH 3/4] Resolve staticcheck error with Nproc --- depot/steps/run_step_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/depot/steps/run_step_test.go b/depot/steps/run_step_test.go index dc25cfcd..5f83d39f 100644 --- a/depot/steps/run_step_test.go +++ b/depot/steps/run_step_test.go @@ -54,6 +54,7 @@ var _ = Describe("RunAction", func() { rl := models.ResourceLimits{} rl.SetNofile(&fileDescriptorLimit) + //lint:ignore SA1019 - testing deprecated logic rl.SetNproc(&processesLimit) runAction = models.RunAction{ From 216d507ada25616554e2f96a60a74bfe27120e65 Mon Sep 17 00:00:00 2001 From: Brandon Roberson Date: Fri, 14 Feb 2025 16:09:11 +0000 Subject: [PATCH 4/4] Change github.com/golang/protobuf (deprecated) to google.golang.org/protobuf --- depot/containerstore/proxy_config_handler.go | 45 +++++++++---------- .../proxy_config_handler_test.go | 14 +++--- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/depot/containerstore/proxy_config_handler.go b/depot/containerstore/proxy_config_handler.go index fbb54b33..f5255914 100644 --- a/depot/containerstore/proxy_config_handler.go +++ b/depot/containerstore/proxy_config_handler.go @@ -27,14 +27,13 @@ import ( envoy_discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" envoy_matcher "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" ghodss_yaml "github.com/ghodss/yaml" - "github.com/golang/protobuf/ptypes/any" - "github.com/golang/protobuf/ptypes/duration" - pstruct "github.com/golang/protobuf/ptypes/struct" - "github.com/golang/protobuf/ptypes/wrappers" "github.com/tedsuo/ifrit" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/wrapperspb" ) const ( @@ -354,7 +353,7 @@ func generateProxyConfig( clusters = append(clusters, &envoy_cluster.Cluster{ Name: clusterName, ClusterDiscoveryType: &envoy_cluster.Cluster_Type{Type: envoy_cluster.Cluster_STATIC}, - ConnectTimeout: &duration.Duration{Nanos: TimeOut}, + ConnectTimeout: &durationpb.Duration{Nanos: TimeOut}, LoadAssignment: &envoy_endpoint.ClusterLoadAssignment{ ClusterName: clusterName, Endpoints: []*envoy_endpoint.LocalityLbEndpoints{{ @@ -369,9 +368,9 @@ func generateProxyConfig( }, CircuitBreakers: &envoy_cluster.CircuitBreakers{ Thresholds: []*envoy_cluster.CircuitBreakers_Thresholds{ - {MaxConnections: &wrappers.UInt32Value{Value: math.MaxUint32}}, - {MaxPendingRequests: &wrappers.UInt32Value{Value: math.MaxUint32}}, - {MaxRequests: &wrappers.UInt32Value{Value: math.MaxUint32}}, + {MaxConnections: &wrapperspb.UInt32Value{Value: math.MaxUint32}}, + {MaxPendingRequests: &wrapperspb.UInt32Value{Value: math.MaxUint32}}, + {MaxRequests: &wrapperspb.UInt32Value{Value: math.MaxUint32}}, }}, }) } @@ -405,18 +404,18 @@ func generateProxyConfig( { Name: "static-layer", LayerSpecifier: &envoy_bootstrap.RuntimeLayer_StaticLayer{ - StaticLayer: &pstruct.Struct{ - Fields: map[string]*pstruct.Value{ - "envoy": &pstruct.Value{ - Kind: &pstruct.Value_StructValue{ - StructValue: &pstruct.Struct{ - Fields: map[string]*pstruct.Value{ - "reloadable_features": &pstruct.Value{ - Kind: &pstruct.Value_StructValue{ - StructValue: &pstruct.Struct{ - Fields: map[string]*pstruct.Value{ - "new_tcp_connection_pool": &pstruct.Value{ - Kind: &pstruct.Value_BoolValue{ + StaticLayer: &structpb.Struct{ + Fields: map[string]*structpb.Value{ + "envoy": &structpb.Value{ + Kind: &structpb.Value_StructValue{ + StructValue: &structpb.Struct{ + Fields: map[string]*structpb.Value{ + "reloadable_features": &structpb.Value{ + Kind: &structpb.Value_StructValue{ + StructValue: &structpb.Struct{ + Fields: map[string]*structpb.Value{ + "new_tcp_connection_pool": &structpb.Value{ + Kind: &structpb.Value_BoolValue{ BoolValue: false, }, }, @@ -455,7 +454,7 @@ func generateProxyConfig( clusters = append(clusters, &envoy_cluster.Cluster{ Name: AdsClusterName, ClusterDiscoveryType: &envoy_cluster.Cluster_Type{Type: envoy_cluster.Cluster_STATIC}, - ConnectTimeout: &duration.Duration{Nanos: TimeOut}, + ConnectTimeout: &durationpb.Duration{Nanos: TimeOut}, LoadAssignment: &envoy_endpoint.ClusterLoadAssignment{ ClusterName: AdsClusterName, Endpoints: []*envoy_endpoint.LocalityLbEndpoints{{ @@ -567,7 +566,7 @@ func generateListeners(container executor.Container, requireClientCerts, http2En } if requireClientCerts && portMap.ContainerTLSProxyPort != C2CTLSPort { - tlsContext.RequireClientCertificate = &wrappers.BoolValue{Value: requireClientCerts} + tlsContext.RequireClientCertificate = &wrapperspb.BoolValue{Value: requireClientCerts} tlsContext.CommonTlsContext.ValidationContextType = &envoy_tls.CommonTlsContext_ValidationContextSdsSecretConfig{ ValidationContextSdsSecretConfig: &envoy_tls.SdsSecretConfig{ Name: "id-validation-context", @@ -669,7 +668,7 @@ func writeDiscoveryResponseYAML(resourceMsg proto.Message, outPath string) error } dr := &envoy_discovery.DiscoveryResponse{ VersionInfo: "0", - Resources: []*any.Any{ + Resources: []*anypb.Any{ resourceAny, }, } diff --git a/depot/containerstore/proxy_config_handler_test.go b/depot/containerstore/proxy_config_handler_test.go index 01d327b0..b33ddf40 100644 --- a/depot/containerstore/proxy_config_handler_test.go +++ b/depot/containerstore/proxy_config_handler_test.go @@ -30,14 +30,14 @@ import ( envoy_matcher "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" "github.com/fsnotify/fsnotify" ghodss_yaml "github.com/ghodss/yaml" - "github.com/golang/protobuf/ptypes/duration" - "github.com/golang/protobuf/ptypes/wrappers" uuid "github.com/nu7hatch/gouuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/wrapperspb" ) var _ = Describe("ProxyConfigHandler", func() { @@ -1089,7 +1089,7 @@ func createListener(config expectedListener) *envoy_listener.Listener { }, } if config.requireClientCertificate { - tlsContext.RequireClientCertificate = &wrappers.BoolValue{Value: true} + tlsContext.RequireClientCertificate = &wrapperspb.BoolValue{Value: true} tlsContext.CommonTlsContext.ValidationContextType = &envoy_tls.CommonTlsContext_ValidationContextSdsSecretConfig{ ValidationContextSdsSecretConfig: &envoy_tls.SdsSecretConfig{ Name: "id-validation-context", @@ -1146,7 +1146,7 @@ func createCluster(config expectedCluster) *envoy_cluster.Cluster { } cluster := &envoy_cluster.Cluster{ Name: config.name, - ConnectTimeout: &duration.Duration{Nanos: 250000000}, + ConnectTimeout: &durationpb.Duration{Nanos: 250000000}, ClusterDiscoveryType: &envoy_cluster.Cluster_Type{Type: envoy_cluster.Cluster_STATIC}, LbPolicy: envoy_cluster.Cluster_ROUND_ROBIN, LoadAssignment: &envoy_endpoint.ClusterLoadAssignment{ @@ -1160,9 +1160,9 @@ func createCluster(config expectedCluster) *envoy_cluster.Cluster { if config.maxConnections > 0 { cluster.CircuitBreakers = &envoy_cluster.CircuitBreakers{ Thresholds: []*envoy_cluster.CircuitBreakers_Thresholds{ - {MaxConnections: &wrappers.UInt32Value{Value: math.MaxUint32}}, - {MaxPendingRequests: &wrappers.UInt32Value{Value: math.MaxUint32}}, - {MaxRequests: &wrappers.UInt32Value{Value: math.MaxUint32}}, + {MaxConnections: &wrapperspb.UInt32Value{Value: math.MaxUint32}}, + {MaxPendingRequests: &wrapperspb.UInt32Value{Value: math.MaxUint32}}, + {MaxRequests: &wrapperspb.UInt32Value{Value: math.MaxUint32}}, }} } return cluster