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

r/virtual_machine: Remove clone config restriction for import/legacy #460

Merged
merged 3 commits into from
Apr 9, 2018

Conversation

vancluever
Copy link
Contributor

@vancluever vancluever commented Apr 8, 2018

This removes the restriction on the presence of the clone sub-resource
block for imported and legacy resources.

Previously, this was blocked as it forced a new resource, which is
obviously not what people would want during this process. ForceNew was
(naturally) controlled in schema, so there was not much we could do
here.

Some recent changes to diff customization has allowed us to change this
process in a way that has been relatively non-invasive. This has
resulted in the changes below:

  • Rather than using schema to force new resources for clone attributes,
    we now go through changed keys in the clone namespace and ForceNew these
    keys through diff customization. This happens for both new and existing
    resources to prevent diff mismatches.
  • We leverage imported as a conditional to provide a one-time exemption
    from this behavior. We now also transition imported from true to false
    after the first apply post-import/migration.

These two changes have the effect in that on the first apply operation
after a resource has been imported or transitioned from a legacy version
of the provider, all clone configuration settings are simply persisted
to state, without forcing a new resource. This, like other post-import
operations like flagging keep_on_remove for disks, is a no-op on the
vSphere API side and does not trigger a reconfigure or a rebuild of the
VM.

The new behavior has been documented. It should be noted that if
configuration changes to clone are made in the first post-apply run they
will be ignored permanently as well (as they will persist to state
without any action carried out on them), however this should be
avoidable when import/migration instructions are followed. This has been
documented as well.


This PR also includes updates to TF and mapstructure/copystructure (the latter as dependencies of changes in 0.11.6) that were needed to fix some bugs with ForceNew that was preventing this from working. The commits are still in PR and vendor should be updated when the fixes are fully upstream.

This adds in commits that are needed for a pending PR that adjusts how
ForceNew works in ResourceDiff. These are needed by some of our new diff
customization bits to make clone config pass-through work.

Also adds in copystructure/reflectwalk as there has been some
long-standing bug fixes that have been finally merged, which affect some
updates to helper/schema.
@vancluever vancluever added the enhancement Type: Enhancement label Apr 8, 2018
@vancluever vancluever requested a review from a team April 8, 2018 16:55
This removes the restriction on the presence of the clone sub-resource
block for imported and legacy resources.

Previously, this was blocked as it forced a new resource, which is
obviously not what people would want during this process. ForceNew was
(naturally) controlled in schema, so there was not much we could do
here.

Some recent changes to diff customization has allowed us to change this
process in a way that has been relatively non-invasive. This has
resulted in the changes below:

* Rather than using schema to force new resources for clone attributes,
we now go through changed keys in the clone namespace and ForceNew these
keys through diff customization. This happens for both new and existing
resources to prevent diff mismatches.
* We leverage imported as a conditional to provide a one-time exemption
from this behavior. We now also transition imported from true to false
after the first apply post-import/migration.

These two changes have the effect in that on the first apply operation
after a resource has been imported or transitioned from a legacy version
of the provider, all clone configuration settings are simply persisted
to state, without forcing a new resource. This, like other post-import
operations like flagging keep_on_remove for disks, is a no-op on the
vSphere API side and does not trigger a reconfigure or a rebuild of the
VM.

The new behavior has been documented. It should be noted that if
configuration changes to clone are made in the first post-apply run they
will be ignored permanently as well (as they will persist to state
without any action carried out on them), however this should be
avoidable when import/migration instructions are followed. This has been
documented as well.
@vancluever
Copy link
Contributor Author

vancluever commented Apr 8, 2018

Ref: #457, #333

ImportStateVerify does not fully simulate an import from scratch. This
means that we can't properly test if imported is being properly checked,
reverted, and passing the clone sub-resource through unless we hack the
state ourselves, which we do by adding another test step.
Copy link
Contributor

@bill-rich bill-rich left a comment

Choose a reason for hiding this comment

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

LGTM

@vancluever vancluever merged commit 9b57d38 into master Apr 9, 2018
@vancluever vancluever deleted the f-import-legacy-allow-clone branch April 26, 2018 17:17
@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants