Skip to content
Snippets Groups Projects

Resolve "Internal Changes representation is not working as expected"

2 files
+ 21
8
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 14
8
@@ -46,6 +46,13 @@ func NewChange(device uuid.UUID, currentState ygot.GoStruct, change ygot.GoStruc
@@ -46,6 +46,13 @@ func NewChange(device uuid.UUID, currentState ygot.GoStruct, change ygot.GoStruc
c.stateOut = stateOut
c.stateOut = stateOut
c.requestState = requestState
c.requestState = requestState
c.errChan = errChan
c.errChan = errChan
 
 
// recieve the errors from a Change and log them
 
go func() {
 
errChan := <-c.errChan
 
log.Error(errChan)
 
}()
 
return c
return c
}
}
@@ -116,6 +123,9 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, <
@@ -116,6 +123,9 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, <
stateIn := make(chan ppb.Change_State)
stateIn := make(chan ppb.Change_State)
stateOut := make(chan ppb.Change_State)
stateOut := make(chan ppb.Change_State)
stateRequest := make(chan bool)
stateRequest := make(chan bool)
 
//A Goroutine, which is called from
 
//principalNetworkDomain.ChangeOND is now the reciever
 
//for errorChan
errChan := make(chan error)
errChan := make(chan error)
// create ticker and make it wait for 1 week
// create ticker and make it wait for 1 week
// workaround for delayed ticker start and ugly housekeeping
// workaround for delayed ticker start and ugly housekeeping
@@ -126,17 +136,13 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, <
@@ -126,17 +136,13 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, <
for {
for {
select {
select {
case <-ticker.C:
case <-ticker.C:
//TODO: errorChan seems problematic here, since there is no real
// reciever available. therefore currently there will be
// only simple logging.
err := ch.callback(ch.intendedState, ch.previousState)
err := ch.callback(ch.intendedState, ch.previousState)
if err != nil {
if err != nil {
state = ppb.Change_INCONSISTENT
state = ppb.Change_INCONSISTENT
log.Errorf("change %v timed out", ch.cuid)
log.Errorf("change %v timed out", ch.cuid)
//errChan <- err
errChan <- err
}
}
log.Errorf("change %v timed out", ch.cuid)
errChan <- fmt.Errorf("change %v timed out", ch.cuid)
//errChan <- fmt.Errorf("change %v timed out", ch.cuid)
case s := <-stateIn:
case s := <-stateIn:
switch s {
switch s {
case ppb.Change_COMMITTED:
case ppb.Change_COMMITTED:
@@ -151,8 +157,8 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, <
@@ -151,8 +157,8 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, <
state = ppb.Change_COMMITTED
state = ppb.Change_COMMITTED
stateOut <- state
stateOut <- state
case ppb.Change_CONFIRMED:
case ppb.Change_CONFIRMED:
// stop the timer, since the changes are now confirmed and a
// The change has been confirmed and the timer is stopped,
// rollback is not needed anymore
// since a rollback is not necessary anymore.
ticker.Stop()
ticker.Stop()
state = ppb.Change_CONFIRMED
state = ppb.Change_CONFIRMED
stateOut <- state
stateOut <- state
Loading