[specific ci=Group11-Upgrade] Add UpgradeInProgress flag for VCH upgrade#4847
[specific ci=Group11-Upgrade] Add UpgradeInProgress flag for VCH upgrade#4847chengwang86 merged 11 commits intovmware:masterfrom
Conversation
cmd/vic-machine/inspect/inspect.go
Outdated
| upgrading, err := vch.GetVCHUpdateStatus(ctx) | ||
| if err != nil { | ||
| log.Errorf("Unable to determine if upgrade is in progress: %s", err) | ||
| log.Errorf("Unable to determine if upgrade/update is in progress: %s", err) |
cmd/vic-machine/inspect/inspect.go
Outdated
| } | ||
| if upgrading { | ||
| log.Info("Upgrade in progress") | ||
| log.Info("Upgrade/update in progress") |
cmd/vic-machine/upgrade/upgrade.go
Outdated
| }, | ||
| cli.BoolFlag{ | ||
| Name: "resetInProgressFlag", | ||
| Usage: "Reset the UpdateInProgress flag", |
There was a problem hiding this comment.
This is upgrade command, name the flag as UpgradeInProgress.
cmd/vic-machine/upgrade/upgrade.go
Outdated
| return errors.New("upgrade failed") | ||
| } | ||
| if upgrading { | ||
| log.Error("Upgrade failed: another upgrade/update operation is in progress") |
There was a problem hiding this comment.
Please mention how to fix it using option --resetInProgressFlag
pkg/vsphere/vm/vm.go
Outdated
| } | ||
|
|
||
| // GetVCHUpdateStatus tells if an upgrade/update has already been started based on the UpdateInProgress flag in ExtraConfig | ||
| // If error != nil, VCH upgrade/update will exit; so the value of the VCH upgrade/update status is not important |
There was a problem hiding this comment.
method help should not talk about the behavior of callers
here should describe while any error happens in vm operation, will return error
pkg/vsphere/vm/vm.go
Outdated
| if v, ok := info[UpdateInProgress]; ok { | ||
| updateStatus, err := strconv.ParseBool(v) | ||
| if err != nil { | ||
| // If error occurs, return true to cancel VCH upgrade. The user can reset the UpdateInProgress flag later. |
There was a problem hiding this comment.
if error happens, the bool return value should not matter for the caller.
again do not comment caller's behavior
mhagen-vmware
left a comment
There was a problem hiding this comment.
couple small changes, otherwise lgtm
| [Arguments] ${expected} | ||
| ${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=%{VCH-NAME} --target=%{TEST_URL} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE} | ||
| Should Be Equal As Integers ${rc} 0 | ||
| Should Contain ${output} ${expected} |
There was a problem hiding this comment.
Pull this into VCH-Util.robot please.
| [Arguments] ${expected} | ||
| ${rc} ${output}= Run And Return Rc And Output govc vm.info -e %{VCH-NAME} | grep UpdateInProgress | ||
| Should Be Equal As Integers ${rc} 0 | ||
| Should Contain ${output} ${expected} |
pkg/vsphere/vm/vm.go
Outdated
|
|
||
| // GetVCHUpdateStatus tells if an upgrade/update has already been started based on the UpdateInProgress flag in ExtraConfig | ||
| // If error != nil, VCH upgrade/update will exit; so the value of the VCH upgrade/update status is not important | ||
| func (vm *VirtualMachine) GetVCHUpdateStatus(ctx context.Context) (bool, error) { |
There was a problem hiding this comment.
GetVCHUpdateStatus => VCHUpdateStatus
pkg/vsphere/vm/vm.go
Outdated
| } | ||
|
|
||
| // SetVCHUpdateStatus sets the "UpdateInProgress" flag in ExtraConfig | ||
| func (vm *VirtualMachine) SetVCHUpdateStatus(ctx context.Context, updateStatus string) error { |
There was a problem hiding this comment.
get set method should use same type of value, all string or bool
cmd/vic-machine/upgrade/upgrade.go
Outdated
| if upgrading { | ||
| log.Error("Upgrade failed: another upgrade/update operation is in progress") | ||
| log.Error("Upgrade failed: another upgrade/configure operation is in progress") | ||
| log.Error("Use --resetInProgressFlag to reset the VCH upgrade/configure status") |
There was a problem hiding this comment.
still need to mention, if there is no other upgrade or configure process running, use ...
pkg/vsphere/vm/vm.go
Outdated
| func (vm *VirtualMachine) GetVCHUpdateStatus(ctx context.Context) (bool, error) { | ||
| // VCHUpgradeStatus tells if an upgrade/configure has already been started based on the UpgradeInProgress flag in ExtraConfig | ||
| // It returns the error if the vm operation does not succeed | ||
| func (vm *VirtualMachine) VCHUpgradeStatus(ctx context.Context) (bool, error) { |
There was a problem hiding this comment.
this method will be reused by upgrade and configure, so might still use update as name
There was a problem hiding this comment.
please also add unit test for these two methods
cmd/vic-machine/upgrade/upgrade.go
Outdated
| }, | ||
| cli.BoolFlag{ | ||
| Name: "resetInProgressFlag", | ||
| Usage: "Reset the UpgradeInProgress flag", |
There was a problem hiding this comment.
feels like here should have a warning message as well. to make sure user does not reset flag during other process is actually running
pkg/vsphere/vm/vm.go
Outdated
| updateStatus, err := strconv.ParseBool(v) | ||
| if err != nil { | ||
| // If error occurs, the bool return value does not matter for the caller. | ||
| return true, fmt.Errorf("failed to parse %s to bool: %s", v, err) |
There was a problem hiding this comment.
I think here should return false
pkg/vsphere/vm/vm.go
Outdated
| return false, err | ||
| } | ||
|
|
||
| if v, ok := info[UpgradeInProgress]; ok { |
e074906 to
43925ad
Compare
Fixes #4069
This PR adds a flag
UpgradeInProgressto the VCH's ExtraConfig.during VCH upgrade, if
UpgradeInProgress==true, the current upgrade operation will fail since there might be another upgrade operation running.I also add
vic-machine upgrade --resetInProgressFlagso that the user could reset the flag tofalsein case the flag is polluted by previous operations that do not finish properly.test cases are added