Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package terraform for openSUSE:Factory checked in at 2023-02-18 17:12:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terraform (Old) and /work/SRC/openSUSE:Factory/.terraform.new.22824 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terraform" Sat Feb 18 17:12:35 2023 rev:49 rq:1066521 version:1.3.9 Changes: -------- --- /work/SRC/openSUSE:Factory/terraform/terraform.changes 2023-02-16 16:55:53.174708710 +0100 +++ /work/SRC/openSUSE:Factory/.terraform.new.22824/terraform.changes 2023-02-18 17:12:42.783617686 +0100 @@ -1,0 +2,7 @@ +Wed Feb 15 18:54:57 UTC 2023 - Johannes Kastl <ka...@b1-systems.de> + +- update to 1.3.9: + * Fix crash when planning to remove already-deposed resource instances. + ([#32663](https://github.com/hashicorp/terraform/issues/32663)) + +------------------------------------------------------------------- Old: ---- terraform-1.3.8.obscpio terraform-1.3.8.tar.gz New: ---- terraform-1.3.9.obscpio terraform-1.3.9.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terraform.spec ++++++ --- /var/tmp/diff_new_pack.XQp6TF/_old 2023-02-18 17:12:45.567635265 +0100 +++ /var/tmp/diff_new_pack.XQp6TF/_new 2023-02-18 17:12:45.623635618 +0100 @@ -17,7 +17,7 @@ Name: terraform -Version: 1.3.8 +Version: 1.3.9 Release: 0 Summary: Tool for building infrastructure safely and efficiently License: MPL-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.XQp6TF/_old 2023-02-18 17:12:46.015638094 +0100 +++ /var/tmp/diff_new_pack.XQp6TF/_new 2023-02-18 17:12:46.055638346 +0100 @@ -3,8 +3,8 @@ <param name="url">https://github.com/hashicorp/terraform</param> <param name="scm">git</param> <param name="filename">terraform</param> - <param name="versionformat">1.3.8</param> - <param name="revision">v1.3.8</param> + <param name="versionformat">1.3.9</param> + <param name="revision">v1.3.9</param> <param name="exclude">.git</param> </service> <service name="tar" mode="disabled"/> @@ -16,7 +16,7 @@ <param name="basename">terraform</param> </service> <service name="go_modules" mode="disabled"> - <param name="archive">terraform-1.3.8.tar.gz</param> + <param name="archive">terraform-1.3.9.tar.gz</param> </service> </services> ++++++ terraform-1.3.8.obscpio -> terraform-1.3.9.obscpio ++++++ /work/SRC/openSUSE:Factory/terraform/terraform-1.3.8.obscpio /work/SRC/openSUSE:Factory/.terraform.new.22824/terraform-1.3.9.obscpio differ: char 50, line 1 ++++++ terraform-1.3.8.tar.gz -> terraform-1.3.9.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.3.8/.go-version new/terraform-1.3.9/.go-version --- old/terraform-1.3.8/.go-version 2023-02-09 20:37:37.000000000 +0100 +++ new/terraform-1.3.9/.go-version 2023-02-15 18:19:12.000000000 +0100 @@ -1 +1 @@ -1.19.4 +1.19.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.3.8/CHANGELOG.md new/terraform-1.3.9/CHANGELOG.md --- old/terraform-1.3.8/CHANGELOG.md 2023-02-09 20:37:37.000000000 +0100 +++ new/terraform-1.3.9/CHANGELOG.md 2023-02-15 18:19:12.000000000 +0100 @@ -1,3 +1,9 @@ +## 1.3.9 (February 15, 2023) + +BUG FIXES: + +* Fix crash when planning to remove already-deposed resource instances. ([#32663](https://github.com/hashicorp/terraform/issues/32663)) + ## 1.3.8 (February 09, 2023) BUG FIXES: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.3.8/internal/terraform/node_resource_plan_orphan.go new/terraform-1.3.9/internal/terraform/node_resource_plan_orphan.go --- old/terraform-1.3.8/internal/terraform/node_resource_plan_orphan.go 2023-02-09 20:37:37.000000000 +0100 +++ new/terraform-1.3.9/internal/terraform/node_resource_plan_orphan.go 2023-02-15 18:19:12.000000000 +0100 @@ -125,7 +125,7 @@ // refresh indicates the instance no longer exists, there is also nothing // to plan because there is no longer any state and it doesn't exist in the // config. - if n.skipPlanChanges || oldState.Value.IsNull() { + if n.skipPlanChanges || oldState == nil || oldState.Value.IsNull() { return diags.Append(n.writeResourceInstanceState(ctx, oldState, workingState)) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.3.8/internal/terraform/node_resource_plan_orphan_test.go new/terraform-1.3.9/internal/terraform/node_resource_plan_orphan_test.go --- old/terraform-1.3.8/internal/terraform/node_resource_plan_orphan_test.go 2023-02-09 20:37:37.000000000 +0100 +++ new/terraform-1.3.9/internal/terraform/node_resource_plan_orphan_test.go 2023-02-15 18:19:12.000000000 +0100 @@ -141,3 +141,70 @@ t.Errorf("there should be no change for the %s instance, got %s", addr, got.Action) } } + +// This test describes a situation which should not be possible, as this node +// should never work on deposed instances. However, a bug elsewhere resulted in +// this code path being exercised and triggered a panic. As a result, the +// assertions at the end of the test are minimal, as the behaviour (aside from +// not panicking) is unspecified. +func TestNodeResourcePlanOrphanExecute_deposed(t *testing.T) { + addr := addrs.Resource{ + Mode: addrs.ManagedResourceMode, + Type: "test_object", + Name: "foo", + }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance) + + state := states.NewState() + state.Module(addrs.RootModuleInstance).SetResourceInstanceDeposed( + addr.Resource, + states.NewDeposedKey(), + &states.ResourceInstanceObjectSrc{ + AttrsFlat: map[string]string{ + "test_string": "foo", + }, + Status: states.ObjectReady, + }, + addrs.AbsProviderConfig{ + Provider: addrs.NewDefaultProvider("test"), + Module: addrs.RootModule, + }, + ) + refreshState := state.DeepCopy() + prevRunState := state.DeepCopy() + changes := plans.NewChanges() + + p := simpleMockProvider() + p.ConfigureProvider(providers.ConfigureProviderRequest{}) + p.ReadResourceResponse = &providers.ReadResourceResponse{ + NewState: cty.NullVal(p.GetProviderSchemaResponse.ResourceTypes["test_string"].Block.ImpliedType()), + } + ctx := &MockEvalContext{ + StateState: state.SyncWrapper(), + RefreshStateState: refreshState.SyncWrapper(), + PrevRunStateState: prevRunState.SyncWrapper(), + InstanceExpanderExpander: instances.NewExpander(), + ProviderProvider: p, + ProviderSchemaSchema: &ProviderSchema{ + ResourceTypes: map[string]*configschema.Block{ + "test_object": simpleTestSchema(), + }, + }, + ChangesChanges: changes.SyncWrapper(), + } + + node := NodePlannableResourceInstanceOrphan{ + NodeAbstractResourceInstance: &NodeAbstractResourceInstance{ + NodeAbstractResource: NodeAbstractResource{ + ResolvedProvider: addrs.AbsProviderConfig{ + Provider: addrs.NewDefaultProvider("test"), + Module: addrs.RootModule, + }, + }, + Addr: mustResourceInstanceAddr("test_object.foo"), + }, + } + diags := node.Execute(ctx, walkPlan) + if diags.HasErrors() { + t.Fatalf("unexpected error: %s", diags.Err()) + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.3.8/internal/terraform/transform_orphan_count.go new/terraform-1.3.9/internal/terraform/transform_orphan_count.go --- old/terraform-1.3.8/internal/terraform/transform_orphan_count.go 2023-02-09 20:37:37.000000000 +0100 +++ new/terraform-1.3.9/internal/terraform/transform_orphan_count.go 2023-02-15 18:19:12.000000000 +0100 @@ -33,7 +33,13 @@ // number of instances of a single resource ought to always be small in any // reasonable Terraform configuration. Have: - for key := range rs.Instances { + for key, inst := range rs.Instances { + // Instances which have no current objects (only one or more + // deposed objects) will be taken care of separately + if inst.Current == nil { + continue + } + thisAddr := rs.Addr.Instance(key) for _, wantAddr := range t.InstanceAddrs { if wantAddr.Equal(thisAddr) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.3.8/internal/terraform/transform_orphan_count_test.go new/terraform-1.3.9/internal/terraform/transform_orphan_count_test.go --- old/terraform-1.3.8/internal/terraform/transform_orphan_count_test.go 2023-02-09 20:37:37.000000000 +0100 +++ new/terraform-1.3.9/internal/terraform/transform_orphan_count_test.go 2023-02-15 18:19:12.000000000 +0100 @@ -161,6 +161,66 @@ } } +func TestOrphanResourceCountTransformer_deposed(t *testing.T) { + state := states.NewState() + root := state.RootModule() + root.SetResourceInstanceCurrent( + mustResourceInstanceAddr("aws_instance.web").Resource, + &states.ResourceInstanceObjectSrc{ + Status: states.ObjectReady, + AttrsJSON: []byte(`{"id":"foo"}`), + }, + mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`), + ) + root.SetResourceInstanceCurrent( + mustResourceInstanceAddr("aws_instance.foo[0]").Resource, + &states.ResourceInstanceObjectSrc{ + Status: states.ObjectReady, + AttrsJSON: []byte(`{"id":"foo"}`), + }, + mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`), + ) + root.SetResourceInstanceCurrent( + mustResourceInstanceAddr("aws_instance.foo[1]").Resource, + &states.ResourceInstanceObjectSrc{ + Status: states.ObjectReady, + AttrsJSON: []byte(`{"id":"foo"}`), + }, + mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`), + ) + root.SetResourceInstanceDeposed( + mustResourceInstanceAddr("aws_instance.foo[2]").Resource, + states.NewDeposedKey(), + &states.ResourceInstanceObjectSrc{ + Status: states.ObjectReady, + AttrsJSON: []byte(`{"id":"foo"}`), + }, + mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`), + ) + + g := Graph{Path: addrs.RootModuleInstance} + + { + tf := &OrphanResourceInstanceCountTransformer{ + Concrete: testOrphanResourceConcreteFunc, + Addr: addrs.RootModuleInstance.Resource( + addrs.ManagedResourceMode, "aws_instance", "foo", + ), + InstanceAddrs: []addrs.AbsResourceInstance{mustResourceInstanceAddr("aws_instance.foo[0]")}, + State: state, + } + if err := tf.Transform(&g); err != nil { + t.Fatalf("err: %s", err) + } + } + + actual := strings.TrimSpace(g.String()) + expected := strings.TrimSpace(testTransformOrphanResourceCountDeposedStr) + if actual != expected { + t.Fatalf("bad:\n\n%s", actual) + } +} + // When converting from a NoEach mode to an EachMap via a switch to for_each, // an edge is necessary to ensure that the map-key'd instances // are evaluated after the NoKey resource, because the final instance evaluated @@ -236,6 +296,10 @@ aws_instance.foo[1] (orphan) ` +const testTransformOrphanResourceCountDeposedStr = ` +aws_instance.foo[1] (orphan) +` + const testTransformOrphanResourceForEachStr = ` aws_instance.foo (orphan) aws_instance.foo["bar"] (orphan) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.3.8/internal/terraform/transform_orphan_resource.go new/terraform-1.3.9/internal/terraform/transform_orphan_resource.go --- old/terraform-1.3.8/internal/terraform/transform_orphan_resource.go 2023-02-09 20:37:37.000000000 +0100 +++ new/terraform-1.3.9/internal/terraform/transform_orphan_resource.go 2023-02-15 18:19:12.000000000 +0100 @@ -87,7 +87,8 @@ } for key, inst := range rs.Instances { - // deposed instances will be taken care of separately + // Instances which have no current objects (only one or more + // deposed objects) will be taken care of separately if inst.Current == nil { continue } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.3.8/version/version.go new/terraform-1.3.9/version/version.go --- old/terraform-1.3.8/version/version.go 2023-02-09 20:37:37.000000000 +0100 +++ new/terraform-1.3.9/version/version.go 2023-02-15 18:19:12.000000000 +0100 @@ -11,7 +11,7 @@ ) // The main version number that is being run at the moment. -var Version = "1.3.8" +var Version = "1.3.9" // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release ++++++ terraform.obsinfo ++++++ --- /var/tmp/diff_new_pack.XQp6TF/_old 2023-02-18 17:12:48.491653727 +0100 +++ /var/tmp/diff_new_pack.XQp6TF/_new 2023-02-18 17:12:48.495653753 +0100 @@ -1,5 +1,5 @@ name: terraform -version: 1.3.8 -mtime: 1675971457 -commit: bd3cd605162d84aa1e5cc710024d71781e696efd +version: 1.3.9 +mtime: 1676481552 +commit: 30dcdb076504d4549f12b64a9ff658f0dea8d75f ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/terraform/vendor.tar.gz /work/SRC/openSUSE:Factory/.terraform.new.22824/vendor.tar.gz differ: char 5, line 1