-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENGDTR-4307] Allow msr2 and msr3 products to coexist (#488)
* Seperate out MSR inlined config into two seperate products * Allow both MSR2 and MSR3 to coexist * Refactor describe to iterate through both product types and remove uses of switch. * Refactor GatherFacts and ValidateFacts phases to validate both products. * Refactor phase to just check for config non-nil and remove uses of switch. * Rename MSR to MSR2 and rename files, packages and struct entries. Signed-off-by: Kyle Squizzato <[email protected]> Co-authored-by: James Nesbitt <[email protected]>
- Loading branch information
1 parent
41149a0
commit 95a2422
Showing
41 changed files
with
728 additions
and
708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package v15 | ||
|
||
import ( | ||
"github.com/Mirantis/mcc/pkg/config/migration" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// Migrate migrates a v1.5 format configuration into the v1.6 api format and | ||
// replaces the contents of the supplied data byte slice. | ||
func Migrate(plain map[string]interface{}) error { | ||
plain["apiVersion"] = "launchpad.mirantis.com/mke/v1.6" | ||
if spec, ok := plain["spec"].(map[interface{}]interface{}); ok { | ||
if msr, ok := spec["msr"].(map[interface{}]interface{}); ok { | ||
// Convert msr key to msr2. | ||
spec["msr2"] = msr | ||
delete(spec, "msr") | ||
} | ||
} | ||
|
||
log.Debugf("migrated configuration from launchpad.mirantis.com/v1.5 to launchpad.mirantis.com/mke/v1.6") | ||
log.Infof("Note: The configuration has been migrated from a previous version") | ||
log.Infof(" to see the migrated configuration use: launchpad describe config") | ||
return nil | ||
} | ||
|
||
func init() { | ||
migration.Register("launchpad.mirantis.com/mke/v1.5", Migrate) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package v15 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
func TestVersionMigration(t *testing.T) { | ||
v15 := []byte(`apiVersion: launchpad.mirantis.com/mke/v1.5 | ||
kind: mke | ||
spec: | ||
mcr: | ||
channel: stable | ||
installURLLinux: https://get.mirantis.com/ | ||
installURLWindows: https://get.mirantis.com/install.ps1 | ||
repoURL: https://repos.mirantis.com | ||
version: 23.0.8 | ||
mke: | ||
adminPassword: miradmin | ||
adminUsername: admin | ||
imageRepo: docker.io/mirantis | ||
installFlags: | ||
- --san=pgedaray-mke-lb-1477b84d031720d6.elb.us-west-1.amazonaws.com | ||
- --nodeport-range=32768-35535 | ||
upgradeFlags: | ||
- --force-recent-backup | ||
- --force-minimums | ||
version: 3.7.3 | ||
msr: | ||
imageRepo: docker.io/mirantis | ||
installFlags: | ||
- --nfs-options nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport | ||
- --nfs-storage-url nfs://nfs.example.com/ | ||
replicaIDs: sequential | ||
version: 2.9.15 | ||
`) | ||
v16 := []byte(`apiVersion: launchpad.mirantis.com/mke/v1.6 | ||
kind: mke | ||
spec: | ||
mcr: | ||
channel: stable | ||
installURLLinux: https://get.mirantis.com/ | ||
installURLWindows: https://get.mirantis.com/install.ps1 | ||
repoURL: https://repos.mirantis.com | ||
version: 23.0.8 | ||
mke: | ||
adminPassword: miradmin | ||
adminUsername: admin | ||
imageRepo: docker.io/mirantis | ||
installFlags: | ||
- --san=pgedaray-mke-lb-1477b84d031720d6.elb.us-west-1.amazonaws.com | ||
- --nodeport-range=32768-35535 | ||
upgradeFlags: | ||
- --force-recent-backup | ||
- --force-minimums | ||
version: 3.7.3 | ||
msr2: | ||
imageRepo: docker.io/mirantis | ||
installFlags: | ||
- --nfs-options nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport | ||
- --nfs-storage-url nfs://nfs.example.com/ | ||
replicaIDs: sequential | ||
version: 2.9.15 | ||
`) | ||
in := make(map[string]interface{}) | ||
require.NoError(t, yaml.Unmarshal(v15, in)) | ||
require.NoError(t, Migrate(in)) | ||
out, err := yaml.Marshal(in) | ||
require.NoError(t, err) | ||
require.Equal(t, string(v16), string(out)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.