fix: clean up stale extracted files on deploy
A failed deploy could leave a non-empty extraction directory behind, such as the scheduler-k3s `kustomization` directory, which caused every following deploy to fail. Leftovers from previous deploys are now fully removed, removing a directory such as `config/kustomize` from the repository now removes the stored copy, and openresty includes now persist across restarts.
This commit is contained in:
12 files changed
+315
-41
No files matched your search
@@ -153,8 +153,8 @@ func CorePostDeploy(input CorePostDeployInput) error {
|
||||
if err := os.Rename(processSpecificPath, existingPath); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if DirectoryExists(fmt.Sprintf("%s.missing", processSpecificPath)) {
|
||||
if err := os.RemoveAll(fmt.Sprintf("%s.missing", processSpecificPath)); err != nil {
|
||||
} else if FileExists(fmt.Sprintf("%s.missing", processSpecificPath)) {
|
||||
if err := os.Remove(fmt.Sprintf("%s.missing", processSpecificPath)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ func CorePostExtract(input CorePostExtractInput) error {
|
||||
return err
|
||||
}
|
||||
for _, f := range files {
|
||||
if err := os.Remove(f); err != nil {
|
||||
if err := os.RemoveAll(f); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -371,13 +371,18 @@ func CorePostExtract(input CorePostExtractInput) error {
|
||||
}
|
||||
} else {
|
||||
if toExtract.IsDirectory {
|
||||
|
||||
if err := CopyDirFromImage(input.AppName, sourceImage, imageSourcePath, processSpecificDestination); err != nil {
|
||||
return TouchFile(missingDestination)
|
||||
if err := TouchFile(missingDestination); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if err := CopyFromImage(input.AppName, sourceImage, imageSourcePath, processSpecificDestination); err != nil {
|
||||
return TouchFile(missingDestination)
|
||||
if err := TouchFile(missingDestination); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user