Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup unused configuration fields #899

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions components/operator/api/v1alpha1/serverless_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ type ServerlessSpec struct {
FunctionBuildMaxSimultaneousJobs string `json:"functionBuildMaxSimultaneousJobs,omitempty"`
// Sets the timeout for the Function health check. The default value in seconds is `10`
HealthzLivenessTimeout string `json:"healthzLivenessTimeout,omitempty"`
// Used to configure the maximum size limit for the request body of a Function. The default value is `1` megabyte
FunctionRequestBodyLimitMb string `json:"functionRequestBodyLimitMb,omitempty"`
// Sets the maximum execution time limit for a Function. By default, the value is `180` seconds
FunctionTimeoutSec string `json:"functionTimeoutSec,omitempty"`
// Configures the default build Job preset to be used
DefaultBuildJobPreset string `json:"defaultBuildJobPreset,omitempty"`
// Configures the default runtime Pod preset to be used
Expand Down Expand Up @@ -110,8 +106,6 @@ type ServerlessStatus struct {
BuildExecutorArgs string `json:"functionBuildExecutorArgs,omitempty"`
BuildMaxSimultaneousJobs string `json:"functionBuildMaxSimultaneousJobs,omitempty"`
HealthzLivenessTimeout string `json:"healthzLivenessTimeout,omitempty"`
RequestBodyLimitMb string `json:"functionRequestBodyLimitMb,omitempty"`
TimeoutSec string `json:"functionTimeoutSec,omitempty"`
DefaultBuildJobPreset string `json:"defaultBuildJobPreset,omitempty"`
DefaultRuntimePodPreset string `json:"defaultRuntimePodPreset,omitempty"`

Expand Down
6 changes: 2 additions & 4 deletions components/operator/internal/chart/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type FlagsBuilder interface {
Build() map[string]interface{}
WithControllerConfiguration(CPUUtilizationPercentage string, requeueDuration string, buildExecutorArgs string, maxSimultaneousJobs string, healthzLivenessTimeout string, requestBodyLimitMb string, timeoutSec string) *flagsBuilder
WithControllerConfiguration(CPUUtilizationPercentage string, requeueDuration string, buildExecutorArgs string, maxSimultaneousJobs string, healthzLivenessTimeout string) *flagsBuilder
WithDefaultPresetFlags(defaultBuildJobPreset string, defaultRuntimePodPreset string) *flagsBuilder
WithOptionalDependencies(publisherURL string, traceCollectorURL string) *flagsBuilder
WithRegistryAddresses(registryAddress string, serverAddress string) *flagsBuilder
Expand Down Expand Up @@ -62,7 +62,7 @@ func nextDeeperFlag(currentFlag map[string]interface{}, path string) map[string]
return currentFlag[path].(map[string]interface{})
}

func (fb *flagsBuilder) WithControllerConfiguration(CPUUtilizationPercentage, requeueDuration, buildExecutorArgs, maxSimultaneousJobs, healthzLivenessTimeout, requestBodyLimitMb, timeoutSec string) *flagsBuilder {
func (fb *flagsBuilder) WithControllerConfiguration(CPUUtilizationPercentage, requeueDuration, buildExecutorArgs, maxSimultaneousJobs, healthzLivenessTimeout string) *flagsBuilder {
optionalFlags := []struct {
key string
value string
Expand All @@ -72,8 +72,6 @@ func (fb *flagsBuilder) WithControllerConfiguration(CPUUtilizationPercentage, re
{"functionBuildExecutorArgs", buildExecutorArgs},
{"functionBuildMaxSimultaneousJobs", maxSimultaneousJobs},
{"healthzLivenessTimeout", healthzLivenessTimeout},
{"functionRequestBodyLimitMb", requestBodyLimitMb},
{"functionTimeoutSec", timeoutSec},
}

for _, flag := range optionalFlags {
Expand Down
7 changes: 0 additions & 7 deletions components/operator/internal/chart/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ func Test_flagsBuilder_Build(t *testing.T) {
"functionBuildExecutorArgs": "testBuildExecutorArgs",
"functionBuildMaxSimultaneousJobs": "testMaxSimultaneousJobs",
"functionPublisherProxyAddress": "testPublisherURL",
"functionRequestBodyLimitMb": "testRequestBodyLimitMb",
"functionRequeueDuration": "testRequeueDuration",
"functionTimeoutSec": "testTimeoutSec",
"functionTraceCollectorEndpoint": "testCollectorURL",
"healthzLivenessTimeout": "testHealthzLivenessTimeout",
"targetCPUUtilizationPercentage": "testCPUUtilizationPercentage",
Expand Down Expand Up @@ -73,8 +71,6 @@ func Test_flagsBuilder_Build(t *testing.T) {
"testBuildExecutorArgs",
"testMaxSimultaneousJobs",
"testHealthzLivenessTimeout",
"testRequestBodyLimitMb",
"testTimeoutSec",
).Build()

require.Equal(t, expectedFlags, flags)
Expand Down Expand Up @@ -105,7 +101,6 @@ func Test_flagsBuilder_Build(t *testing.T) {
"configuration": map[string]interface{}{
"data": map[string]interface{}{
"functionBuildMaxSimultaneousJobs": "testMaxSimultaneousJobs",
"functionRequestBodyLimitMb": "testRequestBodyLimitMb",
"healthzLivenessTimeout": "testHealthzLivenessTimeout",
"targetCPUUtilizationPercentage": "testCPUUtilizationPercentage",
},
Expand All @@ -121,8 +116,6 @@ func Test_flagsBuilder_Build(t *testing.T) {
"",
"testMaxSimultaneousJobs",
"testHealthzLivenessTimeout",
"testRequestBodyLimitMb",
"",
).Build()

require.Equal(t, expectedFlags, flags)
Expand Down
16 changes: 0 additions & 16 deletions components/operator/internal/state/controller_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const (
slowRuntimePreset = "XS"
fastBuildPreset = "fast"
fastRuntimePreset = "L"
functionTimeoutDepreciationMessage = "spec.functionTimeoutSec is unused and will be removed. Remove it from your Serverless CR."
functionRequestBodyLimitDepreciationMessage = "spec.functionRequestBodyLimitMb is unused and will be removed. Remove it from your Serverless CR."
)

func sFnControllerConfiguration(ctx context.Context, r *reconciler, s *systemState) (stateFn, *controllerruntime.Result, error) {
Expand All @@ -25,7 +23,6 @@ func sFnControllerConfiguration(ctx context.Context, r *reconciler, s *systemSta
}

configureControllerConfigurationFlags(s)
warnAboutDeadFields(s)

s.setState(v1alpha1.StateProcessing)
s.instance.UpdateConditionTrue(
Expand All @@ -37,15 +34,6 @@ func sFnControllerConfiguration(ctx context.Context, r *reconciler, s *systemSta
return nextState(sFnApplyResources)
}

func warnAboutDeadFields(s *systemState) {
if s.instance.Spec.FunctionTimeoutSec != "" {
s.warningBuilder.With(functionTimeoutDepreciationMessage)
}
if s.instance.Spec.FunctionRequestBodyLimitMb != "" {
s.warningBuilder.With(functionRequestBodyLimitDepreciationMessage)
halamix2 marked this conversation as resolved.
Show resolved Hide resolved
}
}

func updateControllerConfigurationStatus(ctx context.Context, r *reconciler, instance *v1alpha1.Serverless) error {
nodesLen, err := getNodesLen(ctx, r.client)
if err != nil {
Expand All @@ -66,8 +54,6 @@ func updateControllerConfigurationStatus(ctx context.Context, r *reconciler, ins
{spec.FunctionBuildExecutorArgs, &instance.Status.BuildExecutorArgs, "Function build executor args", ""},
{spec.FunctionBuildMaxSimultaneousJobs, &instance.Status.BuildMaxSimultaneousJobs, "Max number of simultaneous jobs", ""},
{spec.HealthzLivenessTimeout, &instance.Status.HealthzLivenessTimeout, "Duration of health check", ""},
{spec.FunctionRequestBodyLimitMb, &instance.Status.RequestBodyLimitMb, "Max size of request body", ""},
{spec.FunctionTimeoutSec, &instance.Status.TimeoutSec, "Timeout", ""},
{spec.DefaultBuildJobPreset, &instance.Status.DefaultBuildJobPreset, "Default build job preset", defaultBuildPreset},
{spec.DefaultRuntimePodPreset, &instance.Status.DefaultRuntimePodPreset, "Default runtime pod preset", defaultRuntimePreset},
}
Expand All @@ -84,8 +70,6 @@ func configureControllerConfigurationFlags(s *systemState) {
s.instance.Status.BuildExecutorArgs,
s.instance.Status.BuildMaxSimultaneousJobs,
s.instance.Status.HealthzLivenessTimeout,
s.instance.Status.RequestBodyLimitMb,
s.instance.Status.TimeoutSec,
).
WithDefaultPresetFlags(
s.instance.Status.DefaultBuildJobPreset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package state
import (
"context"
"testing"
"fmt"

"github.com/kyma-project/serverless/components/operator/api/v1alpha1"
"github.com/kyma-project/serverless/components/operator/internal/chart"
"github.com/kyma-project/serverless/components/operator/internal/warning"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
Expand All @@ -23,8 +21,6 @@ const (
executorArgsTest = "test-build-executor-args"
maxSimultaneousJobsTest = "test-max-simultaneous-jobs"
healthzLivenessTimeoutTest = "test-healthz-liveness-timeout"
requestBodyLimitMbTest = "test-request-body-limit-mb"
timeoutSecTest = "test-timeout-sec"
buildJobPresetTest = "test=default-build-job-preset"
runtimePodPresetTest = "test-default-runtime-pod-preset"
)
Expand Down Expand Up @@ -234,20 +230,6 @@ func Test_sFnControllerConfiguration(t *testing.T) {
configurationReadyMsg)
require.Equal(t, v1alpha1.StateProcessing, s.instance.Status.State)
})

t.Run("enable dead fields", func(t *testing.T) {
s := &systemState{
warningBuilder: warning.NewBuilder(),
instance: v1alpha1.Serverless{
Spec: v1alpha1.ServerlessSpec{
FunctionRequestBodyLimitMb: requestBodyLimitMbTest,
FunctionTimeoutSec: timeoutSecTest,
},
},
}
warnAboutDeadFields(s)
require.Equal(t, fmt.Sprintf("Warning: %s; %s", functionTimeoutDepreciationMessage, functionRequestBodyLimitDepreciationMessage), s.warningBuilder.Build())
})
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,11 @@ spec:
description: A number of simultaneous jobs that can run at the same
time. The default value is `5`
type: string
functionRequestBodyLimitMb:
description: Used to configure the maximum size limit for the request
body of a Function. The default value is `1` megabyte
type: string
functionRequeueDuration:
description: Sets the requeue duration for Function. By default, the
Function associated with the default configuration is requeued every
5 minutes
type: string
functionTimeoutSec:
description: Sets the maximum execution time limit for a Function.
By default, the value is `180` seconds
type: string
healthzLivenessTimeout:
description: Sets the timeout for the Function health check. The default
value in seconds is `10`
Expand Down Expand Up @@ -205,12 +197,8 @@ spec:
type: string
functionBuildMaxSimultaneousJobs:
type: string
functionRequestBodyLimitMb:
type: string
functionRequeueDuration:
type: string
functionTimeoutSec:
type: string
healthzLivenessTimeout:
type: string
served:
Expand Down
6 changes: 0 additions & 6 deletions config/operator/base/ui-extensions/serverless/details
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ body:
- name: Max Simultaneous Builds
source: spec.functionBuildMaxSimultaneousJobs
visibility: '$exists($value)'
- name: Function Request Body Limit [Mb]
source: spec.functionRequestBodyLimitMb
visibility: '$exists($value)'
- name: Function Timeout [Sec]
source: spec.functionTimeoutSec
visibility: '$exists($value)'
- name: Function Requeue Duration
source: spec.functionRequeueDuration
visibility: '$exists($value)'
Expand Down
18 changes: 0 additions & 18 deletions docs/user/00-20-configure-serverless.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,6 @@ By default, the Function is considered unhealthy if the liveness health check en
healthzLivenessTimeout: "10s"
```

## Configure the Function Request Body Limit

Use this field to configure the maximum size limit for the request body of a Function. The default value is set to `1` megabyte.

```yaml
spec:
functionRequestBodyLimitMb: 1
```

## Configure the Function Timeout

By default, the maximum execution time limit for a Function is set to `180` seconds.

```yaml
spec:
functionTimeoutSec: 180
```

## Configure the Default Build Job Preset

You can configure the default build Job preset to be used.
Expand Down
8 changes: 1 addition & 7 deletions docs/user/resources/06-20-serverless-cr.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ The following Serverless custom resource (CR) shows configuration of Serverless
functionBuildExecutorArgs: "--insecure,--skip-tls-verify,--skip-unused-stages,--log-format=text,--cache=true,--use-new-run,--compressed-caching=false"
functionBuildMaxSimultaneousJobs: 5
healthzLivenessTimeout: "10s"
functionRequestBodyLimitMb: 1
functionTimeoutSec: 180
defaultBuildJobPreset: "normal"
defaultRuntimePodPreset: "M"
status:
Expand Down Expand Up @@ -75,8 +73,6 @@ For details, see the [Serverless specification file](https://github.com/kyma-pro
| **functionBuildExecutorArgs** | string | Specifies the arguments passed to the Function build executor |
| **functionBuildMaxSimultaneousJobs** | string | A number of simultaneous jobs that can run at the same time. The default value is `5` |
| **healthzLivenessTimeout** | string | Sets the timeout for the Function health check. The default value in seconds is `10` |
| **functionRequestBodyLimitMb** | string | Used to configure the maximum size limit for the request body of a Function. The default value is `1` megabyte |
| **functionTimeoutSec** | string | Sets the maximum execution time limit for a Function. By default, the value is `180` seconds |
| **defaultBuildJobPreset** | string | Configures the default build Job preset to be used |
| **defaultRuntimePodPreset** | string | Configures the default runtime Pod preset to be used |

Expand All @@ -100,9 +96,7 @@ For details, see the [Serverless specification file](https://github.com/kyma-pro
| **functionRequeueDuration** | string | Used the Function requeue duration. |
| **functionBuildExecutorArgs** | string | Used the Function build executor arguments. |
| **functionBuildMaxSimultaneousJobs** | string | Used the Function build max number of simultaneous jobs. |
| **healthzLivenessTimeout** | string | Used the healthz liveness timeout. |
| **functionRequestBodyLimitMb** | string | Used the Function request body limit. |
| **functionTimeoutSec** | string | Used the Function timeout. |
| **healthzLivenessTimeout** | string | Used the healthz liveness timeout. |
| **defaultBuildJobPreset** | string | Used the default build Job preset. |
| **defaultRuntimePodPreset** | string | Used the default runtime Pod preset. |

Expand Down
Loading