Replies: 2 comments 5 replies
|
Hi @schveiguy, I don't have a setup to test this, but after I checked your branch and the data flow, it seems that it shouldn't do it. ~ updated_at = 1778074005 -> (known after apply)
~ user_id = "b4b4db51-8da9-4440-849b-64e201bb6f4e" -> (known after apply)This can be read like "provider does not know during refresh what values these fields have and it will provide them during the apply phase". What can you do?In order to investigate if that's the cause, you have multiple options, especially because you develop the provider: LogsCheck the logs of the provider, might show something that might help. You can do that by enabling the logs: TF_LOG=trace tofu planEnhance the provider loggingFor debugging purposes (do not ship this into an actual version of the provider), you can add more logs to help you understand how the provider<->webui interacts. tflog.Info(ctx, "Provider returned resourceModel state", map[string]any{"state": updated})You might need to play around with the Once you have this in place and provider installed and used by your local Provider debuggingA more advanced way to investigate this, is to use the debug options that the plugin-framework comes with and which is supported by OpenTofu. Enable debugging capabilities for your providerIn main.go, update your func main() {
var debug bool
flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()
providerserver.Serve(context.Background(), provider.New, providerserver.ServeOpts{
Address: "registry.terraform.io/nickcecere/openwebui",
Debug: debug,
})
}Start your provider in debug modeNow that the provider supports the debug flag, in your preferred IDE, run the provider TF_REATTACH_PROVIDERS='{"registry.terraform.io/nickcecere/openwebui":{"Protocol":"grpc","ProtocolVersion":6,"Pid":99999,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/xz/gnt2jl7j63n_fqd3ljh821500000gn/T/plugin4208316484"}}}'Instruct
|
|
I think what you have encountered here is unfortunately a classic design problem with retroactively adding something to a provider that was previously completely ignored by that provider, where you now need to be able to represent two different situations:
The first step is to decide how a module author would represent each of those cases in the configuration. You said you made the new argument optional, which suggests that the rule you chose was: if the argument is If that's what you intended, then based on the behavior you described I think the missing piece is that you need an extra plan modifier on if req.ConfigValue.IsNull() {
resp.PlanValue = req.StateValue
}Explicitly setting Note that this means if someone previously had I'm not sure that'd completely solve the problem -- I'm more familiar with the protocol-level details than the plugin framework's abstractions over it -- but hopefully that'd at least make some progress and then we could react to whatever the new situation is. |
Uh oh!
There was an error while loading. Please reload this page.
I am developing a terraform provider (or rather enhancing an open-source one) that communicates with open-webui.
I have changed the access control to enable the new style of access control.
This is achieved by sending an array of objects to the server like:
{ "access_grants": [ { "permission": "read", "principal_type": "user", "principal_id": "*" } ] }I have this implemented and when configured, the provider works as expected.
I have made this optional in the schema, because currently the permissions are not controlled, and I didn't want to invalidate existing configurations.
I have this problem, however. When access grants are NOT specified in the configuration, but there are some access grants on the server, opentofu always detects changes, and sends an update. The update changes nothing (it even does not list any changes in the plan, except for the object itself).
If I have a configuration specified for access_grants, then the diff works correctly.
If there are no access grants on the server, and no configuration, there is no diff detected.
Here is the code I am working with (branch with my changes):
https://github.com/symmetryinvestments/terraform-provider-openwebui/tree/add-public-group-handling
Here is the code which defines the schema for the access grants (focusing on models right now): https://github.com/symmetryinvestments/terraform-provider-openwebui/blob/add-public-group-handling/internal/provider/resource_model.go#L174
And a sample configuration:
Note the lack of
access_grantsin the config.When I run tofu apply:
I've also used
tofu plan -jsonto output a json file, where I compare before/after json. No changes (except for the user_id and updated_at, which are always shown as "known after apply")I feel like there must be some attribute or plan modifier I should be attaching so it doesn't see differences when access_grants are unspecified. What am I doing wrong? I find the actual diffing code in opentofu hard to understand (golang is also new to me). What I want to see/understand is what opentofu uses as the two things to compare. I find it frustrating there is no way to say "show me the whole configuration, highlighting the changes you discovered".
All reactions