Skip to content

Commit

Permalink
Merge pull request #900 from dafsjr/rfe-3765
Browse files Browse the repository at this point in the history
RFE-3765 - Allow Ingress to Modify the HAProxy Log Length when using a Sidecar
  • Loading branch information
openshift-merge-robot authored Jul 20, 2023
2 parents 80cfabf + 8184bce commit b4b5f42
Show file tree
Hide file tree
Showing 21 changed files with 911 additions and 29 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ require (
// github.com/operator-framework/operator-sdk.
replace (
bitbucket.org/ww/goautoneg => github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d
github.com/openshift/api => github.com/openshift/api v0.0.0-20230602160751-5c5196d9f4af
github.com/openshift/api => github.com/openshift/api v0.0.0-20230607151152-bdd886567621
k8s.io/client-go => k8s.io/client-go v0.27.2
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,8 @@ github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.m
github.com/opencontainers/runtime-spec v0.1.2-0.20190618234442-a950415649c7/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs=
github.com/openshift/api v0.0.0-20230602160751-5c5196d9f4af h1:d31ErBNJPDZkZcUjex+QiTKJLLyMcIhHUkER7CcURwU=
github.com/openshift/api v0.0.0-20230602160751-5c5196d9f4af/go.mod h1:4VWG+W22wrB4HfBL88P40DxLEpSOaiBVxUnfalfJo9k=
github.com/openshift/api v0.0.0-20230607151152-bdd886567621 h1:vMG+ycFy+2Ulk6Kl5jp4FkfTxRc/DnctgljQcQeGKJ8=
github.com/openshift/api v0.0.0-20230607151152-bdd886567621/go.mod h1:4VWG+W22wrB4HfBL88P40DxLEpSOaiBVxUnfalfJo9k=
github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc=
github.com/openshift/client-go v0.0.0-20200116152001-92a2713fa240/go.mod h1:4riOwdj99Hd/q+iAcJZfNCsQQQMwURnZV6RL4WHYS5w=
github.com/openshift/client-go v0.0.0-20230120202327-72f107311084 h1:66uaqNwA+qYyQDwsMWUfjjau8ezmg1dzCqub13KZOcE=
Expand Down
10 changes: 9 additions & 1 deletion manifests/00-custom-resource-definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ spec:
properties:
container:
description: container holds parameters for the Container logging destination. Present only if type is Container.
properties:
maxLength:
default: 1024
description: "maxLength is the maximum length of the log message. \n Valid values are integers in the range 480 to 8192, inclusive. \n When omitted, the default value is 1024."
format: int32
maximum: 8192
minimum: 480
type: integer
type: object
syslog:
description: syslog holds parameters for a syslog endpoint. Present only if type is Syslog.
Expand Down Expand Up @@ -351,7 +359,7 @@ spec:
type: string
maxLength:
default: 1024
description: "maxLength is the maximum length of the syslog message \n If this field is empty, the maxLength is set to \"1024\"."
description: "maxLength is the maximum length of the log message. \n Valid values are integers in the range 480 to 4096, inclusive. \n When omitted, the default value is 1024."
format: int32
maximum: 4096
minimum: 480
Expand Down
8 changes: 4 additions & 4 deletions pkg/manifests/bindata.go

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions pkg/operator/controller/ingress/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ const (

RouterHTTPHeaderNameCaseAdjustments = "ROUTER_H1_CASE_ADJUST"

RouterLogLevelEnvName = "ROUTER_LOG_LEVEL"
RouterSyslogAddressEnvName = "ROUTER_SYSLOG_ADDRESS"
RouterSyslogFormatEnvName = "ROUTER_SYSLOG_FORMAT"
RouterSyslogFacilityEnvName = "ROUTER_LOG_FACILITY"
RouterSyslogMaxLengthEnvName = "ROUTER_LOG_MAX_LENGTH"
RouterLogLevelEnvName = "ROUTER_LOG_LEVEL"
RouterLogMaxLengthEnvName = "ROUTER_LOG_MAX_LENGTH"
RouterSyslogAddressEnvName = "ROUTER_SYSLOG_ADDRESS"
RouterSyslogFormatEnvName = "ROUTER_SYSLOG_FORMAT"
RouterSyslogFacilityEnvName = "ROUTER_LOG_FACILITY"

RouterCaptureHTTPRequestHeaders = "ROUTER_CAPTURE_HTTP_REQUEST_HEADERS"
RouterCaptureHTTPResponseHeaders = "ROUTER_CAPTURE_HTTP_RESPONSE_HEADERS"
Expand Down Expand Up @@ -764,20 +764,27 @@ func desiredRouterDeployment(ci *operatorv1.IngressController, ingressController
},
}

if accessLogging.Destination.Container.MaxLength > 0 {
env = append(env, corev1.EnvVar{
Name: RouterLogMaxLengthEnvName,
Value: fmt.Sprintf("%d", accessLogging.Destination.Container.MaxLength),
})
}
env = append(env,
corev1.EnvVar{Name: RouterSyslogAddressEnvName, Value: socketPath},
corev1.EnvVar{Name: RouterLogLevelEnvName, Value: "info"},
)
volumes = append(volumes, rsyslogConfigVolume, rsyslogSocketVolume)
routerVolumeMounts = append(routerVolumeMounts, rsyslogSocketVolumeMount)
deployment.Spec.Template.Spec.Containers = append(deployment.Spec.Template.Spec.Containers, syslogContainer)

case accessLogging.Destination.Type == operatorv1.SyslogLoggingDestinationType:
if len(accessLogging.Destination.Syslog.Facility) > 0 {
env = append(env, corev1.EnvVar{Name: RouterSyslogFacilityEnvName, Value: accessLogging.Destination.Syslog.Facility})
}
if accessLogging.Destination.Syslog.MaxLength > 0 {
env = append(env, corev1.EnvVar{
Name: RouterSyslogMaxLengthEnvName,
Name: RouterLogMaxLengthEnvName,
Value: fmt.Sprintf("%d", accessLogging.Destination.Syslog.MaxLength),
})
}
Expand Down Expand Up @@ -1113,10 +1120,14 @@ func accessLoggingForIngressController(ic *operatorv1.IngressController) *operat

switch ic.Spec.Logging.Access.Destination.Type {
case operatorv1.ContainerLoggingDestinationType:
var containerLoggingParameters operatorv1.ContainerLoggingDestinationParameters
if ic.Spec.Logging.Access.Destination.Container != nil {
containerLoggingParameters.MaxLength = ic.Spec.Logging.Access.Destination.Container.MaxLength
}
return &operatorv1.AccessLogging{
Destination: operatorv1.LoggingDestination{
Type: operatorv1.ContainerLoggingDestinationType,
Container: &operatorv1.ContainerLoggingDestinationParameters{},
Container: &containerLoggingParameters,
},
HttpLogFormat: ic.Spec.Logging.Access.HttpLogFormat,
HTTPCaptureHeaders: ic.Spec.Logging.Access.HTTPCaptureHeaders,
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/controller/ingress/rsyslog_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ import (

const (
// rsyslogConfiguration is the contents for rsyslog.conf.
// The parameter "$MaxMessageSize 10k" is needed to allow messages with
// 8192 characters, because the default value only allows messages with
// maximum 8096 characters.
rsyslogConfiguration = `$ModLoad imuxsock
$SystemLogSocketName /var/lib/rsyslog/rsyslog.sock
$ModLoad omstdout.so
$MaxMessageSize 10k
*.* :omstdout:
`
)
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func TestAll(t *testing.T) {
t.Run("TestMTLSWithCRLs", TestMTLSWithCRLs)
t.Run("TestCRLUpdate", TestCRLUpdate)
t.Run("TestContainerLogging", TestContainerLogging)
t.Run("TestContainerLoggingMaxLength", TestContainerLoggingMaxLength)
t.Run("TestContainerLoggingMinLength", TestContainerLoggingMinLength)
t.Run("TestCustomErrorpages", TestCustomErrorpages)
t.Run("TestCustomIngressClass", TestCustomIngressClass)
t.Run("TestDomainNotMatchingBase", TestDomainNotMatchingBase)
Expand Down
Loading

0 comments on commit b4b5f42

Please sign in to comment.