Skip to content

Commit 9039b0b

Browse files
authored
Add error checking and comments around custom logging config. (#885)
Previously, custom logging configs were now allowed, but there was not a lot of documentation and error checking. This PR adds this.
1 parent f98c5f3 commit 9039b0b

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

apis/v1alpha1/cluster_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ type CrdbClusterSpec struct {
134134
// proper channels in the cockroachdb. Logging configuration is available for cockroach version v21.1.0 onwards.
135135
// The logging configuration is taken in format of yaml file, you can check the logging configuration here (https://www.cockroachlabs.com/docs/stable/configure-logs.html#default-logging-configuration)
136136
// The default logging for cockroach version v20.x or less is stderr, logging API is ignored for older versions.
137+
// NOTE: The `data` field of map must contain an entry called `logging.yaml`
138+
// that contains config options.
137139
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Cockroach Database Logging configuration config map"
138140
// +optional
139141
LogConfigMap string `json:"logConfigMap,omitempty"`

config/crd/bases/crdb.cockroachlabs.com_crdbclusters.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -974,13 +974,16 @@ spec:
974974
type: object
975975
type: object
976976
logConfigMap:
977-
description: (Optional) LogConfigMap define the config map which contains
978-
log configuration used to send the logs through the proper channels
979-
in the cockroachdb. Logging configuration is available for cockroach
980-
version v21.1.0 onwards. The logging configuration is taken in format
981-
of yaml file, you can check the logging configuration here (https://www.cockroachlabs.com/docs/stable/configure-logs.html#default-logging-configuration)
977+
description: '(Optional) LogConfigMap define the config map which
978+
contains log configuration used to send the logs through the proper
979+
channels in the cockroachdb. Logging configuration is available
980+
for cockroach version v21.1.0 onwards. The logging configuration
981+
is taken in format of yaml file, you can check the logging configuration
982+
here (https://www.cockroachlabs.com/docs/stable/configure-logs.html#default-logging-configuration)
982983
The default logging for cockroach version v20.x or less is stderr,
983-
logging API is ignored for older versions.
984+
logging API is ignored for older versions. NOTE: The `data` field
985+
of map must contain an entry called `logging.yaml` that contains
986+
config options.'
984987
type: string
985988
maxSQLMemory:
986989
description: '(Optional) The maximum in-memory storage capacity available

install/crds.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -972,13 +972,16 @@ spec:
972972
type: object
973973
type: object
974974
logConfigMap:
975-
description: (Optional) LogConfigMap define the config map which contains
976-
log configuration used to send the logs through the proper channels
977-
in the cockroachdb. Logging configuration is available for cockroach
978-
version v21.1.0 onwards. The logging configuration is taken in format
979-
of yaml file, you can check the logging configuration here (https://www.cockroachlabs.com/docs/stable/configure-logs.html#default-logging-configuration)
975+
description: '(Optional) LogConfigMap define the config map which
976+
contains log configuration used to send the logs through the proper
977+
channels in the cockroachdb. Logging configuration is available
978+
for cockroach version v21.1.0 onwards. The logging configuration
979+
is taken in format of yaml file, you can check the logging configuration
980+
here (https://www.cockroachlabs.com/docs/stable/configure-logs.html#default-logging-configuration)
980981
The default logging for cockroach version v20.x or less is stderr,
981-
logging API is ignored for older versions.
982+
logging API is ignored for older versions. NOTE: The `data` field
983+
of map must contain an entry called `logging.yaml` that contains
984+
config options.'
982985
type: string
983986
maxSQLMemory:
984987
description: '(Optional) The maximum in-memory storage capacity available

pkg/resource/cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ func (cluster Cluster) LoggingConfiguration(fetcher Fetcher) (string, error) {
334334

335335
if val, ok := cm.Data["logging.yaml"]; ok {
336336
return `"` + val + `"`, nil
337+
} else {
338+
return "", errors.Newf(
339+
"`logging.yaml` entry not found in configMap %s", cluster.Spec().LogConfigMap)
337340
}
338341
}
339342

0 commit comments

Comments
 (0)