Skip to content

Commit

Permalink
Merge pull request #793 from sergioifg94/THREESCALE-8749
Browse files Browse the repository at this point in the history
THREESCALE-8749: Ability to set APICAST_SERVICE_CACHE_SIZE
  • Loading branch information
sergioifg94 authored Nov 11, 2022
2 parents 5c915e6 + 532c31c commit 4cf6ab1
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apis/apps/v1alpha1/apimanager_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ type ApicastProductionSpec struct {
// * character, which matches all hosts, effectively disables the proxy.
// +optional
NoProxy *string `json:"noProxy,omitempty"` // NO_PROXY
// ServiceCacheSize specifies the number of services that APICast can store in the internal cache
// +optional
ServiceCacheSize *int32 `json:"serviceCacheSize,omitempty"`
}

type ApicastStagingSpec struct {
Expand Down Expand Up @@ -315,6 +318,9 @@ type ApicastStagingSpec struct {
// * character, which matches all hosts, effectively disables the proxy.
// +optional
NoProxy *string `json:"noProxy,omitempty"` // NO_PROXY
// ServiceCacheSize specifies the number of services that APICast can store in the internal cache
// +optional
ServiceCacheSize *int32 `json:"serviceCacheSize,omitempty"`
}

type BackendSpec struct {
Expand Down
10 changes: 10 additions & 0 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions bundle/manifests/apps.3scale.net_apimanagers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ spec:
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
serviceCacheSize:
description: ServiceCacheSize specifies the number of services that APICast can store in the internal cache
format: int32
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates any taint that matches the triple <key,value,effect> using the matching operator <operator>.
Expand Down Expand Up @@ -1269,6 +1273,10 @@ spec:
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
serviceCacheSize:
description: ServiceCacheSize specifies the number of services that APICast can store in the internal cache
format: int32
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates any taint that matches the triple <key,value,effect> using the matching operator <operator>.
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/apps.3scale.net_apimanagers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,11 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
serviceCacheSize:
description: ServiceCacheSize specifies the number of services
that APICast can store in the internal cache
format: int32
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates
Expand Down Expand Up @@ -2243,6 +2248,11 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
serviceCacheSize:
description: ServiceCacheSize specifies the number of services
that APICast can store in the internal cache
format: int32
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates
Expand Down
8 changes: 8 additions & 0 deletions pkg/3scale/amp/component/apicast.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ func (apicast *Apicast) buildApicastStagingEnv() []v1.EnvVar {
result = append(result, helper.EnvVarFromValue("NO_PROXY", *apicast.Options.StagingNoProxy))
}

if apicast.Options.StagingServiceCacheSize != nil {
result = append(result, helper.EnvVarFromValue("APICAST_SERVICE_CACHE_SIZE", fmt.Sprintf("%d", *apicast.Options.StagingServiceCacheSize)))
}

return result
}

Expand Down Expand Up @@ -437,6 +441,10 @@ func (apicast *Apicast) buildApicastProductionEnv() []v1.EnvVar {
result = append(result, helper.EnvVarFromValue("NO_PROXY", *apicast.Options.ProductionNoProxy))
}

if apicast.Options.ProductionServiceCacheSize != nil {
result = append(result, helper.EnvVarFromValue("APICAST_SERVICE_CACHE_SIZE", fmt.Sprintf("%d", *apicast.Options.ProductionServiceCacheSize)))
}

return result
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/3scale/amp/component/apicast_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ type ApicastOptions struct {
StagingHTTPSProxy *string
StagingNoProxy *string

ProductionServiceCacheSize *int32
StagingServiceCacheSize *int32

AdditionalPodAnnotations map[string]string `validate:"required"`
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/3scale/amp/operator/apicast_options_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (a *ApicastOptionsProvider) GetApicastOptions() (*component.ApicastOptions,
a.apicastOptions.StagingHTTPSCertificateSecretName = &a.apimanager.Spec.Apicast.StagingSpec.HTTPSCertificateSecretRef.Name
}

a.apicastOptions.ProductionServiceCacheSize = a.apimanager.Spec.Apicast.ProductionSpec.ServiceCacheSize
a.apicastOptions.StagingServiceCacheSize = a.apimanager.Spec.Apicast.StagingSpec.ServiceCacheSize

a.setResourceRequirementsOptions()
a.setNodeAffinityAndTolerationsOptions()
a.setReplicas()
Expand Down
23 changes: 23 additions & 0 deletions pkg/3scale/amp/operator/apicast_options_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,29 @@ func TestGetApicastOptionsProvider(t *testing.T) {
return opts
},
},
{"WithServiceCacheSize",
func() *appsv1alpha1.APIManager {
apimanager := basicApimanagerTestApicastOptions()
var stagingCacheSize int32 = 10
var productionCacheSize int32 = 20

apimanager.Spec.Apicast.ProductionSpec.ServiceCacheSize = &productionCacheSize
apimanager.Spec.Apicast.StagingSpec.ServiceCacheSize = &stagingCacheSize

return apimanager
},
func() *component.ApicastOptions {
opts := defaultApicastOptions()

var stagingCacheSize int32 = 10
var productionCacheSize int32 = 20

opts.ProductionServiceCacheSize = &productionCacheSize
opts.StagingServiceCacheSize = &stagingCacheSize

return opts
},
},
}

for _, tc := range cases {
Expand Down

0 comments on commit 4cf6ab1

Please sign in to comment.