diff --git a/examples/application.conf b/examples/application.conf index 45788f55..ce21e57c 100644 --- a/examples/application.conf +++ b/examples/application.conf @@ -1,6 +1,6 @@ akka { loggers = ["akka.event.slf4j.Slf4jLogger"] -# loglevel = "DEBUG" + loglevel = "ERROR" logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" actor { debug { diff --git a/examples/src/main/scala/skuber/examples/customresources/CreateCRD.scala b/examples/src/main/scala/skuber/examples/customresources/CreateCRD.scala index 946c1944..3106541d 100644 --- a/examples/src/main/scala/skuber/examples/customresources/CreateCRD.scala +++ b/examples/src/main/scala/skuber/examples/customresources/CreateCRD.scala @@ -46,9 +46,15 @@ object CreateCRD extends App { case Success(_) => System.out.println("done!") k8s.close + system.terminate().foreach { f => + System.exit(0) + } case Failure(ex) => System.err.println("Failed: " + ex) k8s.close + system.terminate().foreach { f => + System.exit(1) + } } def save(crd: CustomResourceDefinition) = { diff --git a/examples/src/main/scala/skuber/examples/deployment/DeploymentExamples.scala b/examples/src/main/scala/skuber/examples/deployment/DeploymentExamples.scala index ae5cfbe1..24fd1b89 100644 --- a/examples/src/main/scala/skuber/examples/deployment/DeploymentExamples.scala +++ b/examples/src/main/scala/skuber/examples/deployment/DeploymentExamples.scala @@ -37,8 +37,7 @@ object DeploymentExamples extends App { val deployment = deployNginx("1.7.9") - deployment onSuccess { - case depl => + deployment.foreach { depl => // Wait for initial deployment to complete before updating it. // NOTE: Kubernetes v1.1 Deployment status subresource does not seem to be reliably populated @@ -63,17 +62,18 @@ object DeploymentExamples extends App { updateNginx("1.9.1") onComplete { case scala.util.Success(_) => println("Update successfully requested - use'kubectl describe deployments' to monitor progress") - system.terminate() - System.exit(0) + system.terminate().foreach { f => + System.exit(0) + } case scala.util.Failure(ex) => ex.printStackTrace() - system.terminate() - System.exit(1) + system.terminate().map { f => + System.exit(1) + } } } - deployment onFailure { - case ex => + deployment.failed.foreach { ex => ex.printStackTrace() system.terminate() System.exit(1) diff --git a/examples/src/main/scala/skuber/examples/fluent/FluentExamples.scala b/examples/src/main/scala/skuber/examples/fluent/FluentExamples.scala index 18294c30..0b6f82d2 100644 --- a/examples/src/main/scala/skuber/examples/fluent/FluentExamples.scala +++ b/examples/src/main/scala/skuber/examples/fluent/FluentExamples.scala @@ -312,8 +312,13 @@ object FluentExamples extends App { c <- deployControllers } yield c - deployAll onFailure { case ex: K8SException => System.err.println("Request failed with status : " + ex.status) } + deployAll.failed.foreach { case ex: K8SException => System.err.println("Request failed with status : " + ex.status) } - deployAll andThen { case _ => k8s.close } + deployAll andThen { case _ => + k8s.close + system.terminate().foreach { f => + System.exit(0) + } + } } } \ No newline at end of file diff --git a/examples/src/main/scala/skuber/examples/guestbook/Guestbook.scala b/examples/src/main/scala/skuber/examples/guestbook/Guestbook.scala index 375a8847..f90a1733 100644 --- a/examples/src/main/scala/skuber/examples/guestbook/Guestbook.scala +++ b/examples/src/main/scala/skuber/examples/guestbook/Guestbook.scala @@ -21,20 +21,23 @@ object Guestbook extends App { result match { case GuestbookActor.DeployedSuccessfully => { System.out.println("\n*** Deployment of Guestbook application to Kubernetes completed successfully!") - System.out.println("Waiting 5 seconds to allow skuber client to close...") - Thread.sleep(5000) - System.exit(0) + sys.terminate().foreach { f => + System.exit(0) + } } case GuestbookActor.DeploymentFailed(ex) => { System.err.println("\n!!! Deployment of Guestbook application failed: " + ex) - System.out.println("Waiting 5 seconds to allow skuber client to close...") - Thread.sleep(5000) - System.exit(1) + sys.terminate().foreach { f => + System.exit(0) + } } } } - deploymentResult onFailure { - case ex => System.err.println("Unexpected error deploying Guestbook: " + ex) - System.exit(-1) + deploymentResult.failed.foreach { + case ex => + System.err.println("Unexpected error deploying Guestbook: " + ex) + sys.terminate().foreach { f => + System.exit(1) + } } } diff --git a/examples/src/main/scala/skuber/examples/guestbook/KubernetesProxyActor.scala b/examples/src/main/scala/skuber/examples/guestbook/KubernetesProxyActor.scala index 6724c02a..30f76bfb 100644 --- a/examples/src/main/scala/skuber/examples/guestbook/KubernetesProxyActor.scala +++ b/examples/src/main/scala/skuber/examples/guestbook/KubernetesProxyActor.scala @@ -126,6 +126,9 @@ class KubernetesProxyActor extends Actor with ActorLogging { case Close => { k8s.close System.out.println("Closed skuber client") + system.terminate().foreach { f => + System.exit(0) + } sender ! Closed } } diff --git a/examples/src/main/scala/skuber/examples/job/PrintPiJob.scala b/examples/src/main/scala/skuber/examples/job/PrintPiJob.scala index 402a4ba4..b282bd61 100644 --- a/examples/src/main/scala/skuber/examples/job/PrintPiJob.scala +++ b/examples/src/main/scala/skuber/examples/job/PrintPiJob.scala @@ -35,9 +35,15 @@ object PrintPiJob extends App { case Success(job) => System.out.println("Job successfully created on the cluster") k8s.close + system.terminate().foreach { f => + System.exit(0) + } case Failure(ex) => System.err.println("Failed to create job: " + ex) k8s.close + system.terminate().foreach { f => + System.exit(1) + } } // The job can be tracked using 'kubectl get pods' to get the name of the pod running the job (starts with "pi-") // and then when the pod terminates use "kubectl logs " to see the printed pi result diff --git a/examples/src/main/scala/skuber/examples/list/ListExamples.scala b/examples/src/main/scala/skuber/examples/list/ListExamples.scala index 606fa368..7abd159f 100644 --- a/examples/src/main/scala/skuber/examples/list/ListExamples.scala +++ b/examples/src/main/scala/skuber/examples/list/ListExamples.scala @@ -72,4 +72,7 @@ object ListExamples extends App { Await.ready(printAllPods, 30 seconds) k8s.close + system.terminate().foreach { f => + System.exit(0) + } } \ No newline at end of file diff --git a/examples/src/main/scala/skuber/examples/scale/ScaleExamples.scala b/examples/src/main/scala/skuber/examples/scale/ScaleExamples.scala index b7bd9c11..a72c64b2 100644 --- a/examples/src/main/scala/skuber/examples/scale/ScaleExamples.scala +++ b/examples/src/main/scala/skuber/examples/scale/ScaleExamples.scala @@ -73,7 +73,12 @@ object ScaleExamples extends App { "\n, message= " + k8sex.status.message.getOrElse("<>")) case ex: Exception => ex.printStackTrace } - autoScale onComplete { case _ => k8s.close } + autoScale onComplete { case _ => + k8s.close + system.terminate().foreach { f => + System.exit(0) + } + } } scaleNginxController } \ No newline at end of file diff --git a/examples/src/main/scala/skuber/examples/watch/WatchExamples.scala b/examples/src/main/scala/skuber/examples/watch/WatchExamples.scala index bfb25477..7223746c 100644 --- a/examples/src/main/scala/skuber/examples/watch/WatchExamples.scala +++ b/examples/src/main/scala/skuber/examples/watch/WatchExamples.scala @@ -56,6 +56,8 @@ object WatchExamples { Thread.sleep(30000) // watch for some time before closing the session k8s.close - system.terminate + system.terminate().foreach { f => + System.exit(0) + } } } \ No newline at end of file