Juniper / terraform-provider-apstra

Apstra Terraform Provider
Apache License 2.0
14 stars 3 forks source link

Bug in `apstra_datacenter_generic_system` handling of `group_label` #441

Open chrismarget-j opened 10 months ago

chrismarget-j commented 10 months ago

Reproduce:

Expected behavior:

Actual behavior:

@bwJuniper, please reproduce, verify my summary here, then assign to me? If there's some subtlety I'm missing, I'd like to be aware of it before I dig in. Thanks!

bwJuniper commented 10 months ago

There is a missing if/catch here in this area that does not check to see if the link bond is different or the same from the state to the plan... (i hope i got this right ) here is the code and a stack trace.


if !o.Tags.Equal(state.Tags) || !o.LagMode.Equal(state.LagMode) {
        var tags []string
        diags.Append(o.Tags.ElementsAs(ctx, &tags, false)...)
        if tags == nil {
            tags = []string{} // convert nil -> empty slice to clear tags
        }

        var lagMode apstra.RackLinkLagMode
        err := lagMode.FromString(o.LagMode.ValueString())
        if err != nil {
            diags.AddError(fmt.Sprintf("failed to parse lag mode %s", o.LagMode), err.Error())
            return
        }

        // set lag params + tag set
        err = client.SetLinkLagParams(ctx, &apstra.SetLinkLagParamsRequest{id: apstra.LinkLagParams{
            GroupLabel: o.GroupLabel.ValueString(),
            LagMode:    lagMode,
            Tags:       tags,
        }})
        if err != nil {
            diags.AddError(fmt.Sprintf("failed to set link %s LAG parameters", id), err.Error())
        }
    }

blueprint.(*DatacenterGenericSystemLink).updateParams (datacenter_generic_system_link.go:201) github.com/Juniper/terraform-provider-apstra/apstra/blueprint
blueprint.(*DatacenterGenericSystem).updateLinkParams (datacenter_generic_system.go:475) github.com/Juniper/terraform-provider-apstra/apstra/blueprint
blueprint.(*DatacenterGenericSystem).UpdateLinkSet (datacenter_generic_system.go:408) github.com/Juniper/terraform-provider-apstra/apstra/blueprint
tfapstra.(*resourceDatacenterGenericSystem).Update (resource_datacenter_generic_system.go:198) github.com/Juniper/terraform-provider-apstra/apstra
fwserver.(*Server).UpdateResource (server_updateresource.go:122) github.com/hashicorp/terraform-plugin-framework/internal/fwserver
fwserver.(*Server).ApplyResourceChange (server_applyresourcechange.go:102) github.com/hashicorp/terraform-plugin-framework/internal/fwserver
proto6server.(*Server).ApplyResourceChange (server_applyresourcechange.go:55) github.com/hashicorp/terraform-plugin-framework/internal/proto6server
tf6server.(*server).ApplyResourceChange (server.go:819) github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server
tfplugin6._Provider_ApplyResourceChange_Handler (tfplugin6_grpc.pb.go:422) github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6
grpc.(*Server).processUnaryRPC (server.go:1337) google.golang.org/grpc
grpc.(*Server).handleStream (server.go:1714) google.golang.org/grpc
grpc.(*Server).serveStreams.func1.1 (server.go:959) google.golang.org/grpc
runtime.goexit (asm_arm64.s:1172) runtime
 - Async Stack Trace
grpc.(*Server).serveStreams.func1 (server.go:957) google.golang.org/grpc