Compare commits

...

4 Commits

Author SHA1 Message Date
Chao Geng 0a80051229 EE-2167 update message of upgrade notification (#6657) 2022-03-18 18:51:51 +08:00
chaogeng77977 e4ee6d548e EE-2167 fix(upgrade) remove code not related upgrade 2022-03-15 14:25:27 +08:00
chaogeng77977 8a61d9fa37 EE-2167 feat(upgrade) create new release branch 2022-03-15 14:05:46 +08:00
Chao Geng a813388920 fix(upgrade): Migrate 1.24 users to 2.13 EE-2167 (#6458)
* EE-2167 Migrate 1.24 users to 2.13
Changes:
1. When user login, popup a notification. This notification shows only once when user login.
2. Backup database when container start. Its name is portainer-1-24-backup.db.

* EE-2167 fix typo

* EE-2167 remove pre-commit

* EE-2167 backup db everytime when container start

* EE-2167 use default value 'null' of bootbox when showing upgrade notification

* move logic to backup1_24db

* added the version checking

* EE-2167 fix typo
2022-03-01 20:48:51 +08:00
6 changed files with 68 additions and 4 deletions
+39 -1
View File
@@ -1,7 +1,9 @@
package bolt
import (
"io"
"log"
"os"
"path"
"time"
@@ -11,7 +13,7 @@ import (
"github.com/portainer/portainer/api/bolt/tunnelserver"
"github.com/boltdb/bolt"
"github.com/portainer/portainer/api"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/bolt/dockerhub"
"github.com/portainer/portainer/api/bolt/endpoint"
"github.com/portainer/portainer/api/bolt/endpointgroup"
@@ -34,6 +36,7 @@ import (
const (
databaseFileName = "portainer.db"
dbBackupFileName = "portainer-1-24-backup.db"
)
// Store defines the implementation of portainer.DataStore using
@@ -284,3 +287,38 @@ func (store *Store) initServices() error {
return nil
}
func (store *Store) Backup1_24db() error {
version, err := store.VersionService.DBVersion()
if err != nil && err != portainer.ErrObjectNotFound {
return err
}
if version != 24 {
return nil
}
databasePath := path.Join(store.path, databaseFileName)
dbBackupPath := path.Join(store.path, dbBackupFileName)
source, err := os.Open(databasePath)
if err != nil {
return err
}
defer source.Close()
destination, err := os.Create(dbBackupPath)
if err != nil {
return err
}
defer destination.Close()
_, err = io.Copy(destination, source)
if err == nil {
log.Println("backup for 1.24 finished successfully.")
}
return err
}
+6
View File
@@ -63,10 +63,16 @@ func initStore(dataStorePath string, fileService portainer.FileService) *bolt.St
log.Fatal(err)
}
err = store.Backup1_24db()
if err != nil {
log.Fatal(err)
}
err = store.MigrateData()
if err != nil {
log.Fatal(err)
}
return store
}
+1 -1
View File
@@ -1011,7 +1011,7 @@ type (
const (
// APIVersion is the version number of the Portainer API
APIVersion = "1.24.2"
APIVersion = "1.25.0"
// DBVersion is the version number of the Portainer database
DBVersion = 24
// AssetsServerURL represents the URL of the Portainer asset server
+17
View File
@@ -225,6 +225,23 @@ angular.module('portainer.app').factory('ModalService', [
);
};
service.upgradeNotification = function () {
bootbox.dialog({
size: 'extra-large',
title: 'Upgrade notification',
message: `You are currently using version 1.x of Portainer, which is no longer supported maintained or enhanced. Continuing to use this version is at your own risk.
<br/><br/>Please upgrade immediately by using the tag <code>portainer/portainer-ce:2.0.1</code>
<br/><br/>If you decide to stay on version 1, please use the tag <code>portainer/portainer:1.24.2</code> to prevent automatically upgrading to version 2, as <code>portainer:latest</code> will be updated to version 2 from May.`,
onEscape: false,
buttons: {
Close: {
label: 'Close',
className: 'btn-primary',
},
},
});
};
return service;
},
]);
+4 -1
View File
@@ -19,7 +19,8 @@ class AuthenticationController {
SettingsService,
URLHelper,
LocalStorage,
StatusService
StatusService,
ModalService
) {
this.$async = $async;
this.$scope = $scope;
@@ -37,6 +38,7 @@ class AuthenticationController {
this.URLHelper = URLHelper;
this.LocalStorage = LocalStorage;
this.StatusService = StatusService;
this.ModalService = ModalService;
this.logo = this.StateManager.getState().application.logo;
this.formValues = {
@@ -157,6 +159,7 @@ class AuthenticationController {
}
} finally {
this.StateManager.setVersionInfo(versionInfo);
this.ModalService.upgradeNotification();
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
"author": "Portainer.io",
"name": "portainer",
"homepage": "http://portainer.io",
"version": "1.24.2",
"version": "1.25.0",
"repository": {
"type": "git",
"url": "git@github.com:portainer/portainer.git"