Fix issue where registration file is not removed when registration is cleared
cr:
@@ -192,14 +192,19 @@ func registerManagedInstance(log logger.T) (managedInstanceID string, err error)
// clearRegistration clears any existing registration data
func clearRegistration(log logger.T) (exitCode int) {
err := registration.UpdateServerInfo("", "", "", "")
- if err == nil {
- log.Info("Registration information has been removed from the instance.")
- return 0
- }
+ if err != nil {
log.Errorf("error clearing the instance registration information. %v\nTry running as sudo/administrator.", err)
return 1
}
+ // Remove the registration file
+ os.Remove(registrationFile)
+
+ log.Info("Registration information has been removed from the instance.")
+ return 0
+
+}
+
// askForConfirmation will ask user for confirmation if they want to proceed.
func askForConfirmation() (result bool, err error) {
var response string
