-
Notifications
You must be signed in to change notification settings - Fork 12
Introduce ForceRerun parameter for Linux RCv2 #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,9 +165,18 @@ func uninstall(ctx *log.Context, h types.HandlerEnvironment, report *types.RunCo | |
| } | ||
|
|
||
| func enablePre(ctx *log.Context, h types.HandlerEnvironment, metadata types.RCMetadata, c types.Cmd) error { | ||
| extensionEvents := createExtensionEventManager(ctx, h) | ||
|
|
||
| // parse the extension handler settings | ||
| cfg, err1 := handlersettings.GetHandlerSettings(h.HandlerEnvironment.ConfigFolder, metadata.ExtName, metadata.SeqNum, ctx) | ||
| if err1 != nil { | ||
| errMessage := fmt.Sprintf("Failed to get configuration in enablePre: %v", err1) | ||
| extensionEvents.LogErrorEvent("enablePre", errMessage) | ||
| return errors.Wrap(err1, "failed to get configuration") | ||
| } | ||
| // 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, metadata.SeqNum, metadata.MostRecentSequence); err != nil { | ||
| if shouldExit, err := checkAndSaveSeqNum(ctx, metadata.SeqNum, metadata.MostRecentSequence, cfg.ForceRerun); err != nil { | ||
| return errors.Wrap(err, "failed to process sequence number") | ||
| } else if shouldExit { | ||
| ctx.Log("event", "exit", "message", "the script configuration has already been processed, will not run again") | ||
|
|
@@ -388,14 +397,14 @@ func getOutput(ctx *log.Context, stdoutFileName string, stderrFileName string) ( | |
| // checkAndSaveSeqNum checks if the given seqNum is already processed | ||
| // according to the specified seqNumFile and if so, returns true, | ||
| // otherwise saves the given seqNum into seqNumFile returns false. | ||
| func checkAndSaveSeqNum(ctx log.Logger, seq int, mrseqPath string) (shouldExit bool, _ error) { | ||
| func checkAndSaveSeqNum(ctx log.Logger, seq int, mrseqPath string, forceRerun bool) (shouldExit bool, _ error) { | ||
| ctx.Log("event", "comparing seqnum", "path", mrseqPath) | ||
| smaller, err := seqnum.IsSmallerThan(mrseqPath, seq) | ||
| isSavedSeqNumSmallerThanNewSeqNum, err := seqnum.IsSmallerThan(mrseqPath, seq) | ||
| if err != nil { | ||
| return false, errors.Wrap(err, "failed to check sequence number") | ||
| } | ||
|
|
||
| if !smaller { | ||
| if !forceRerun && !isSavedSeqNumSmallerThanNewSeqNum { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if the machine is rebooted? From this it appears we'll run the script every time RCV2 is executed. Why not just have CRP increment the seqNo?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. I did think about it earlier. Do you mean instead of making this "ForceRun" (thinking to rename it) flag change in Windows and Linux extensions, we could just increment sequence number in CRP ? Only thing is it may not work right away if for some reason the VM has much higher sequence number than what CRP has. Especially, Linux uses files to note down mrseq number and if user reuses a disk for example. That may be an edge case though.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think just incrementing it in CRP is a better solution. I'll close this PR |
||
| // stored sequence number is equals or greater than the current | ||
| // sequence number. | ||
| return true, nil | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should trace somewhere (and also put it in an extension event) that the force flag was used.