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

Multi-CPI Director doesn't needlessly recreate VMs #2384

Merged
merged 1 commit into from
Jun 14, 2022
Merged

Multi-CPI Director doesn't needlessly recreate VMs #2384

merged 1 commit into from
Jun 14, 2022

Conversation

cunnie
Copy link
Member

@cunnie cunnie commented Jun 8, 2022

During a bosh deploy, a multi-CPI multi-IaaS BOSH Director may mistakenly recreate VMs that don't need to be recreated; it confuses the stemcells, thinking that the VM needs a different, wrong stemcell.

This commit fixes that error by fine-tuning the stemcell selection process. Specifically, the BOSH Director uses the CPI required by the AZ that the VM is to be placed in to determine which stemcell is desired.
We introduce a new method, DeploymentPlan::InstancePlan#stemcell_model_for_cpi, to properly select the stemcell.

The source of this stemcell mismatch is from DeploymentPlan::Stemcell#add_stemcell_models, where the first stemcell is arbitrarily chosen from an array of stemcells, which may be the correct stemcell for some of the VMs, and the wrong stemcell for others.

Although the decision to make the new method stemcell_model_for_cpi public is debatable (it should be a private method; it's never called outside the class), it certainly allowed for easier & more thorough testing.

Fixes, from bosh task 14721 --debug:

D, [2022-03-08T10:29:59.075291 #14721] [] DEBUG -- DirectorJobRunner: Need to update instance 'vpn-probe/e39b63ac-fb33-4e71-bbea-61eb19b5650f (0)', changes: "stemcell" stemcell_changed? changed FROM: bosh-vsphere-esxi-ubuntu-bionic-go_agent TO: bosh-openstack-kvm-ubuntu-bionic-go_agent on instance vpn-probe/e39b63ac-fb33-4e71-bbea-61eb19b5650f (0)

[Fixes #2363]

What is this change about?

During a bosh deploy, a multi-CPI multi-IaaS BOSH Director may mistakenly recreate VMs that don't need to be recreated

Please provide contextual information.

#2363

What tests have you run against this PR?

Unit tests. And I've hot-patched my multi-CPI BOSH Director and have done new deploys, existing deploys, deleted deployments, uploaded stemcells, cck, etc.

How should this change be described in bosh release notes?

Multi-CPI multi-IaaS BOSH Directors no longer unnecessarily recreate VMs on deploy.

Does this PR introduce a breaking change?

No.

During a `bosh deploy`, a multi-CPI multi-IaaS BOSH Director may
mistakenly recreate VMs that don't need to be recreated; it confuses the
stemcells, thinking that the VM needs a different, wrong stemcell.

This commit fixes that error by fine-tuning the stemcell selection
process. Specifically, the BOSH Director uses the CPI required by the AZ
that the VM is to be placed in to determine which stemcell is desired.
We introduce a new method,
`DeploymentPlan::InstancePlan#stemcell_model_for_cpi`, to properly
select the stemcell.

The source of this stemcell mismatch is from
`DeploymentPlan::Stemcell#add_stemcell_models`, where the first stemcell
is arbitrarily chosen from an array of stemcells, which may be the
correct stemcell for some of the VMs, and the wrong stemcell for others.

Although the decision to make the new method `stemcell_model_for_cpi`
public is debatable (it should be a private method; it's never called
outside the class), it certainly allowed for easier & more thorough
testing.

Fixes, from `bosh task 14721 --debug`:

> D, [2022-03-08T10:29:59.075291 #14721] [] DEBUG -- DirectorJobRunner: Need to update instance 'vpn-probe/e39b63ac-fb33-4e71-bbea-61eb19b5650f (0)', changes: "stemcell" stemcell_changed? changed FROM: bosh-vsphere-esxi-ubuntu-bionic-go_agent TO: bosh-openstack-kvm-ubuntu-bionic-go_agent on instance vpn-probe/e39b63ac-fb33-4e71-bbea-61eb19b5650f (0)

Drive-by: `#stemcell_changed?`: switched `@existing_instance` to
`existing_instance`; if you've gone to the trouble of setting an
`attr_accessor`, then you may as well take advantage it.

[Fixes #2363]
@beyhan beyhan requested review from a team, lnguyen and ramonskie and removed request for a team June 9, 2022 14:51
Copy link
Member

@lnguyen lnguyen left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ramonskie ramonskie left a comment

Choose a reason for hiding this comment

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

lgtm

@cunnie cunnie merged commit 8dc8fff into main Jun 14, 2022
@aramprice aramprice deleted the multi-cpi branch January 12, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
3 participants