Skip to content

Commit

Permalink
Fixes #15670: Compilation error on 5.1 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceMacBuche committed Sep 10, 2019
1 parent a2d1c17 commit ed798cc
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ case class NameValueComparator(ldapAttr: String) extends TStringComparator {
final case class SubGroupChoice(id: NodeGroupId, name: String)

class SubGroupComparator(getGroups: () => IOResult[Seq[SubGroupChoice]]) extends TStringComparator {
class SubGroupComparator(getGroups: () => Box[Seq[SubGroupChoice]]) extends TStringComparator {
override val comparators = Equals :: Nil

override def buildFilter(attributeName:String,comparator:CriterionComparator,value:String) : Filter = comparator match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trait BootstrapChecks {

}

object BootraspLogger extends NamedZioLogger {
object BootstrapLogger extends NamedZioLogger {
override final def loggerName: String = "bootchecks"
}

Expand All @@ -76,7 +76,7 @@ class SequentialImmediateBootStrapChecks(_checkActions:BootstrapChecks*) extends
}

override val description = "Sequence of bootstrap checks"
val formater = new PeriodFormatterBuilder()
val formatter = new PeriodFormatterBuilder()
.appendMinutes()
.appendSuffix(" m")
.appendSeparator(" ")
Expand All @@ -90,14 +90,14 @@ class SequentialImmediateBootStrapChecks(_checkActions:BootstrapChecks*) extends
@throws(classOf[ UnavailableException ])
override def checks() : Unit = checkActions.zipWithIndex.foreach { case (check,i) =>
val start = System.currentTimeMillis
val msg = if(BootraspLogger.logEffect.isDebugEnabled) {
val msg = if(BootstrapLogger.logEffect.isDebugEnabled) {
s"[#${i}] ${check.description}"
} else {
s"${check.description}"
}
BootraspLogger.logEffect.info(msg)
BootstrapLogger.logEffect.info(msg)
check.checks
BootraspLogger.logEffect.debug(msg + s": OK in [${formater.print(new Duration(System.currentTimeMillis - start).toPeriod)}] ms")
BootstrapLogger.logEffect.debug(msg + s": OK in [${formatter.print(new Duration(System.currentTimeMillis - start).toPeriod)}] ms")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class CheckApiTokenAutorizationKind(
val name = e(A_NAME).orElse(e(A_API_UUID)).getOrElse("")
ldap.save(e) foldM (
err =>
BootraspLogger.logPure.error(s"Error when trying to add default '${DEFAULT_AUTHZ.name.toUpperCase}' authorization level to API token ${name}. Error was: ${err.fullMsg}")
BootstrapLogger.logPure.error(s"Error when trying to add default '${DEFAULT_AUTHZ.name.toUpperCase}' authorization level to API token ${name}. Error was: ${err.fullMsg}")
, ok =>
BootraspLogger.logPure.info(s"[migration] Adding default '${DEFAULT_AUTHZ.name.toUpperCase}' authorization level to API token '${name}'")
BootstrapLogger.logPure.info(s"[migration] Adding default '${DEFAULT_AUTHZ.name.toUpperCase}' authorization level to API token '${name}'")
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import com.unboundid.ldap.sdk.RDN
import java.io.File
import java.io.FileInputStream

import bootstrap.liftweb.BootraspLogger
import bootstrap.liftweb.BootstrapLogger

import com.normation.errors._
import zio._
Expand Down Expand Up @@ -98,7 +98,7 @@ object CheckCfengineSystemRuleTargets {
} else {
con.save(wanted, true, keepAttrs).flatMap { mod =>
ZIO.when(mod != LDIFNoopChangeRecord(wanted.dn)) {
BootraspLogger.logPure.info(s"Updating system configuration stored in entry '${wanted.dn.toString}': ${mod}")
BootstrapLogger.logPure.info(s"Updating system configuration stored in entry '${wanted.dn.toString}': ${mod}")
} *> mod.succeed
}
}
Expand All @@ -114,7 +114,7 @@ class CheckCfengineSystemRuleTargets(
override val description = "Check that system group / directive / rules for Rudder 4.2 are agent-specific"

def FAIL(msg:String) = {
BootraspLogger.logEffect.error(msg)
BootstrapLogger.logEffect.error(msg)
throw new UnavailableException(msg)
}

Expand Down Expand Up @@ -207,7 +207,7 @@ class CheckCfengineSystemRuleTargets(
val wanted = hasPolicyServer(uuid)
compare(con, wanted, entry)
case _ =>
BootraspLogger.logPure.warn(s"Ignoring entry '${entry.dn.toString}' when updating 'hasPolicyServer-*' system groups: name is not well formed") *>
BootstrapLogger.logPure.warn(s"Ignoring entry '${entry.dn.toString}' when updating 'hasPolicyServer-*' system groups: name is not well formed") *>
LDIFNoopChangeRecord(entry.dn).succeed
}
}
Expand All @@ -229,7 +229,7 @@ class CheckCfengineSystemRuleTargets(
case eb: EmptyBox =>
val e = eb ?~! "Error when updating system configuration for CFEngine based agent"
e.rootExceptionCause.foreach { ex =>
BootraspLogger.logEffect.debug("Exception was: ", ex)
BootstrapLogger.logEffect.debug("Exception was: ", ex)
}
FAIL(e.messageChain)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CheckConnections(
override def checks() : Unit = {

def FAIL(msg:String) = {
BootraspLogger.logEffect.error(msg)
BootstrapLogger.logEffect.error(msg)
throw new UnavailableException(msg)
}

Expand All @@ -78,7 +78,7 @@ class CheckConnections(
case e: Exception => FAIL("Can not open connection to PostgreSQL database server")
}

BootraspLogger.logEffect.info("LDAP and PostgreSQL connection are OK")
BootstrapLogger.logEffect.info("LDAP and PostgreSQL connection are OK")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CheckDIT(
override def checks() : Unit = {

def FAIL(msg:String) = {
BootraspLogger.logEffect.error(msg)
BootstrapLogger.logEffect.error(msg)
throw new UnavailableException(msg)
}

Expand Down Expand Up @@ -114,9 +114,9 @@ class CheckDIT(
con <- ldap
e <- ditEntries.accumulate { e =>
con.exists(e.dn).flatMap {
case true => BootraspLogger.logPure.debug(s"DIT entry '${e.dn}' already in LDAP directory, nothing to do")
case true => BootstrapLogger.logPure.debug(s"DIT entry '${e.dn}' already in LDAP directory, nothing to do")
case false =>
BootraspLogger.logPure.info(s"Missing DIT entry '${e.dn}', trying to add it") *> con.save(e)
BootstrapLogger.logPure.info(s"Missing DIT entry '${e.dn}', trying to add it") *> con.save(e)
}
}
} yield {
Expand Down Expand Up @@ -158,7 +158,7 @@ class CheckDIT(
}


BootraspLogger.logEffect.info("All the required DIT entries are present in the LDAP directory")
BootstrapLogger.logEffect.info("All the required DIT entries are present in the LDAP directory")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ class CheckInitUserTemplateLibrary(
}).toBox match {
case eb:EmptyBox =>
val e = eb ?~! s"Error when trying to check for root entry of the user template library"
BootraspLogger.logEffect.error(e.messageChain)
case Full(None) => BootraspLogger.logEffect.error("The root entry of the user template library was not found")
BootstrapLogger.logEffect.error(e.messageChain)
case Full(None) => BootstrapLogger.logEffect.error("The root entry of the user template library was not found")
case Full(Some(root)) => root.getAsGTime(A_INIT_DATETIME) match {
case Some(date) => BootraspLogger.logEffect.debug("The root user template library was initialized on %s".format(date.dateTime.toString("YYYY/MM/dd HH:mm")))
case Some(date) => BootstrapLogger.logEffect.debug("The root user template library was initialized on %s".format(date.dateTime.toString("YYYY/MM/dd HH:mm")))
case None =>
BootraspLogger.logEffect.info("The Active Technique library is not marked as being initialized: adding all policies from reference library...")
BootstrapLogger.logEffect.info("The Active Technique library is not marked as being initialized: adding all policies from reference library...")
copyReferenceLib() match {
case Full(x) =>
asyncDeploymentAgent ! AutomaticStartDeployment(ModificationId(uuidGen.newUuid), RudderEventActor)
BootraspLogger.logEffect.info("...done")
BootstrapLogger.logEffect.info("...done")
case eb:EmptyBox =>
val e = eb ?~! "Some error where encountered during the initialization of the user library"
val msg = e.messageChain.split("<-").mkString("\n ->")
BootraspLogger.logEffect.warn(msg)
e.rootExceptionCause.foreach(ex => BootraspLogger.logEffect.debug("cause was:", ex))
BootstrapLogger.logEffect.warn(msg)
e.rootExceptionCause.foreach(ex => BootstrapLogger.logEffect.debug("cause was:", ex))
// Even if complete reload failed, we need to trigger a policy deployment, as otherwise it will never be done
asyncDeploymentAgent ! AutomaticStartDeployment(ModificationId(uuidGen.newUuid), RudderEventActor)
}
Expand All @@ -106,9 +106,9 @@ class CheckInitUserTemplateLibrary(
ldap.flatMap(_.save(root)).toBox match {
case eb:EmptyBox =>
val e = eb ?~! "Error when updating information about the LDAP root entry of technique library."
BootraspLogger.logEffect.error(e.messageChain)
BootstrapLogger.logEffect.error(e.messageChain)
e.rootExceptionCause.foreach { ex =>
BootraspLogger.logEffect.error("Root exception was: ", ex)
BootstrapLogger.logEffect.error("Root exception was: ", ex)
}
case _ => // nothing to do
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ class CheckInitXmlExport(
tagMap <- itemArchiveManager.getFullArchiveTags
ident <- personIdentService.getPersonIdentOrDefault(RudderEventActor.name)
res <- if(tagMap.isEmpty) {
BootraspLogger.info("No full archive of configuration-repository items seems to have been done, initialising the system with one") *>
BootstrapLogger.info("No full archive of configuration-repository items seems to have been done, initialising the system with one") *>
itemArchiveManager.exportAll(ident, ModificationId(uuidGen.newUuid), RudderEventActor, Some("Initialising configuration-repository sub-system"), false)
} else {
BootraspLogger.trace("At least a full archive of configuration items done, no need for further initialisation") *>
BootstrapLogger.trace("At least a full archive of configuration items done, no need for further initialisation") *>
UIO.unit
}

Expand All @@ -84,13 +84,13 @@ class CheckInitXmlExport(
}).toBox match {
case eb:EmptyBox =>
val fail = eb ?~! "Error when trying to initialise to configuration-repository sub-system with a first full archive"
BootraspLogger.logEffect.error(fail.messageChain)
BootstrapLogger.logEffect.error(fail.messageChain)
fail.rootExceptionCause.foreach { t =>
BootraspLogger.logEffect.error("Root exception was:", t)
BootstrapLogger.logEffect.error("Root exception was:", t)
}

case Full(_) =>
BootraspLogger.logEffect.info("First full archive of configuration-repository items done")
BootstrapLogger.logEffect.info("First full archive of configuration-repository items done")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
package bootstrap.liftweb.checks

import bootstrap.liftweb.BootstrapChecks
import com.normation.rudder.domain.logger.ApplicationLogger
import bootstrap.liftweb.BootstrapLogger
import javax.servlet.UnavailableException
import net.liftweb.common._

import scala.util.control.NonFatal

Expand All @@ -60,7 +59,7 @@ class CheckNashornWarning() extends BootstrapChecks {
val javaVersionElements = System.getProperty("java.version").split('.')
val major = Integer.parseInt(javaVersionElements(0))
if(major >= 11) {
ApplicationLogger.warn(s"Set '${nashornProp}=${nashornVal}' to avoid redundant deprecation warnings")
BootstrapLogger.logEffect.warn(s"Set '${nashornProp}=${nashornVal}' to avoid redundant deprecation warnings")
System.getProperty(nashornProp) match {
case null => System.setProperty(nashornProp, nashornVal)
case value =>
Expand All @@ -75,7 +74,7 @@ class CheckNashornWarning() extends BootstrapChecks {
}
} catch { // in case of error, don't touch anything
case NonFatal(ex) => // do nothing
logger.warn(s"Unable to remove NashHorn deprecation warning, exception was: ${ex.getMessage}")
BootstrapLogger.logEffect.warn(s"Unable to remove NashHorn deprecation warning, exception was: ${ex.getMessage}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,27 +163,27 @@ class CheckNcfTechniqueUpdate(
techniques
} ) match {
case Right(techniques) =>
BootraspLogger.logEffect.info(s"All ncf techniques were updated, ${techniques.size} were migrated")
BootstrapLogger.logEffect.info(s"All ncf techniques were updated, ${techniques.size} were migrated")
case Left(NcfApiAuthFailed(msg,e)) =>
BootraspLogger.logEffect.warn(s"Could not authenticate in ncf API, maybe it was not initialized yet, retrying in 5 seconds, details ${msg}")
BootstrapLogger.logEffect.warn(s"Could not authenticate in ncf API, maybe it was not initialized yet, retrying in 5 seconds, details ${msg}")
ZioRuntime.internal.unsafeRunAsync(Task.effect(updateNcfTechniques).delay(5.seconds))( _ => ())
case Left(FlagFileError(_,_)) =>
BootraspLogger.logEffect.warn(s"All ncf techniques were updated, but we could not delete flag file ${ncfTechniqueUpdateFlag}, please delete it manually")
BootstrapLogger.logEffect.warn(s"All ncf techniques were updated, but we could not delete flag file ${ncfTechniqueUpdateFlag}, please delete it manually")
case Left(e : NcfTechniqueUpgradeError) =>
BootraspLogger.logEffect.error(s"An error occured while updating ncf techniques: ${e.msg}")
BootstrapLogger.logEffect.error(s"An error occured while updating ncf techniques: ${e.msg}")
}
}

try {
if (ncfTechniqueUpdateFlag.exists) {
ZioRuntime.internal.unsafeRunAsync(Task.effect(updateNcfTechniques).delay(10.seconds))( _ => ())
} else {
BootraspLogger.logEffect.info(s"Flag file '${ncfTechniqueUpdateFlag}' does not exist, do not regenerate ncf Techniques")
BootstrapLogger.logEffect.info(s"Flag file '${ncfTechniqueUpdateFlag}' does not exist, do not regenerate ncf Techniques")
}
} catch {
// Exception while checking the flag existence
case e : Exception =>
BootraspLogger.logEffect.error(s"An error occurred while accessing flag file '${ncfTechniqueUpdateFlag}', cause is: ${e.getMessage}")
BootstrapLogger.logEffect.error(s"An error occurred while accessing flag file '${ncfTechniqueUpdateFlag}', cause is: ${e.getMessage}")
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ class CheckRootRuleCategoryExport(
exists <- IOResult.effect(categoryDirectory.exists).chainError(s"Error when checking '${categoryDirectory}' directory existence")
ident <- personIdentService.getPersonIdentOrDefault(RudderEventActor.name)
res <- if(!exists) {
BootraspLogger.info(s"Directory '${categoryDirectory.getAbsolutePath()}' is missing, initialize it by exporting Rules") *>
BootstrapLogger.info(s"Directory '${categoryDirectory.getAbsolutePath()}' is missing, initialize it by exporting Rules") *>
itemArchiveManager.exportRules(ident, ModificationId(uuidGen.newUuid), RudderEventActor, Some("Initialising configuration-repository Rule categories directory"), false)
} else {
BootraspLogger.trace(s"Directory '${categoryDirectory.getAbsolutePath()}' exists") *>
BootstrapLogger.trace(s"Directory '${categoryDirectory.getAbsolutePath()}' exists") *>
UIO.unit
}
} yield {
}).toBox match {
case eb:EmptyBox =>
val fail = eb ?~! "Initialising configuration-repository Rule categories directory with a Rule archive"
BootraspLogger.logEffect.error(fail.msg)
BootstrapLogger.logEffect.error(fail.msg)
fail.rootExceptionCause.foreach { t =>
BootraspLogger.logEffect.error("Root exception was:", t)
BootstrapLogger.logEffect.error("Root exception was:", t)
}

case Full(_) =>
BootraspLogger.logEffect.info(s"Creating directory '${categoryDirectory.getAbsolutePath()}' exists, done")
BootstrapLogger.logEffect.info(s"Creating directory '${categoryDirectory.getAbsolutePath()}' exists, done")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ class CheckSystemGroups(

val updatedGroup = group.copy(isDynamic = true, query = Some(query))
rwRepos.updateSystemGroup(updatedGroup, modId, RudderEventActor, Some(message)).toBox
BootraspLogger.logEffect.info(message)
BootstrapLogger.logEffect.info(message)

}
}
case eb: EmptyBox =>
val fail = eb ?~! "Could not migrate system groups"
BootraspLogger.logEffect.error(fail.messageChain)
BootstrapLogger.logEffect.error(fail.messageChain)
}
}
}
Expand Down

0 comments on commit ed798cc

Please sign in to comment.