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

Unmarshalling fails for Scale object if 'replicas' is set to 0 #289

Closed
mariozel opened this issue Sep 13, 2019 · 1 comment
Closed

Unmarshalling fails for Scale object if 'replicas' is set to 0 #289

mariozel opened this issue Sep 13, 2019 · 1 comment

Comments

@mariozel
Copy link

mariozel commented Sep 13, 2019

Hey there.
I have some code that looks like this:

def scaleDeployment(namespace: String, name: String, newScale: Int): Future[Scale] = {
  skuber.usingNamespace(namespace).getScale[Deployment](name).flatMap { scale =>
    val downscale = scale.withSpecReplicas(newScale)
    skuber.usingNamespace(namespace).updateScale[Deployment](name, downscale)
  }
}

calling this method with non-zero values in newScale works just fine. However, if I need to scale the deployment to 0 then Unmarshalling fails with the following error:

e => JsError(List((/spec/replicas,List(JsonValidationError(List(error.path.missing),WrappedArray())))))
akka.http.scaladsl.server.RejectionError
	at skuber.json.PlayJsonSupportForAkkaHttp.$anonfun$unmarshaller$1(PlayJsonSupportForAkkaHttp.scala:79)
	at play.api.libs.json.JsError.recoverTotal(JsResult.scala:91)
	at skuber.json.PlayJsonSupportForAkkaHttp.read$1(PlayJsonSupportForAkkaHttp.scala:76)
	at skuber.json.PlayJsonSupportForAkkaHttp.$anonfun$unmarshaller$2(PlayJsonSupportForAkkaHttp.scala:83)
	at akka.http.scaladsl.util.FastFuture$.$anonfun$map$1(FastFuture.scala:23)
	at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)
	at akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:45)
	at akka.http.scaladsl.util.FastFuture$.map$extension(FastFuture.scala:23)
	at akka.http.scaladsl.unmarshalling.Unmarshaller.$anonfun$map$3(Unmarshaller.scala:26)
	at akka.http.scaladsl.unmarshalling.Unmarshaller.$anonfun$transform$3(Unmarshaller.scala:23)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$$anon$1.apply(Unmarshaller.scala:58)
	at akka.http.scaladsl.unmarshalling.LowerPriorityGenericUnmarshallers.$anonfun$messageUnmarshallerFromEntityUnmarshaller$3(GenericUnmarshallers.scala:25)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$$anon$1.apply(Unmarshaller.scala:58)
	at akka.http.scaladsl.unmarshalling.Unmarshal.to(Unmarshal.scala:25)
	at skuber.api.client.impl.KubernetesClientImpl.$anonfun$toKubernetesResponse$1(KubernetesClientImpl.scala:651)
	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
	at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
	at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
	at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
	at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
	at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

It seems that k8s is omitting the 0 value in replicas which invalidates the Json object for Skuber.

Is this a known issue (perhaps related to #48 )? Is there a workaround?

Thanks in advance
M

@mzeljkovic
Copy link
Contributor

PR up with a proposed fix.

Apologies for using a different account. (same user as the person logging the issue)

doriordan pushed a commit that referenced this issue Dec 14, 2019
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

No branches or pull requests

3 participants