From 2e93f5f91f1cd966ad06017c46d6e8f726f2c8e7 Mon Sep 17 00:00:00 2001 From: Sam Sgro Date: Sat, 18 Oct 2014 16:11:36 -0400 Subject: [PATCH 1/6] - latest karyon has split its examples into multiple directories. multiple fixes related to running Jersey example - make patchEndpoint a true build dependency --- karyon/build.gradle | 31 +++++++++++++++++++------------ karyon/root/etc/init/karyon.conf | 6 +++--- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/karyon/build.gradle b/karyon/build.gradle index 7a1a14a..1da8287 100644 --- a/karyon/build.gradle +++ b/karyon/build.gradle @@ -7,47 +7,55 @@ task cloneRepo(type: CloneRepo) { task patchRepo { dependsOn 'cloneRepo' doFirst { - def app = new File(cloneRepo.gitDir, 'karyon-examples/hello-netflix-oss/src/main/java/com/netflix/hellonoss/server/HelloWorldApp.java') + def app = new File(cloneRepo.gitDir, 'karyon-examples/src/main/java/com/netflix/karyon/examples/hellonoss/server/jersey/JerseyHelloWorldApp.java') def contents = app.text app.withWriter { out -> out << contents - .replace('//, KaryonEurekaModule.class', ', KaryonEurekaModule.class') + .replace('import com.netflix.karyon.servo.KaryonServoModule;', 'import com.netflix.karyon.servo.KaryonServoModule;\nimport com.netflix.karyon.eureka.KaryonEurekaModule;') + .replace('// KaryonEurekaModule.class,', 'KaryonEurekaModule.class, ') // It's impossible to test REST calls from a browser if a HTTP Header is required. - .replace('interceptorSupport.forUri("/hello").interceptIn(AuthInterceptor.class);', '//interceptorSupport.forUri("/hello").interceptIn(AuthInterceptor.class);') + .replace('interceptorSupport().forUri("/hello").interceptIn(AuthInterceptor.class);', '//interceptorSupport().forUri("/hello").interceptIn(AuthInterceptor.class);') } - def scanning = new File(cloneRepo.gitDir, 'karyon-examples/hello-netflix-oss/src/main/resources/hello-netflix-oss.properties') + def scanning = new File(cloneRepo.gitDir, 'karyon-examples/src/main/resources/hello-netflix-oss.properties') def scanContents = scanning.text scanning.withWriter { out -> // Let jersey scan Eureka package for healthcheck - out << scanContents.replace('com.netflix.hellonoss', 'com.netflix.hellonoss,com.netflix.appinfo') + out << scanContents.replace('com.netflix.karyon.examples.hellonoss', 'com.netflix.karyon.examples.hellonoss,com.netflix.appinfo') } + + def mc = new File(cloneRepo.gitDir, 'karyon-examples/build.gradle') + def mcContents = mc.text + mc.withWriter { out -> + // need to rewire + out << mcContents.replace("apply plugin: 'application'", "apply plugin: 'application'\nmainClassName = 'com.netflix.karyon.KaryonRunner'") + } } } task patchEndpoint { dependsOn 'cloneRepo' doFirst { - def app = new File(cloneRepo.gitDir, 'karyon-examples/hello-netflix-oss/src/main/java/com/netflix/hellonoss/server/HelloworldResource.java') + def app = new File(cloneRepo.gitDir, 'karyon-examples/src/main/java/com/netflix/karyon/examples/hellonoss/server/jersey/HelloworldResource.java') def contents = app.text app.withWriter { out -> out << contents - .replace('Hello Netflix OSS component!', 'Hello Zero To Cloud developer!') + .replace('Netflix OSS', 'Zero to Cloud Developers!') } } } task buildRepo(type: Build) { - dependsOn 'cloneRepo', 'patchRepo' + dependsOn 'cloneRepo', 'patchRepo', 'patchEndpoint' mustRunAfter 'patchEndpoint' moduleDir = cloneRepo.gitDir - arguments = [':karyon-examples:hello-netflix-oss:distZip', '-x', 'check', '-x', 'signArchives', '-x', 'sourcesJar', '-x', 'javadocJar', '--stacktrace'] + arguments = [':karyon-examples:distZip', '-x', 'check', '-x', 'signArchives', '-x', 'sourcesJar', '-x', 'javadocJar', '--stacktrace'] } import org.apache.tools.ant.filters.* ospackage { - def dist = new File(buildRepo.moduleDir, 'karyon-examples/hello-netflix-oss/build/distributions/hello-netflix-oss-2.1.00-RC3.zip') + def dist = new File(buildRepo.moduleDir, 'karyon-examples/build/distributions/karyon-examples-2.1.00-RC6.zip') from( zipTree(dist) ) { into('/opt') } @@ -55,7 +63,6 @@ ospackage { into('/') filter ReplaceTokens, tokens: [ 'KARYON_OPTS': System.getenv('KARYON_OPTS') ?: '' ] } - postInstall('mv /opt/hello-netflix-oss* /opt/hello-netflix-oss') // zip was nested postInstall('echo manual > /etc/init/tomcat7.override') } -buildDeb.dependsOn(buildRepo) \ No newline at end of file +buildDeb.dependsOn(buildRepo) diff --git a/karyon/root/etc/init/karyon.conf b/karyon/root/etc/init/karyon.conf index 0a42de7..c91c875 100644 --- a/karyon/root/etc/init/karyon.conf +++ b/karyon/root/etc/init/karyon.conf @@ -6,6 +6,6 @@ env enabled=1 respawn -env JAVA_OPTS="-Xmx2560m -Djava.awt.headless=true -Deureka.name=karyon -Deureka.region=us-west-2 -Deureka.port=8888 -Deureka.us-west-2.availabilityZones=default @KARYON_OPTS@" -exec start-stop-daemon --start --chuid ubuntu --chdir /opt/hello-netflix-oss/ \ ---exec /opt/hello-netflix-oss/bin/hello-netflix-oss -- com.netflix.hellonoss.server.HelloWorldApp +env JAVA_OPTS="-Xmx2560m -Djava.awt.headless=true -Deureka.name=karyon -Deureka.region=us-west-2 -Deureka.port=80 -Deureka.us-west-2.availabilityZones=default @KARYON_OPTS@" +exec start-stop-daemon --start --chuid ubuntu --chdir /opt/karyon-examples-2.1.00-RC6/ \ +--exec /opt/karyon-examples-2.1.00-RC6/bin/karyon-examples -- com.netflix.karyon.examples.hellonoss.server.jersey.JerseyHelloWorldApp From 5b9326900fb6295aa24263516068da7d3fd16388 Mon Sep 17 00:00:00 2001 From: Sam Sgro Date: Sat, 18 Oct 2014 17:45:54 -0400 Subject: [PATCH 2/6] Formatting fixes --- karyon/build.gradle | 59 +++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/karyon/build.gradle b/karyon/build.gradle index 1da8287..45530e5 100644 --- a/karyon/build.gradle +++ b/karyon/build.gradle @@ -1,53 +1,54 @@ import zerotocloud.* task cloneRepo(type: CloneRepo) { - repository = 'https://github.com/Netflix/karyon.git' + repository = 'https://github.com/Netflix/karyon.git' + } task patchRepo { - dependsOn 'cloneRepo' + dependsOn 'cloneRepo' doFirst { - def app = new File(cloneRepo.gitDir, 'karyon-examples/src/main/java/com/netflix/karyon/examples/hellonoss/server/jersey/JerseyHelloWorldApp.java') + def app = new File(cloneRepo.gitDir, 'karyon-examples/src/main/java/com/netflix/karyon/examples/hellonoss/server/jersey/JerseyHelloWorldApp.java') def contents = app.text app.withWriter { out -> - out << contents - .replace('import com.netflix.karyon.servo.KaryonServoModule;', 'import com.netflix.karyon.servo.KaryonServoModule;\nimport com.netflix.karyon.eureka.KaryonEurekaModule;') - .replace('// KaryonEurekaModule.class,', 'KaryonEurekaModule.class, ') - // It's impossible to test REST calls from a browser if a HTTP Header is required. - .replace('interceptorSupport().forUri("/hello").interceptIn(AuthInterceptor.class);', '//interceptorSupport().forUri("/hello").interceptIn(AuthInterceptor.class);') + out << contents + .replace('import com.netflix.karyon.servo.KaryonServoModule;', 'import com.netflix.karyon.servo.KaryonServoModule;\nimport com.netflix.karyon.eureka.KaryonEurekaModule;') + .replace('// KaryonEurekaModule.class,', 'KaryonEurekaModule.class, ') + // It's impossible to test REST calls from a browser if a HTTP Header is required. + .replace('interceptorSupport().forUri("/hello").interceptIn(AuthInterceptor.class);', '//interceptorSupport().forUri("/hello").interceptIn(AuthInterceptor.class);') } - def scanning = new File(cloneRepo.gitDir, 'karyon-examples/src/main/resources/hello-netflix-oss.properties') + def scanning = new File(cloneRepo.gitDir, 'karyon-examples/src/main/resources/hello-netflix-oss.properties') def scanContents = scanning.text scanning.withWriter { out -> - // Let jersey scan Eureka package for healthcheck - out << scanContents.replace('com.netflix.karyon.examples.hellonoss', 'com.netflix.karyon.examples.hellonoss,com.netflix.appinfo') + // Let jersey scan Eureka package for healthcheck + out << scanContents.replace('com.netflix.karyon.examples.hellonoss', 'com.netflix.karyon.examples.hellonoss,com.netflix.appinfo') } - def mc = new File(cloneRepo.gitDir, 'karyon-examples/build.gradle') - def mcContents = mc.text - mc.withWriter { out -> - // need to rewire - out << mcContents.replace("apply plugin: 'application'", "apply plugin: 'application'\nmainClassName = 'com.netflix.karyon.KaryonRunner'") - } + def mc = new File(cloneRepo.gitDir, 'karyon-examples/build.gradle') + def mcContents = mc.text + mc.withWriter { out -> + // need to rewire + out << mcContents.replace("apply plugin: 'application'", "apply plugin: 'application'\nmainClassName = 'com.netflix.karyon.KaryonRunner'") + } } } task patchEndpoint { - dependsOn 'cloneRepo' + dependsOn 'cloneRepo' doFirst { - def app = new File(cloneRepo.gitDir, 'karyon-examples/src/main/java/com/netflix/karyon/examples/hellonoss/server/jersey/HelloworldResource.java') + def app = new File(cloneRepo.gitDir, 'karyon-examples/src/main/java/com/netflix/karyon/examples/hellonoss/server/jersey/HelloworldResource.java') def contents = app.text app.withWriter { out -> - out << contents - .replace('Netflix OSS', 'Zero to Cloud Developers!') + out << contents + .replace('Netflix OSS', 'Zero to Cloud Developers!') } } } task buildRepo(type: Build) { - dependsOn 'cloneRepo', 'patchRepo', 'patchEndpoint' + dependsOn 'cloneRepo', 'patchRepo', 'patchEndpoint' mustRunAfter 'patchEndpoint' moduleDir = cloneRepo.gitDir arguments = [':karyon-examples:distZip', '-x', 'check', '-x', 'signArchives', '-x', 'sourcesJar', '-x', 'javadocJar', '--stacktrace'] @@ -55,14 +56,14 @@ task buildRepo(type: Build) { import org.apache.tools.ant.filters.* ospackage { - def dist = new File(buildRepo.moduleDir, 'karyon-examples/build/distributions/karyon-examples-2.1.00-RC6.zip') + def dist = new File(buildRepo.moduleDir, 'karyon-examples/build/distributions/karyon-examples-2.1.00-RC6.zip') from( zipTree(dist) ) { - into('/opt') - } - from(file('root')) { - into('/') - filter ReplaceTokens, tokens: [ 'KARYON_OPTS': System.getenv('KARYON_OPTS') ?: '' ] + into('/opt') } - postInstall('echo manual > /etc/init/tomcat7.override') + from(file('root')) { + into('/') + filter ReplaceTokens, tokens: [ 'KARYON_OPTS': System.getenv('KARYON_OPTS') ?: '' ] + } + postInstall('echo manual > /etc/init/tomcat7.override') } buildDeb.dependsOn(buildRepo) From e98333e67fbd1cc0ad7f41a61f0741e5e588b532 Mon Sep 17 00:00:00 2001 From: Sam Sgro Date: Thu, 23 Oct 2014 16:49:28 -0400 Subject: [PATCH 3/6] Manually switching versions TODO: find a better mechanism --- karyon/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karyon/build.gradle b/karyon/build.gradle index 1da8287..63725ff 100644 --- a/karyon/build.gradle +++ b/karyon/build.gradle @@ -55,7 +55,7 @@ task buildRepo(type: Build) { import org.apache.tools.ant.filters.* ospackage { - def dist = new File(buildRepo.moduleDir, 'karyon-examples/build/distributions/karyon-examples-2.1.00-RC6.zip') + def dist = new File(buildRepo.moduleDir, 'karyon-examples/build/distributions/karyon-examples-2.1.00-RC7.zip') from( zipTree(dist) ) { into('/opt') } From b8d23c118108765202a5fba691a5a8e35fc89495 Mon Sep 17 00:00:00 2001 From: samsgro Date: Thu, 23 Oct 2014 16:52:06 -0400 Subject: [PATCH 4/6] Fixing to RC7 --- karyon/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karyon/build.gradle b/karyon/build.gradle index 45530e5..283cf72 100644 --- a/karyon/build.gradle +++ b/karyon/build.gradle @@ -56,7 +56,7 @@ task buildRepo(type: Build) { import org.apache.tools.ant.filters.* ospackage { - def dist = new File(buildRepo.moduleDir, 'karyon-examples/build/distributions/karyon-examples-2.1.00-RC6.zip') + def dist = new File(buildRepo.moduleDir, 'karyon-examples/build/distributions/karyon-examples-2.1.00-RC7.zip') from( zipTree(dist) ) { into('/opt') } From 77452e08b436013acc7287c59f19d38b68867dea Mon Sep 17 00:00:00 2001 From: samsgro Date: Thu, 23 Oct 2014 16:54:14 -0400 Subject: [PATCH 5/6] Fixing to RC7 --- karyon/root/etc/init/karyon.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/karyon/root/etc/init/karyon.conf b/karyon/root/etc/init/karyon.conf index c91c875..5c29559 100644 --- a/karyon/root/etc/init/karyon.conf +++ b/karyon/root/etc/init/karyon.conf @@ -7,5 +7,5 @@ env enabled=1 respawn env JAVA_OPTS="-Xmx2560m -Djava.awt.headless=true -Deureka.name=karyon -Deureka.region=us-west-2 -Deureka.port=80 -Deureka.us-west-2.availabilityZones=default @KARYON_OPTS@" -exec start-stop-daemon --start --chuid ubuntu --chdir /opt/karyon-examples-2.1.00-RC6/ \ ---exec /opt/karyon-examples-2.1.00-RC6/bin/karyon-examples -- com.netflix.karyon.examples.hellonoss.server.jersey.JerseyHelloWorldApp +exec start-stop-daemon --start --chuid ubuntu --chdir /opt/karyon-examples-2.1.00-RC7/ \ +--exec /opt/karyon-examples-2.1.00-RC7/bin/karyon-examples -- com.netflix.karyon.examples.hellonoss.server.jersey.JerseyHelloWorldApp From c7be6f940d97a73eedb0eb443187757ff7960c99 Mon Sep 17 00:00:00 2001 From: Sam Sgro Date: Fri, 24 Oct 2014 02:33:15 -0400 Subject: [PATCH 6/6] Separating out :patchEndpoint for red/black testing to work --- karyon/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karyon/build.gradle b/karyon/build.gradle index 63725ff..b197432 100644 --- a/karyon/build.gradle +++ b/karyon/build.gradle @@ -47,7 +47,7 @@ task patchEndpoint { } task buildRepo(type: Build) { - dependsOn 'cloneRepo', 'patchRepo', 'patchEndpoint' + dependsOn 'cloneRepo', 'patchRepo' mustRunAfter 'patchEndpoint' moduleDir = cloneRepo.gitDir arguments = [':karyon-examples:distZip', '-x', 'check', '-x', 'signArchives', '-x', 'sourcesJar', '-x', 'javadocJar', '--stacktrace']