-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Kube Logs are stored and retrieved from Cloud Storage. #4053
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
a0827fa
Set Log4j2 debug mode. Successfull route job and app logs to S3 while…
davinchia 814449f
Turn everything into environment variables. Successfully use property…
davinchia aafa5bd
Checkpoint: Get GCS working.
davinchia d4e611f
Checkpoint: Get all objects out of a directory and write it to a file.
davinchia ff959a3
Checkpoint: Get scheduler and server logs from Cloud working using th…
davinchia 09c6d1d
Setup to test S3LoggingClient.
davinchia 98bca11
One initial test in S3Logs class.
davinchia 329bfd1
Fill in normal test.
davinchia 7d97575
Look at a specific folder.
davinchia e9bd71d
Correct error.
davinchia 35d1abf
Get logs tail working.
davinchia 6415d55
Format.
davinchia 3ff34b7
Pass test.
davinchia c9e89cb
Make logging test script executable. Disable most of build for faster…
davinchia 0299f44
Mount S3 secret for logging test.
davinchia 746a593
Strip quotes from jq output.
davinchia b3320c3
Uncomment rest of build.
davinchia 23c8c93
Add comments.
davinchia afbe9d2
Checkpoint: Kube modifications. Scheduler, Server and Job logs are wo…
davinchia 19db827
Remove affinity.
davinchia 858090b
Revert "Remove affinity."
davinchia 0dcb92b
Checkpoint: Stop emitting job id with MDC as we are not actually usin…
davinchia 742d780
Checkpoint: Remove Temporal PVC. Clean up logging functions and MDC key.
davinchia d08269a
Merge remote-tracking branch 'origin' into davinchia/s3-logging-exper…
davinchia 06f6981
Push code that is failing on Davin machine so Jared can test.
davinchia cbca608
Remove random changes.
davinchia e259fa3
Remove unused plugin.
davinchia 9801789
Remove GCP configuration for now.
davinchia e062f71
Remove logic added for GKE bug.
davinchia af615e1
Checkpoint: Job and app logs work. Get S3LogClient integration test w…
davinchia 0d8ccbc
Fix worker log test.
davinchia 35e998a
Fix job scheduler test.
davinchia ede5e42
Correct cloud storage test path. Fix format.
davinchia 2cb5730
Stash to check if master acceptance tests work.
davinchia b49c7c9
Does registering all modules fix test?
davinchia 8be0a6e
Add S3 credentials information to Kube acceptance tests.
davinchia 786d594
Add comments to explain Log4j config.
davinchia 9858624
Remove unneeded package.
davinchia d0043b3
Remove unneeded comments.
davinchia 31dd280
Respond to PR feedback.
davinchia 7014ea3
Explicitly require Jackson date time module.
davinchia d6b949d
Format.
davinchia 22eb741
Migrate all mappers to use injected function.
davinchia 2c4bd4c
More format.
davinchia File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
airbyte-commons/src/main/java/io/airbyte/commons/jackson/MoreMappers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.commons.jackson; | ||
|
||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
|
||
/** | ||
* The {@link JavaTimeModule} allows mappers to accommodate different varieties of serialised date | ||
* time strings. | ||
* | ||
* All jackson mapper creation should use the following methods for instantiation. | ||
*/ | ||
public class MoreMappers { | ||
|
||
public static ObjectMapper initMapper() { | ||
final ObjectMapper result = new ObjectMapper().registerModule(new JavaTimeModule()); | ||
result.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
return result; | ||
} | ||
|
||
public static ObjectMapper initYamlMapper(YAMLFactory factory) { | ||
return new ObjectMapper(factory).registerModule(new JavaTimeModule()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,26 +3,60 @@ | |
<Properties> | ||
<Property name="default-pattern">%d{yyyy-MM-dd HH:mm:ss}{GMT+0} %highlight{%p} %C{1.}(%M):%L - %X - %m%n</Property> | ||
<Property name="default-worker-file-pattern">%d{yyyy-MM-dd HH:mm:ss}{GMT+0} %p (%X{job_root}) %C{1}(%M):%L - %m%n</Property> | ||
|
||
<Property name="s3-bucket">$${env:S3_LOG_BUCKET}</Property> | ||
<Property name="s3-region">$${env:S3_LOG_BUCKET_REGION}</Property> | ||
<Property name="s3-aws-key">$${env:AWS_ACCESS_KEY_ID}</Property> | ||
<Property name="s3-aws-secret">$${env:AWS_SECRET_ACCESS_KEY}</Property> | ||
|
||
</Properties> | ||
|
||
<Appenders> | ||
<Console name="Default" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="${default-pattern}"/> | ||
</Console> | ||
|
||
<Routing name="LogSplit"> | ||
<Routes pattern="$${ctx:job_root}"> | ||
<Routes pattern="$${ctx:job_log_path}"> | ||
<!-- Don't split logs if job_root isn't defined --> | ||
<Route key="$${ctx:job_root}"> | ||
<Route key="$${ctx:job_log_path}"> | ||
<Null name="/dev/null"/> | ||
</Route> | ||
<Route> | ||
<File name="${ctx:job_root}" fileName="${ctx:job_root}/${ctx:job_log_filename}"> | ||
<File name="${ctx:job_log_path}-local" fileName="${ctx:job_log_path}"> | ||
<PatternLayout pattern="${default-worker-file-pattern}"/> | ||
</File> | ||
</Route> | ||
</Routes> | ||
<IdlePurgePolicy timeToLive="15" timeUnit="minutes"/> | ||
</Routing> | ||
|
||
<!-- | ||
Separate routers are created for each cloud logger as | ||
1) a Route only accepts 1 appender | ||
2) Routes don't support routing log output to more than Route | ||
--> | ||
<Routing name="LogSplitCloud"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will comment why we had to configure in this way - essentially only accepts one appender. |
||
<Routes pattern="$${ctx:job_log_path}"> | ||
<!-- Don't split logs if job_root isn't defined --> | ||
<Route key="$${ctx:job_log_path}"> | ||
<Null name="/dev/null"/> | ||
</Route> | ||
<Route> | ||
<Log4j2Appender name="${ctx:job_log_path}-cloud" | ||
verbose="true" | ||
stagingBufferAge="1" | ||
s3Bucket="${s3-bucket}" s3Path="job-logging${ctx:job_log_path}" s3Region="${s3-region}" | ||
s3AwsKey="${s3-aws-key}" s3AwsSecret="${s3-aws-secret}"> | ||
<PatternLayout> | ||
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Pattern> | ||
</PatternLayout> | ||
</Log4j2Appender> | ||
</Route> | ||
</Routes> | ||
<IdlePurgePolicy timeToLive="15" timeUnit="minutes"/> | ||
</Routing> | ||
|
||
<Routing name="AppLogSplit"> | ||
<Routes pattern="$${ctx:workspace_app_root}"> | ||
<!-- Don't split logs if workspace_app_log_root isn't defined --> | ||
|
@@ -31,7 +65,7 @@ | |
</Route> | ||
<Route> | ||
<RollingFile | ||
name="${ctx:workspace_app_root}" | ||
name="${ctx:workspace_app_root}-local" | ||
fileName="${ctx:workspace_app_root}/logs.log" | ||
filePattern="${ctx:workspace_app_root}/logs.%i.log.gz" | ||
ignoreExceptions="false"> | ||
|
@@ -47,13 +81,34 @@ | |
</Routes> | ||
<IdlePurgePolicy timeToLive="15" timeUnit="minutes"/> | ||
</Routing> | ||
<Routing name="AppLogSplitCloud"> | ||
<Routes pattern="$${ctx:workspace_app_root}"> | ||
<!-- Don't split logs if workspace_app_log_root isn't defined --> | ||
<Route key="$${ctx:workspace_app_root}"> | ||
<Null name="/dev/null"/> | ||
</Route> | ||
<Route> | ||
<Log4j2Appender name="app-logging/${ctx:workspace_app_root}-cloud/" | ||
stagingBufferAge="1" | ||
s3Bucket="${s3-bucket}" s3Path="app-logging${ctx:workspace_app_root}" s3Region="${s3-region}" | ||
s3AwsKey="${s3-aws-key}" s3AwsSecret="${s3-aws-secret}"> | ||
<PatternLayout> | ||
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Pattern> | ||
</PatternLayout> | ||
</Log4j2Appender> | ||
</Route> | ||
</Routes> | ||
<IdlePurgePolicy timeToLive="15" timeUnit="minutes"/> | ||
</Routing> | ||
</Appenders> | ||
|
||
<Loggers> | ||
<Root level="INFO"> | ||
<AppenderRef ref="Default"/> | ||
<AppenderRef ref="LogSplit"/> | ||
<AppenderRef ref="LogSplitCloud"/> | ||
<AppenderRef ref="AppLogSplit"/> | ||
<AppenderRef ref="AppLogSplitCloud"/> | ||
</Root> | ||
|
||
<Logger name="org.eclipse.jetty" level="INFO" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
airbyte-config/models/src/main/java/io/airbyte/config/helpers/CloudLogs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.config.helpers; | ||
|
||
import io.airbyte.config.Configs; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* Interface for various Cloud Storage clients supporting Cloud log retrieval. | ||
* | ||
* The underlying assumption 1) each file at the path is part of the entire log file represented by | ||
* that path 2) log files names start with timestamps, making it possible extract the time the file | ||
* was written from it's name. | ||
*/ | ||
public interface CloudLogs { | ||
|
||
/** | ||
* Retrieve all objects at the given path in lexicographical order, and return their contents as one | ||
* file. | ||
*/ | ||
File downloadCloudLog(Configs configs, String logPath) throws IOException; | ||
|
||
/** | ||
* Assume all the lexicographically ordered objects at the given path form one giant log file, | ||
* return the last numLines lines. | ||
*/ | ||
List<String> tailCloudLog(Configs configs, String logPath, int numLines) throws IOException; | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of https://github.com/airbytehq/airbyte/blob/master/build.gradle#L181, if everything is depending on airbyte-commons, it seems cleaner to have all of common's dependencies in the build.gradle as well.