in main/cmds.go [126:148]
func enablePre(ctx *log.Context, hEnv HandlerEnvironment, seqNum int) error {
// exit if this sequence number (a snapshot of the configuration) is already
// processed. if not, save this sequence number before proceeding.
if shouldExit, err := checkAndSaveSeqNum(ctx, seqNum, mostRecentSequence); err != nil {
return errors.Wrap(err, "failed to process seqnum")
} else if shouldExit {
ctx.Log("event", "exit", "message", "this script configuration is already processed, will not run again")
if IsExtensionStillRunning(pidFilePath) {
ctx.Log("event", "check status", "message", "Previous runcommand process is still running")
} else {
statusType, err := readStatus(ctx, hEnv, seqNum)
if err == nil && statusType == StatusTransitioning {
// Make sure status is not stuck in transitioning state when previous extension process is not running
// If VM was restarted or process didn't finish its possible that seqNum ihas been marked as processed
// but last status file is still is "transitioning"
ctx.Log("event", "check status", "message", "transitioning status detected but no process to handle it - set to success status")
reportStatus(ctx, hEnv, seqNum, StatusSuccess, cmd{enable, "Enable", true, enablePre, 3}, "Last script execution didn't finish.")
}
}
os.Exit(0)
}
return nil
}