don't migrate backend during init without override
If the backend config hashes match during init, and there are no new backend override options, then we assume the existing config is OK. Since init should be idempotent, we should be able to run init with no options or config changes, and not effect the backends at all.
This commit is contained in:
parent
cefc927e48
commit
ee9a618369
|
@ -671,7 +671,7 @@ func TestInit_inputFalse(t *testing.T) {
|
|||
}
|
||||
|
||||
// A missing input=false should abort rather than loop infinitely
|
||||
args = []string{"-backend-config=path=bar"}
|
||||
args = []string{"-backend-config=path=baz"}
|
||||
if code := c.Run(args); code == 0 {
|
||||
t.Fatal("init should have failed", ui.OutputWriter)
|
||||
}
|
||||
|
|
|
@ -463,12 +463,11 @@ func (m *Meta) backendFromConfig(opts *BackendOpts) (backend.Backend, tfdiags.Di
|
|||
|
||||
// Potentially changing a backend configuration
|
||||
case c != nil && !s.Backend.Empty():
|
||||
// If we're not initializing, then it's sufficient for the configuration
|
||||
// hashes to match, since that suggests that the static backend
|
||||
// settings in the configuration files are unchanged. (The only
|
||||
// record we have of CLI overrides is in the settings cache in this
|
||||
// case, so we have no other source to compare with.
|
||||
if !opts.Init && uint64(cHash) == s.Backend.Hash {
|
||||
// We are not going to migrate if were not initializing and the hashes
|
||||
// match indicating that the stored config is valid. If we are
|
||||
// initializing, then we also assume the the backend config is OK if
|
||||
// the hashes match, as long as we're not providing any new overrides.
|
||||
if (uint64(cHash) == s.Backend.Hash) && (!opts.Init || opts.ConfigOverride == nil) {
|
||||
log.Printf("[TRACE] Meta.Backend: using already-initialized, unchanged %q backend configuration", c.Type)
|
||||
return m.backend_C_r_S_unchanged(c, cHash, sMgr)
|
||||
}
|
||||
|
@ -823,8 +822,6 @@ func (m *Meta) backend_C_r_S_changed(c *configs.Backend, cHash int, sMgr *state.
|
|||
return nil, diags
|
||||
}
|
||||
|
||||
fmt.Println("HERE")
|
||||
|
||||
// Perform the migration
|
||||
err := m.backendMigrateState(&backendMigrateOpts{
|
||||
OneType: s.Backend.Type,
|
||||
|
|
Loading…
Reference in New Issue