Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Operator on Fabric8 actions#994

Merged
andreaTP merged 105 commits into
masterfrom
fabric8-actions-next
Mar 23, 2021
Merged

Operator on Fabric8 actions#994
andreaTP merged 105 commits into
masterfrom
fabric8-actions-next

Conversation

@andreaTP

@andreaTP andreaTP commented Mar 3, 2021

Copy link
Copy Markdown
Contributor

Opening a Draft PR to monitor the progress and to share.

Current status:

  • tests are passing
  • IT tests are passing
  • all the follow-up PRs (helm / release / enterprise operator) have been drafted

TODO:

  • @RayRoestenburg review
  • self-review
  • more testing on live applications
  • fix the headers

@andreaTP andreaTP requested a review from RayRoestenburg March 3, 2021 19:23
val thisService =
services.inNamespace(service.getMetadata.getNamespace).withName(service.getMetadata.getName)
val ser = thisService.get()
Option(ser) match {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor, use foreach?

ownerReferences: List[OwnerReference]): Seq[Action] =
app.spec.streamlets
.map(streamlet => streamlet.descriptor.runtime.name)
.map(streamlet => streamlet.descriptor.runtime)

@RayRoestenburg RayRoestenburg Mar 22, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why was this change needed? (just does not seem fabric8 related)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's related to the usage of the Fabric8 CR


private val log = LoggerFactory.getLogger(TopicActions.getClass)

// TOOD: again Blueprint and CR overlapping

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// TOOD: again Blueprint and CR overlapping
// TODO: again Blueprint and CR overlapping

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

used in the Runner

Action.createOrReplace(res)
}

def deleteResource(name: String, namespace: String)(implicit ct: ClassTag[Deployment]): Action =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in the Runner

.inNamespace(deployment.getMetadata.getNamespace)
.withName(deployment.getMetadata.getName)
.patch(deployment)
Action.log.warn("Akka deployment patched!")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why warn? maybe debug leftover.

.withName(deployment.getMetadata.getName)
.patch(deployment)
Action.log.warn("Akka deployment patched!")
Action.noop

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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: _*)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this

Map("cpu" -> resourceConstraints.cpuRequests, "memory" -> resourceConstraints.memoryRequests)
}

lazy val resourceRequirements =

@RayRoestenburg RayRoestenburg Mar 22, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
lazy val resourceRequirements =
lazy val resourceRequirementsFromDefaults =

containerConfig <- pod.containers.get(PodsConfig.CloudflowContainerName)
resources <- containerConfig.resources
} yield {
resources

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you miss the defaults here.

var resReqManagerBuilder = new ResourceRequirementsBuilder()

val defaultRequests =
((resourceDefaults.cpuRequest match {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

map?

case Some(req) => Map("cpu" -> req)
case _ => Map.empty[String, Quantity]
}) ++
(resourceDefaults.memoryRequest match {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

map?

case Some(secret) =>
createOrReplaceResource(resource(deployment, newApp, secret))
case None =>
// TODO: this is an un-recoverable error -> errorAction instead? @Ray

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's not change this now.

.build()
}

val resources = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

updatedExecutor
}

// TODO: changed the original logic that seem to be incorrect

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warn?

case _ => Nil // app could not be found, do nothing.
}

// TODO: duplicated fixme

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?


import scala.jdk.CollectionConverters._

class CloudflowApplicationSpec

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AppCrSpec?

libraryDependencies ++= Seq(
Compile.typesafeConfig,
Compile.sprayJson,
// TODO: check if Avro and ScalaPB can stay in a separate module

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@RayRoestenburg RayRoestenburg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM in general, some minor comments, and the fix for pod config resource requirements.

@andreaTP andreaTP merged commit 6394426 into master Mar 23, 2021
@andreaTP andreaTP deleted the fabric8-actions-next branch March 23, 2021 12:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants