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

Pure CloudWatch Logs implementation with no Fluentd #8

Merged
merged 46 commits into from
Nov 20, 2018

Conversation

jglick
Copy link
Member

@jglick jglick commented Aug 22, 2018

If this works out, it would be a lot simpler conceptually and for administrators—no need to host and configure a separate service (meaning Evergreen could pick it up directly à la jenkins-infra/evergreen#128), and much more precise control over timing of event ingestion. And the Fluentd implementation as it stands is not suitable for production use since it has no means of limiting log output from agents to specified jobs (or builds) only.

  • PoC using AssumeRole (tests fail with access denied error if policy() is deliberately mistyped)
  • clean up role detection using new APIs in aws-credentials: Correcting default credentials when using assumed roles aws-credentials-plugin#46
  • test implementation starting from permanent user credentials with GetFederationToken
  • separate log stream per Jenkins Node so DescribeLogStreams can be restricted to the master
  • LogStorageTestBase.remotingInDocker to verify temporary credentials and job-granularity access control
  • asynchronous buffered log pushes
  • remove obsolete sender and timestamp fields
  • refresh temporary credentials when they expire

@jglick jglick changed the title Sketch of pure CloudWatch Logs implementation with no Fluentd Pure CloudWatch Logs implementation with no Fluentd Aug 22, 2018
Copy link

@dominicgunn dominicgunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of comments, nice work!

<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
<artifactId>pipeline-log-fluentd-cloudwatch</artifactId>
<artifactId>pipeline-log-fluentd-cloudwatch</artifactId> <!-- TODO minus fluentd -->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was waiting for a non-PR context to actually rename the plugin in full (artifact ID, package, repo…).

@@ -151,6 +151,7 @@ FormValidation validate(String logGroupName, String region, String credentialsId

try {
filter(client, logGroupName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tickets in backlog to do these todos?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afraid not, this is on an “as is” basis.

List<FilteredLogEvent> events;
try {
events = client.filterLogEvents(createFilter().withFilterPattern("{$.timestamp = " + timestamp + "}").withLimit(1)).getEvents();
events = client.filterLogEvents(createFilter().withLimit(1).withStartTime(timestamp)).getEvents();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By way of background, the timestamp field in JSON (duplicating the native AWS Logs input / result event field) was there due to a bug in the Fluentd plugin that forwarded messages: fluent-plugins-nursery/fluent-plugin-cloudwatch-logs#108

synchronized (agentLogStreamNames) {
for (int i = 1; ; i++) {
String candidate = logStreamNameBase + "@agent" + i;
if (agentLogStreamNames.add(candidate)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care this is unbounded? What's the likelihood of this Set getting a bit too large?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ought not get particularly large I think. The maximum size should be roughly the maximum number of agents being used concurrently by all builds of a given job. So, on the order of a few to dozens typically.

return;
}
String sequenceToken = null;
MAIN: while (true) {
Copy link

@dominicgunn dominicgunn Oct 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I've ever seen this used in Java before, interesting!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it happens in Java, probably the code needs some refactoring :)

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with the current code if it targets the alpha release, it looks solid though I am not fully familiar with the codebase. Once AWS Credentials are fixed, it can be released IMO. TODOs can be addressed later, as well as any performance concerns

<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>
<url>https://wiki.jenkins.io/display/JENKINS/Pipeline+Log+Fluentd+CloudWatch+Plugin</url>
<url>https://wiki.jenkins.io/display/JENKINS/Pipeline+Log+Fluentd+CloudWatch+Plugin</url> <!-- TODO minus fluentd -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address these TODOs before the alpha release?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would expect to do that along with renaming the repository and adjusting the entry in repository-permissions-updater.

pom.xml Outdated Show resolved Hide resolved
@oleg-nenashev
Copy link
Member

I also agree with some of @dominicgunn's code improvement proposals. Adding TODOs or addressing them would make sense

Copy link
Contributor

@carlossg carlossg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to work fine

@jglick jglick merged commit c799639 into jenkinsci:master Nov 20, 2018
@jglick jglick deleted the pure-cloudwatch branch November 20, 2018 18:27
@jglick jglick mentioned this pull request Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants