Repository navigation
🍀 Proposal: Support for rollback in case of error in intermediate steps #1173
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
What Would You Like to Add? Why Is This Needed?
devstream/internal/pkg/upgrade/upgrade.go
Lines 133 to 165 in ed469dc
| // applyUpgrade use os.Rename replace old version dtm with the latest one | |
| // (1) rename current dtm file name to `dtm-bak`. | |
| // (2) rename `dtm-tmp` to current dtm file name. | |
| // (3) grant new dtm file execute permission. | |
| // (4) remove `dtm-bak` binary file. | |
| // TODO(hxcGit): Support for rollback in case of error in intermediate steps | |
| func applyUpgrade(workDir string) error { | |
| dtmFilePath := filepath.Join(workDir, dtmFileName) | |
| dtmBakFilePath := filepath.Join(workDir, dtmBakFileName) | |
| dtmTmpFilePath := filepath.Join(workDir, dtmTmpFileName) | |
| if err := os.Rename(dtmFilePath, dtmBakFilePath); err != nil { | |
| return err | |
| } | |
| log.Debugf("Dtm upgrade: rename %s to dtm-bak successfully.", dtmFileName) | |
| if err := os.Rename(dtmTmpFilePath, dtmFilePath); err != nil { | |
| return err | |
| } | |
| log.Debugf("Dtm upgrade: rename dtm-tmp to %s successfully.", dtmFileName) | |
| if err := os.Chmod(dtmFilePath, 0755); err != nil { | |
| return err | |
| } | |
| log.Debugf("Dtm upgrade: grant %s execute permission successfully.", dtmFileName) | |
| if err := os.Remove(dtmBakFilePath); err != nil { | |
| return err | |
| } | |
| log.Debug("Dtm upgrade: remove dtm-bak successfully.") | |
| return nil | |
| } |
Design
Anything else
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Activity
0zyt commentedon Oct 16, 2022
I want to do it
aFlyBird0 commentedon Oct 16, 2022
Do as much as you like!
0zyt commentedon Oct 16, 2022
@xavier-hou Hi,Do you think it is necessary to consider being interrupted by a signal such as CTRL+C?
0zyt commentedon Oct 16, 2022
I had a discussion with @aFlyBird0 about writing test for this feature because I couldn't find a better way to test this feature.
The codes above from @aFlyBird0 ,
I think this is a practical and effective way to test, but it doesn't look elegant at first glance.
The other way is to keep it simple and elegant and not change the function signature and to verify it locally by me or other members, but this is not a transparent way to test an open source project and may not be good enough.
So I would like to hear your thoughts.
@xavier-hou @Danielhui @steinliber @IronCore864
I will PR after getting a better way.
IronCore864 commentedon Oct 17, 2022
I think this is a way to test it, but as you said, it changes the signature of the func, which might be a bit confusing to read.
I personally suggest a better way to test it. What do you guys think?