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

cctl upgrade machine #82

Merged
merged 13 commits into from
Aug 12, 2018
Merged

cctl upgrade machine #82

merged 13 commits into from
Aug 12, 2018

Conversation

vannrt
Copy link
Contributor

@vannrt vannrt commented Aug 8, 2018

If any of the components except for nodeadm/etcadm were updated, trigger an
upgrade.

A nodeadm/etcdadm version change does not require an actuator call. The
ssh-provider actuator will take care of ensuring that the correct
version is invoked.

cmd/machine.go Outdated

currentComponentVersions := getCurrentComponentVersions()

if cmp.Equal(oldMachineSpec.ComponentVersions, currentComponentVersions) {
Copy link
Contributor

@puneetguptanitj puneetguptanitj Aug 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment, would it make sense to have a isUpgradeRequired sort of a method which takes old and current versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a better way to put it than the current implementation, thanks Puneet!

Copy link
Contributor

@sarun87 sarun87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me otherwise.

cmd/machine.go Outdated
upgradeRequired, upgrade := isUpgradeRequired(oldMachineSpec.ComponentVersions, currentComponentVersions)

if !upgradeRequired {
fmt.Printf("Machine is update to date\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: typo, I believe you meant "Machine is up to date"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Use fmt.Println

cmd/machine.go Outdated
// and create a new one with the same specs as the old one
createMachine(ip, oldProvisionedMachine.Spec.SSHConfig.Port, oldProvisionedMachine.Spec.VIPNetworkInterface,
role, oldProvisionedMachine.Spec.SSHConfig.PublicKeys)
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note that the specified machine upgraded successfully?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

cmd/machine.go Outdated
if err := state.PullFromAPIs(); err != nil {
log.Fatalf("Unable to sync on-disk state: %v", err)
}
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: Add a note that the specified machine upgraded successfully?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@dlipovetsky dlipovetsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use log, not fmt to print to console.

@vannrt
Copy link
Contributor Author

vannrt commented Aug 11, 2018

@dlipovetsky I've updated the diff to use log instead of fmt

cmd/machine.go Outdated
deleteMachine(ip)
role := string(oldMachineSpec.Roles[0])
// and create a new one with the same specs as the old one
createMachine(ip, oldProvisionedMachine.Spec.SSHConfig.Port, oldProvisionedMachine.Spec.VIPNetworkInterface,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's suppose the user runs cctl machine upgrade, and deleteMachine succeeds, but createMachine fails. That means the machine has been removed from the on-disk state, and cctl machine create must be run.

@puneetguptanitj If you the observation has merit, can you please create an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case we can make this less bothersome by checking if createMachine succeeded and if not we can log the details that we use to create the machine.

I'm wondering if a retry would make sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may have to address this separately. Filed #93.


upgradeRequired, upgrade := isUpgradeRequired(oldMachineSpec.ComponentVersions, currentComponentVersions)

if !upgradeRequired {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this name makes sense. If upgradeRequired is true, but only the nodeadm/etcdadm versions have changed, then an upgrade is not required--only the state file needs to be updated.

Given that one of the conditional blocks (on L678 and L692) will execute, I think upgradeRequired might not be necessary. The lines on L673-674 could run after the two conditional blocks above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess in this context I consider any change to be an upgrade even if only a state file change is required. But I see your point though. This could be better named.

@dlipovetsky
Copy link
Contributor

@vannrt Thanks for changing to log!

vannrt and others added 13 commits August 11, 2018 20:50
@vannrt vannrt force-pushed the private/vteves/cctl-upgrade-machine branch from 87e9bca to fdf51ab Compare August 12, 2018 03:57
upgrade.KeepalivedVersion ||
upgrade.EtcdVersion {
// delete machine
deleteMachine(ip, false, false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlipovetsky What you do think about this? deleteMachine here is called with force=False and skipDrainDelete=False.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this with respect to resolving the merge conflict? If so, LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sounds good. I was going to add if setting them to False was a good choice but I saw that the default for both options is False so I think we're good. Thanks!

@vannrt vannrt merged commit 980193f into master Aug 12, 2018
@vannrt vannrt deleted the private/vteves/cctl-upgrade-machine branch October 2, 2018 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants