Skip to content

Commit 92fb7c3

Browse files
authored
Add details to error operator log (#375)
* Add details to error operator log * Update test for new error log reporting
1 parent d22fa25 commit 92fb7c3

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

acto/checker/impl/operator_log.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def check(
3434
)
3535
if is_invalid:
3636
return InvalidInputResult(
37+
message=value,
3738
responsible_property=invalid_field_path
3839
)
3940
# We reported error if we found error in the operator log

acto/checker/impl/tests/test_operator_log.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ def checker_func(s: Snapshot, prev_s: Snapshot) -> Optional[InvalidInputResult]:
2424
enumerate(
2525
[
2626
InvalidInputResult(
27+
message="StatefulSet.apps \"test-cluster-server\" is invalid: spec.template.spec.restartPolicy: Unsupported value: \"OnFailure\": supported values: \"Always\"",
2728
responsible_property=PropertyPath([]),
2829
),
2930
None,
3031
InvalidInputResult(
32+
message="tidb cluster acto-namespace/test-cluster is not valid and must be fixed first, aggregated error: spec.tidb.volumeName: Invalid value: \"lsgqejeydt\": Can not find volumeName: lsgqejeydt in storageVolumes or additionalVolumes/additionalVolumeMounts",
3133
responsible_property=PropertyPath([]),
3234
),
3335
InvalidInputResult(
36+
message="github.com/rabbitmq/cluster-operator/controllers.(*RabbitmqClusterReconciler).Reconcile\n\t/workspace/controllers/rabbitmqcluster_controller.go:260\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:298\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:253\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:214",
3437
responsible_property=PropertyPath(
3538
[
3639
"spec",

acto/common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,11 +583,13 @@ def invalid_input_message(
583583
- when log indicates invalid input: the responsible field path for the invalid input
584584
"""
585585
logger = get_thread_logger(with_prefix=True)
586+
is_invalid = False
586587

587588
for regex in INVALID_INPUT_LOG_REGEX:
588589
if re.search(regex, log_msg):
589590
logger.info("Recognized invalid input through regex: %s", log_msg)
590-
return True, PropertyPath([])
591+
is_invalid = True
592+
break
591593

592594
# Check if the log line contains the field or value
593595
# If so, also return True
@@ -621,7 +623,7 @@ def invalid_input_message(
621623
)
622624
return True, delta.path
623625

624-
return False, PropertyPath([])
626+
return is_invalid, PropertyPath([])
625627

626628

627629
def canonicalize(s: str):

0 commit comments

Comments
 (0)