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

[specific ci=Group11-Upgrade] Reconfigure VM display name #4134

Merged
merged 58 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e63f1d1
initial design proposal for docker rename
chengwang86 Feb 14, 2017
f080eb7
reconfigure the VM display name right after VM creation.
chengwang86 Feb 23, 2017
6608066
add test case in docker create and check the VM display name
chengwang86 Feb 23, 2017
d26775d
set the VM display name to containerID when creating the container
chengwang86 Feb 27, 2017
4b10dd5
check go fmt and goimport
chengwang86 Feb 27, 2017
5470a29
update the test case for vm reconfigure
chengwang86 Feb 27, 2017
661886d
update test
chengwang86 Feb 27, 2017
564de55
use containerShortID
chengwang86 Feb 28, 2017
e76636b
correct error in the test case for docker create
chengwang86 Feb 28, 2017
f686b89
add common2 and use it for vm creation; here the name in common2 is s…
chengwang86 Mar 2, 2017
12e44ba
update test cases so that they use the new naming convention for VM d…
chengwang86 Mar 2, 2017
312fbc8
update test case
chengwang86 Mar 2, 2017
31f5b96
correct unit test
chengwang86 Mar 2, 2017
332c170
update regression test
chengwang86 Mar 3, 2017
f5fd7f5
update test case
chengwang86 Mar 3, 2017
a2526fc
use isVCH() function to check whether a VM is a VCH or not during VCH…
chengwang86 Mar 3, 2017
b6ec05b
update test case for group9-vic-admin
chengwang86 Mar 6, 2017
1710ca6
correct error in test group9-01
chengwang86 Mar 6, 2017
b6d4024
obtain the VCH hostname from vsphere for the vicadmin web portal
chengwang86 Mar 6, 2017
ae9f2b6
- rename `Common2` to `CommonSpecForVM`
chengwang86 Mar 6, 2017
5278a2f
add plugin for data migration after VCH upgrade
chengwang86 Mar 6, 2017
1a301fd
- add a plugin to support changing VCH config (setting the scope of c…
chengwang86 Mar 7, 2017
905c8ab
resolve conflict
chengwang86 Mar 7, 2017
a9c6cf4
add plugins
chengwang86 Mar 15, 2017
494e650
update error msgs and correct goimports
chengwang86 Mar 8, 2017
e0008c1
update the functions and tests based on review comments
chengwang86 Mar 8, 2017
7fb5d05
rearrage
chengwang86 Mar 8, 2017
f2ecb14
update VCHName()
chengwang86 Mar 10, 2017
f8040d4
fix the issue of vicadmin grabbing container log bunble using contain…
chengwang86 Mar 10, 2017
0f9cb0b
update code based on comments
chengwang86 Mar 10, 2017
9c81713
update test case 9-01
chengwang86 Mar 10, 2017
a2f4c95
update test 9-01
chengwang86 Mar 10, 2017
9afaea6
set vm full name to be containerName-shortID
chengwang86 Mar 13, 2017
625447c
add vsan logic
chengwang86 Mar 14, 2017
4a55491
add vsan logic to logging
chengwang86 Mar 15, 2017
5f7ced4
- remove vm reconfigure after vm creation; instead, we set the datast…
chengwang86 Mar 15, 2017
65a75f7
cosmetic changes
chengwang86 Mar 15, 2017
4acae52
add plugins
chengwang86 Mar 15, 2017
175d278
remove unnecessary comments and update test case
chengwang86 Mar 15, 2017
8b595bf
update upgrade test
chengwang86 Mar 16, 2017
f0491e4
update test case 11-01
chengwang86 Mar 16, 2017
e3b186e
cosmetic change
chengwang86 Mar 16, 2017
e395ab6
correct typo
chengwang86 Mar 16, 2017
e27d600
- set log bundle name of containerVMs to the display name
chengwang86 Mar 22, 2017
b2790bb
correct errors in test cases
chengwang86 Mar 22, 2017
6616805
update code repo
chengwang86 Mar 22, 2017
bc7f544
use session.isVSAN() to check whether it is a vsan setup
chengwang86 Mar 22, 2017
df19841
update exec_test.go
chengwang86 Mar 22, 2017
3370e0e
cosmetic changees
chengwang86 Mar 22, 2017
f2c7a48
cosmetic change
chengwang86 Mar 22, 2017
cd20d16
update tests and the method for obtaining VCH name in vicadmin
chengwang86 Mar 22, 2017
2f1ff70
remove VSAN checking from logging.go
chengwang86 Mar 22, 2017
7f80e50
cosmetic change
chengwang86 Mar 22, 2017
456f991
cosmetic change
chengwang86 Mar 22, 2017
5866e27
- update test case 9-01
chengwang86 Mar 23, 2017
9ffcb32
move plugins from pkg to lib/migration/plugins/
chengwang86 Mar 23, 2017
ddc4363
cosmetic changes
chengwang86 Mar 23, 2017
607b057
cosmetic change
chengwang86 Mar 23, 2017
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
10 changes: 5 additions & 5 deletions cmd/tether/attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func attachCase(t *testing.T, runblock bool) {
testServer, _ := server.(*testAttachServer)

cfg := executor.ExecutorConfig{
Common: executor.Common{
ExecutorConfigCommon: executor.ExecutorConfigCommon{
ID: "attach",
Name: "tether_test_executor",
},
Expand Down Expand Up @@ -336,7 +336,7 @@ func TestAttachTTY(t *testing.T) {
testServer, _ := server.(*testAttachServer)

cfg := executor.ExecutorConfig{
Common: executor.Common{
ExecutorConfigCommon: executor.ExecutorConfigCommon{
ID: "attach",
Name: "tether_test_executor",
},
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestAttachMultiple(t *testing.T) {
testServer, _ := server.(*testAttachServer)

cfg := executor.ExecutorConfig{
Common: executor.Common{
ExecutorConfigCommon: executor.ExecutorConfigCommon{
ID: "tee1",
Name: "tether_test_executor",
},
Expand Down Expand Up @@ -603,7 +603,7 @@ func TestAttachInvalid(t *testing.T) {
testServer, _ := server.(*testAttachServer)

cfg := executor.ExecutorConfig{
Common: executor.Common{
ExecutorConfigCommon: executor.ExecutorConfigCommon{
ID: "attachinvalid",
Name: "tether_test_executor",
},
Expand Down Expand Up @@ -740,7 +740,7 @@ func TestReattach(t *testing.T) {
testServer, _ := server.(*testAttachServer)

cfg := executor.ExecutorConfig{
Common: executor.Common{
ExecutorConfigCommon: executor.ExecutorConfigCommon{
ID: "attach",
Name: "tether_test_executor",
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/vic-init/restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestRestart(t *testing.T) {
defer testTeardown(t)

cfg := executor.ExecutorConfig{
Common: executor.Common{
ExecutorConfigCommon: executor.ExecutorConfigCommon{
ID: "pathlookup",
Name: "tether_test_executor",
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/vicadmin/vicadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func newBytesEntry(name string, b []byte) entry {

type versionReader string

func (path versionReader) open() (entry,error) {
func (path versionReader) open() (entry, error) {
defer trace.End(trace.Begin(string(path)))
return newBytesEntry(string(path), []byte(version.Version)), nil
}
Expand Down
2 changes: 1 addition & 1 deletion doc/design/docker-rename.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ Robot scripts will be written to test the following:
- `docker-compose up –force-recreate` when there are existing containers for the same service even if the configuration or image has not been changed

3. Backward compatibility
- Add a test case in the upgrade test. Create a container using a VCH that does not support `docker rename`. After upgrading the VCH, the basic docker operations that are supported by the old VCH should work.
- Add a test case in the upgrade test. Create a container using a VCH that does not support `docker rename`. After upgrading the VCH, the basic docker operations that are supported by the old VCH should work.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (handler *ContainersHandlersImpl) CreateHandler(params containers.CreatePar
}

m := &executor.ExecutorConfig{
Common: executor.Common{
ExecutorConfigCommon: executor.ExecutorConfigCommon{
ID: id,
Name: params.CreateConfig.Name,
},
Expand Down
17 changes: 16 additions & 1 deletion lib/config/executor/container_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ type Common struct {
Notes string `vic:"0.1" scope:"hidden" key:"notes"`
}

// Common data (specifically for a containerVM) between managed entities, across execution environments.
type ExecutorConfigCommon struct {
// A reference to the components hosting execution environment, if any
ExecutionEnvironment string

// Unambiguous ID with meaning in the context of its hosting execution environment
ID string `vic:"0.1" scope:"read-only" key:"id"`

// Convenience field to record a human readable name
Name string `vic:"0.1" scope:"hidden" key:"name"`

// Freeform notes related to the entity
Notes string `vic:"0.1" scope:"hidden" key:"notes"`
}

// Diagnostics records some basic control and lifecycle information for diagnostic purposes
type Diagnostics struct {
// Should debugging be enabled on whatever component this is and at what level
Expand Down Expand Up @@ -108,7 +123,7 @@ type ContainerVM struct {
// in that there is no process inherently associated - this is closer to a ThreadPool than a Thread and
// is the owner of the shared filesystem environment. This is the guest visible complement to ContainerVM.
type ExecutorConfig struct {
Common `vic:"0.1" scope:"read-only" key:"common"`
ExecutorConfigCommon `vic:"0.1" scope:"read-only" key:"common"`

// CreateTime stamp
CreateTime int64 `vic:"0.1" scope:"read-write" key:"createtime"`
Expand Down
9 changes: 6 additions & 3 deletions lib/install/management/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,26 @@ func (d *Dispatcher) DeleteVCHInstances(vmm *vm.VirtualMachine, conf *config.Vir
if err != nil {
return err
}

if children, err = d.parentResourcepool.GetChildrenVMs(d.ctx, d.session); err != nil {
return err
}

if d.session.Datastore, err = d.getImageDatastore(vmm, conf, d.force); err != nil {
return err
}

for _, child := range children {
name, err := child.Name(d.ctx)
//Leave VCH appliance there until everything else is removed, cause it has VCH configuration. Then user could retry delete in case of any failure.
ok, err := d.isVCH(child)
if err != nil {
errs = append(errs, err.Error())
continue
}
//Leave VCH appliance there until everything else is removed, cause it has VCH configuration. Then user could retry delete in case of any failure.
if name == conf.Name {
if ok {
continue
}

if err = d.deleteVM(child, d.force); err != nil {
errs = append(errs, err.Error())
}
Expand Down
14 changes: 8 additions & 6 deletions lib/migration/migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package migration

import (
"strconv"
"strings"
"testing"

Expand All @@ -34,10 +35,11 @@ func setUp() {
// register sample plugin into test
log.SetLevel(log.DebugLevel)
trace.Logger.Level = log.DebugLevel
version.MaxPluginVersion = 1
version.MaxPluginVersion = version.MaxPluginVersion + 1

if err := manager.Migrator.Register(1, manager.ApplianceConfigure, &plugin1.ApplianceStopSignalRename{}); err != nil {
log.Errorf("Failed to register plugin %s:%d, %s", manager.ApplianceConfigure, 1, err)
if err := manager.Migrator.Register(version.MaxPluginVersion, manager.ApplianceConfigure, &plugin1.ApplianceStopSignalRename{}); err != nil {
log.Errorf("Failed to register plugin %s:%d, %s", manager.ApplianceConfigure, version.MaxPluginVersion, err)
panic(err)
}
}

Expand Down Expand Up @@ -72,7 +74,7 @@ func TestMigrateConfigure(t *testing.T) {
assert.True(t, migrated, "should be migrated")

latestVer := newData[manager.ApplianceVersionKey]
assert.Equal(t, "1", latestVer, "upgrade version mismatch")
assert.Equal(t, strconv.Itoa(version.MaxPluginVersion), latestVer, "upgrade version mismatch")

// check new data
var found bool
Expand Down Expand Up @@ -102,7 +104,7 @@ func TestMigrateConfigure(t *testing.T) {
newConf := &config.VirtualContainerHostConfigSpec{}
extraconfig.Decode(extraconfig.MapSource(newData), newConf)

assert.Equal(t, 1, newConf.Version.PluginVersion, "should not be migrated")
assert.Equal(t, version.MaxPluginVersion, newConf.Version.PluginVersion, "should not be migrated")
t.Logf("other version fields: %s", newConf.Version.String())
}

Expand Down Expand Up @@ -139,5 +141,5 @@ func TestIsDataOlder(t *testing.T) {

older, err = ContainerDataIsOlder(mapData)
assert.Equal(t, nil, err, "should not have error")
assert.False(t, older, "Test data should not be older than latest, no container update plugin registered yet")
assert.True(t, older, "Test data should be older than latest since a container update plugin has been registered")
}
4 changes: 4 additions & 0 deletions lib/migration/plugins/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
package plugins

// import all plugin packages here to register plugins
import (
_ "github.com/vmware/vic/lib/migration/plugins/plugin1"
_ "github.com/vmware/vic/lib/migration/plugins/plugin2"
)
128 changes: 128 additions & 0 deletions lib/migration/plugins/plugin1/commonSpecForVCH.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package plugin1

import (
"context"
"fmt"

"github.com/vmware/vic/lib/migration/manager"

log "github.com/Sirupsen/logrus"
"github.com/vmware/vic/lib/migration/errors"
"github.com/vmware/vic/pkg/trace"
"github.com/vmware/vic/pkg/vsphere/extraconfig"
"github.com/vmware/vic/pkg/vsphere/session"
)

const (
version = 1
target = manager.ApplianceConfigure
)

func init() {
defer trace.End(trace.Begin(fmt.Sprintf("Registering plugin %s:%d", target, version)))
if err := manager.Migrator.Register(version, target, &AddCommonSpecForVCH{}); err != nil {
log.Errorf("Failed to register plugin %s:%d, %s", target, version, err)
panic(err)
}
}

// AddCommonSpecForVM is plugin for vic 0.8.0-GA version upgrade
type AddCommonSpecForVCH struct {
}

type VirtualContainerHostConfigSpec struct {
ExecutorConfig `vic:"0.1" scope:"read-only" key:"init"`
}

type ExecutorConfig struct {
Common `vic:"0.1" scope:"read-only" key:"common"`
}

type Common struct {
// A reference to the components hosting execution environment, if any
ExecutionEnvironment string

// Unambiguous ID with meaning in the context of its hosting execution environment
ID string `vic:"0.1" scope:"read-only" key:"id"`

// Convenience field to record a human readable name
Name string `vic:"0.1" scope:"read-only" key:"name"`

// Freeform notes related to the entity
Notes string `vic:"0.1" scope:"hidden" key:"notes"`
}

type UpdatedVCHConfigSpec struct {
UpdatedExecutorConfig `vic:"0.1" scope:"read-only" key:"init"`
}

type UpdatedExecutorConfig struct {
UpdatedCommon `vic:"0.1" scope:"read-only" key:"common"`
}

type UpdatedCommon struct {
// A reference to the components hosting execution environment, if any
ExecutionEnvironment string

// Unambiguous ID with meaning in the context of its hosting execution environment
ID string `vic:"0.1" scope:"read-only" key:"id"`

// Convenience field to record a human readable name
Name string `vic:"0.1" scope:"hidden" key:"name"`

// Freeform notes related to the entity
Notes string `vic:"0.1" scope:"hidden" key:"notes"`
}

func (p *AddCommonSpecForVCH) Migrate(ctx context.Context, s *session.Session, data interface{}) error {
defer trace.End(trace.Begin(fmt.Sprintf("AddCommonSpecForVCH version: %d", version)))
if data == nil {
return nil
}
mapData, ok := data.(map[string]string)
if !ok {
// Log the error here and return nil so that other plugins can proceed
log.Errorf("Migration data format is not map: %+v", data)
return nil
}
oldStruct := &VirtualContainerHostConfigSpec{}
result := extraconfig.Decode(extraconfig.MapSource(mapData), oldStruct)
log.Debugf("The oldStruct is %+v", oldStruct)
if result == nil {
return &errors.DecodeError{Err: fmt.Errorf("decode oldStruct %+v failed", oldStruct)}
}

newStruct := &UpdatedVCHConfigSpec{
UpdatedExecutorConfig: UpdatedExecutorConfig{
UpdatedCommon: UpdatedCommon{
Name: oldStruct.Name,
ID: oldStruct.ID,
ExecutionEnvironment: oldStruct.ExecutionEnvironment,
Notes: oldStruct.Notes,
},
},
}

cfg := make(map[string]string)
extraconfig.Encode(extraconfig.MapSink(cfg), newStruct)

for k, v := range cfg {
log.Debugf("New data: %s:%s", k, v)
mapData[k] = v
}
return nil
}
Loading