Project

General

Profile

Actions

Architecture #16603

closed

Clarify code of rollback events parsing

Added by Vincent MEMBRÉ about 4 years ago. Updated almost 4 years ago.

Status:
Released
Priority:
N/A
Category:
Architecture - Code maintenance
Target version:
Effort required:
Name check:
To do
Fix check:
Checked
Regression:

Description

Something is fishy in parsing of rollback events

  def getRollbackDetails(xml:NodeSeq) : Box[RollbackInfo] = {
  def getEvents(xml:NodeSeq)= {
    for{
      event     <- xml
      eventlogs <- event.child
      entry     <- eventlogs \ "rollbackedEvent" 
      id        <- (entry \ "id").headOption.map(_.text.toInt) ?~! ("Entry type is not a 'rollback': %s".format(entry))
      evtType   <-(entry \ "type").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
      author    <-(entry \ "author").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
      date      <-(entry \ "date").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
    } yield {
      RollbackedEvent(id,date,evtType,author)
    }
  }

 val rollbackInfo =  for{
      event        <- xml
      eventlogs    <- event.child
      entry        <- (eventlogs \ "main").headOption
      id           <- (entry \ "id").headOption.map(_.text.toInt) ?~! ("Entry type is not a 'rollback': %s".format(entry))
      evtType      <- (entry \ "type").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
      author       <- (entry \ "author").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
      date         <- (entry \ "date").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
      rollbackType <- (entry \ "rollbackType").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
    } yield {
      val target = RollbackedEvent(id,date,evtType,author)
      RollbackInfo(target,rollbackType,getEvents(xml))
    }
   rollbackInfo.headOption
  }

rollbackinfo is a Seq, that we take head, andwe implictly convert to box, it should directlybe a box

getEvents should be a Box[Seq[RollbackedEvents]]

moreover, identation is broken, and error message useless

Actions #1

Updated by Vincent MEMBRÉ about 4 years ago

  • Status changed from New to In progress
  • Assignee set to Vincent MEMBRÉ
Actions #2

Updated by Vincent MEMBRÉ about 4 years ago

  • Status changed from In progress to Pending technical review
  • Assignee changed from Vincent MEMBRÉ to François ARMAND
  • Pull Request set to https://github.com/Normation/rudder/pull/2734
Actions #3

Updated by Vincent MEMBRÉ about 4 years ago

  • Status changed from Pending technical review to Pending release
Actions #4

Updated by Vincent MEMBRÉ almost 4 years ago

  • Status changed from Pending release to Released

This bug has been fixed in Rudder 6.1.0~beta1 which was released today.

Actions #5

Updated by François ARMAND almost 4 years ago

  • Fix check changed from To do to Checked
Actions

Also available in: Atom PDF