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

Add details to error operator log #375

Merged
merged 2 commits into from
Mar 28, 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
1 change: 1 addition & 0 deletions acto/checker/impl/operator_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def check(
)
if is_invalid:
return InvalidInputResult(
message=value,
responsible_property=invalid_field_path
)
# We reported error if we found error in the operator log
Expand Down
3 changes: 3 additions & 0 deletions acto/checker/impl/tests/test_operator_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ def checker_func(s: Snapshot, prev_s: Snapshot) -> Optional[InvalidInputResult]:
enumerate(
[
InvalidInputResult(
message="StatefulSet.apps \"test-cluster-server\" is invalid: spec.template.spec.restartPolicy: Unsupported value: \"OnFailure\": supported values: \"Always\"",
responsible_property=PropertyPath([]),
),
None,
InvalidInputResult(
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",
responsible_property=PropertyPath([]),
),
InvalidInputResult(
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",
responsible_property=PropertyPath(
[
"spec",
Expand Down
6 changes: 4 additions & 2 deletions acto/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,13 @@ def invalid_input_message(
- when log indicates invalid input: the responsible field path for the invalid input
"""
logger = get_thread_logger(with_prefix=True)
is_invalid = False

for regex in INVALID_INPUT_LOG_REGEX:
if re.search(regex, log_msg):
logger.info("Recognized invalid input through regex: %s", log_msg)
return True, PropertyPath([])
is_invalid = True
break

# Check if the log line contains the field or value
# If so, also return True
Expand Down Expand Up @@ -621,7 +623,7 @@ def invalid_input_message(
)
return True, delta.path

return False, PropertyPath([])
return is_invalid, PropertyPath([])


def canonicalize(s: str):
Expand Down
Loading