Repository navigation
Fixes #37287: store agent logs in S3 whenever the server is configured for it (backport 2.1 #37394) - #38103
Conversation
…d for it (backport 2.1 #37394)
Code Review ✅ Approved 🔴 High riskChanging log-write authorization to accept EditIngestionPipelineStatus could let status-only roles submit misleading run logs. Backport of #37394 to 2.1 that makes S3-configured servers always enable streamable agent logs on deploy, reads each run's logs from where they were written, and lets log writes accept EditIngestionPipelineStatus so the Auto Classification bot can store logs. No issues found. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| return isS3LogStorageEnabled() | ||
| && isStorageRunKey(runId) | ||
| && ((runGoing && shipsLogsToStorage(pipeline)) | ||
| || runLogsStored(pipeline.getFullyQualifiedName(), UUID.fromString(runId))); |
There was a problem hiding this comment.
Redeploy hides active-run logs. A run that started with
enableStreamableLogs=false keeps that logging setup. Redeploying its pipeline with S3 configured now saves the flag as true, so this condition sends reads for the still-running old run to S3 without checking whether it uploaded anything. Its logs remain on the runner, but the viewer reads an empty store until the run finishes.
Choose the source using the run’s logging setting, not the pipeline’s latest flag, and cover a redeploy while an older run is still active.
| assertNotEquals(403, statusOfLogWrite(bot, runLogs), botName + " writing logs"); | ||
| assertEquals(200, statusOfLogWrite(bot, runLogs + "/close"), botName + " closing logs"); |
There was a problem hiding this comment.
Write checks accept unrelated failures.
assertNotEquals(403, ...) also passes for a malformed request, a missing route, or an unrelated server error. In particular, moving the write permission check back inside the broad catch would turn a refusal into 500 and still pass this assertion. The successful close check would not catch a write-only regression.
Use working storage and require a successful write with readable content, or check that the expected storage error—not an authorization error—caused the 500.
| private static void runDeploy(Runnable deploy) { | ||
| try (MockedConstruction<OpenMetadataConnectionBuilder> connectionBuilder = | ||
| Mockito.mockConstruction( | ||
| OpenMetadataConnectionBuilder.class, | ||
| (builder, context) -> | ||
| when(builder.build()).thenReturn(new OpenMetadataConnection())); | ||
| MockedStatic<Entity> entity = Mockito.mockStatic(Entity.class)) { | ||
| entity | ||
| .when(() -> Entity.getEntity(any(EntityReference.class), any(), any(Include.class))) | ||
| .thenReturn(mock(ServiceEntityInterface.class)); |
There was a problem hiding this comment.
Deploy tests replace internal code.
runDeploy replaces both OpenMetadataConnectionBuilder construction and static calls on Entity. The Java guide says to mock only the repository or external-system boundary through the constructor. These tests instead depend on how deployment finds its collaborators.
Use the real deployment setup in an integration test, or inject the needed boundary so these internal replacements are unnecessary.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| void runLogsAreReadFromWhereTheRunWroteThem( | ||
| String scenario, | ||
| LogStorageConfiguration.Type storageType, | ||
| String runId, | ||
| boolean runGoing, | ||
| boolean pipelineShipsLogs, | ||
| boolean logsStored, | ||
| boolean expected) |
There was a problem hiding this comment.
Test exceeds the argument limit. This new test takes seven arguments, including four booleans whose meaning depends on position. The Java guide sets a maximum of five parameters and requires a parameter object beyond that. Pass a named test-case record so the cases are harder to mix up.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| boolean latestRun = latestStatus != null && Objects.equals(runId, latestStatus.getRunId()); | ||
| PipelineStatus run = latestRun ? latestStatus : ownRunStatus(pipelineFQN, runId); |
There was a problem hiding this comment.
New bindings omit
final. latestRun and run are assigned once but lack final. The Java guide requires final on locals and parameters that do not change. Apply it here and to the other unchanged bindings added in this PR.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| updater.changeDescription.getFieldsUpdated().stream() | ||
| .filter(change -> "enableStreamableLogs".equals(change.getName())) |
There was a problem hiding this comment.
Test strings lack constants. The new assertion uses
"enableStreamableLogs" directly in .equals(), and the added cases repeat "svc.agent" throughout the file. The Java guide forbids raw strings in equality checks and requires repeated strings to be named constants. Extract those values so the cases share one definition.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Describe your changes:
Backport of #37394 to
2.1. Fixes #37287. Fixes #36568.When the server stores agent logs in S3, every deploy now turns the agent's
enableStreamableLogsflag on, so admins no longer have to enable it per agent through the API. The redeploy after an edit saves that flag, each run's logs are read from where that run wrote them, and log writes acceptEditIngestionPipelineStatuslike the other run-reporting endpoints, so the Auto Classification bot can store its logs.PIPELINE_SERVICE_CLIENT_LOG_ENABLEDis deprecated and ignored; it stays in the schema so existing configuration files keep loading.The eight commits of #37394 cherry-picked cleanly onto
2.1and were squashed into one;git patch-id --stableis identical to the diff of #37394.Type of change:
Tests:
Unit tests
IngestionPipelineRepositoryTest,S3LogStorageTestandIngestionLogStreamFactoryTeston2.1: 146 passed.Backend integration tests
IngestionPipelineLogStreamingResourceITcomes with the change and runs in CI.UI screen recording:
Not applicable: backend-only change (the UI files are regenerated types).
Checklist:
Fixes #<issue-number>above.REVIEW.md; no findings.Address the Java guide requirements before merging; also fix the active-run read choice and tighten the write assertion.
Findings
Summary
This backport automatically turns on S3 log uploads during deployment and chooses where to read logs using each run’s state.
The review found an active-run routing gap, a loose write-test assertion, and several violations of the Java guide. No tests were run during this review.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Deploy pipeline] --> B{S3 configured?} B -->|Yes| C[Turn on log uploads and save flag] B -->|No| D[Keep pipeline flag] C --> E[Agent uploads logs] E --> F[Check status-edit or full-edit permission] F --> G[S3 open stream, partial file, or final file] H[Read run logs] --> I{Run active with uploads enabled, or stored logs exist?} I -->|Yes| G I -->|No| J[Read from runner]Reviews (1) · Last reviewed commit: "Fixes #37287: store agent logs in S3 whe..." · Reviewed by Greptile