Skip to content
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

Add code to remove legacy validation_marker file that created by etcd-custom-image on the filesystem #38

Merged
merged 3 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (a *Application) Start() error {
if err = a.startEtcd(); err != nil {
return err
}
// Delete validation marker after etcd starts successfully
// Delete exit code file after etcd starts successfully
if err = bootstrap.CleanupExitCode(types.DefaultExitCodeFilePath); err != nil {
a.logger.Warn("failed to clean-up last captured exit code", zap.Error(err))
}
Expand Down
6 changes: 6 additions & 0 deletions internal/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ func (i *initializer) tryGetEtcdConfig(ctx context.Context, maxRetries int, inte

func determineValidationMode(exitCodeFilePath string, logger *zap.Logger) brclient.ValidationType {
var err error

// remove legacy validation_marker file created by etcd-custom-image
if err = CleanupExitCode(types.ValidationMarkerFilePath); err != nil {
logger.Error("error in removing validation_marker file", zap.String("validationMarkerFilePath", types.ValidationMarkerFilePath), zap.Error(err))
}

if _, err = os.Stat(exitCodeFilePath); err == nil {
data, err := os.ReadFile(exitCodeFilePath) // #nosec G304 -- only path passed is `DefaultExitCodeFilePath`, no user input is used.
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
DefaultBackupRestoreHostPort = ":8080"
// DefaultExitCodeFilePath defines the default file path for the file that stores the exit code of the previous run
DefaultExitCodeFilePath = "/var/etcd/data/exit_code"
// ValidationMarkerFilePath defines the file path to the legacy file that was used to record exit code of the previous run
ValidationMarkerFilePath = "/var/etcd/data/validation_marker"
// DefaultLogLevel defines the default log level for any zap loggers created
DefaultLogLevel = zapcore.InfoLevel
)