Operator on Fabric8 actions#994
Conversation
| val thisService = | ||
| services.inNamespace(service.getMetadata.getNamespace).withName(service.getMetadata.getName) | ||
| val ser = thisService.get() | ||
| Option(ser) match { |
There was a problem hiding this comment.
Maybe do Option(thisService.get()) so no one can make the mistake to use ser (super minor)
| val metadataName = newEventName(podName, app.spec.appId) | ||
|
|
||
| // the object reference fieldPath is irrelevant for application events. | ||
| fieldPath match { |
There was a problem hiding this comment.
minor, use foreach?
| ownerReferences: List[OwnerReference]): Seq[Action] = | ||
| app.spec.streamlets | ||
| .map(streamlet => streamlet.descriptor.runtime.name) | ||
| .map(streamlet => streamlet.descriptor.runtime) |
There was a problem hiding this comment.
Why was this change needed? (just does not seem fabric8 related)
There was a problem hiding this comment.
it's related to the usage of the Fabric8 CR
|
|
||
| private val log = LoggerFactory.getLogger(TopicActions.getClass) | ||
|
|
||
| // TOOD: again Blueprint and CR overlapping |
There was a problem hiding this comment.
| // TOOD: again Blueprint and CR overlapping | |
| // TODO: again Blueprint and CR overlapping |
There was a problem hiding this comment.
I think we know what to do about this, so maybe remove the comment.
|
|
||
| val runtime = Runtime | ||
|
|
||
| def createOrReplaceResource(res: Deployment)(implicit ct: ClassTag[Deployment]): Action = { |
There was a problem hiding this comment.
used in the Runner
| Action.createOrReplace(res) | ||
| } | ||
|
|
||
| def deleteResource(name: String, namespace: String)(implicit ct: ClassTag[Deployment]): Action = |
| .inNamespace(deployment.getMetadata.getNamespace) | ||
| .withName(deployment.getMetadata.getName) | ||
| .patch(deployment) | ||
| Action.log.warn("Akka deployment patched!") |
There was a problem hiding this comment.
Why warn? maybe debug leftover.
| .withName(deployment.getMetadata.getName) | ||
| .patch(deployment) | ||
| Action.log.warn("Akka deployment patched!") | ||
| Action.noop |
There was a problem hiding this comment.
Why return noop? you could return this?
| app: App.Cr, | ||
| configSecret: Secret, | ||
| updateLabels: Map[String, String] = Map()): Deployment = { | ||
| // The runtimeConfig is already applied in the runner config secret, so it can be safely ignored. |
There was a problem hiding this comment.
Which runtimeConfig? maybe outdated comment, remove?
| // Pass this argument to the entry point script. The top level entry point will be a | ||
| // cloudflow-entrypoint.sh which will route to the appropriate entry point based on the | ||
| // arguments passed to it | ||
| val args = List("akka") |
There was a problem hiding this comment.
I think this can be removed, the entrypoint is now already akka specific, so please remove comment and these args.
| .withResources(resourceRequirements) | ||
| .withImage(deployment.image) | ||
| .withEnv(environmentVariables: _*) | ||
| .withArgs(args: _*) |
| Map("cpu" -> resourceConstraints.cpuRequests, "memory" -> resourceConstraints.memoryRequests) | ||
| } | ||
|
|
||
| lazy val resourceRequirements = |
There was a problem hiding this comment.
| lazy val resourceRequirements = | |
| lazy val resourceRequirementsFromDefaults = |
| containerConfig <- pod.containers.get(PodsConfig.CloudflowContainerName) | ||
| resources <- containerConfig.resources | ||
| } yield { | ||
| resources |
There was a problem hiding this comment.
you miss the defaults here.
| var resReqManagerBuilder = new ResourceRequirementsBuilder() | ||
|
|
||
| val defaultRequests = | ||
| ((resourceDefaults.cpuRequest match { |
| case Some(req) => Map("cpu" -> req) | ||
| case _ => Map.empty[String, Quantity] | ||
| }) ++ | ||
| (resourceDefaults.memoryRequest match { |
| case Some(secret) => | ||
| createOrReplaceResource(resource(deployment, newApp, secret)) | ||
| case None => | ||
| // TODO: this is an un-recoverable error -> errorAction instead? @Ray |
There was a problem hiding this comment.
Let's not change this now.
| .build() | ||
| } | ||
|
|
||
| val resources = { |
| updatedExecutor | ||
| } | ||
|
|
||
| // TODO: changed the original logic that seem to be incorrect |
There was a problem hiding this comment.
We discussed, can remove comment.
| Option(typedSelector.fromServer().get()) match { | ||
| case Some(curr) => | ||
| // NOTE: the typed API for patching doesn't work ... | ||
| Action.log.warn(s"Patching Spark Cr ${cr.name} in ${cr.namespace}") |
| case _ => Nil // app could not be found, do nothing. | ||
| } | ||
|
|
||
| // TODO: duplicated fixme |
|
|
||
| import scala.jdk.CollectionConverters._ | ||
|
|
||
| class CloudflowApplicationSpec |
| libraryDependencies ++= Seq( | ||
| Compile.typesafeConfig, | ||
| Compile.sprayJson, | ||
| // TODO: check if Avro and ScalaPB can stay in a separate module |
RayRoestenburg
left a comment
There was a problem hiding this comment.
LGTM in general, some minor comments, and the fix for pod config resource requirements.
Opening a Draft PR to monitor the progress and to share.
Current status:
TODO: