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

Error when creating a Drive #11

Closed
jannishuebl opened this issue Feb 3, 2023 · 2 comments
Closed

Error when creating a Drive #11

jannishuebl opened this issue Feb 3, 2023 · 2 comments
Assignees

Comments

@jannishuebl
Copy link

When i want to create a shared drive, the drive is created but terraform gives me:

Error: XXXXX: googleapi: Error 404: Shared drive not found: XXXXX, notFound

I think there could be some timeing issue:
Do you think it could help to increase this sleep time?

time.Sleep(5 * time.Second)

@hanneshayashi hanneshayashi self-assigned this Feb 3, 2023
@hanneshayashi
Copy link
Owner

Hi and thanks for the bug report!
The API is unfortunately a little inconsistent sometimes. There is actually code in GSM that is supposed to make the function only return the Drive object after it can be queried by the API by checking the permissions on it:
https://github.com/hanneshayashi/gsm/blob/main/gsmdrive/drives.go#L51-L61
This seems to work in most cases. I also tried querying it again immediately after creation, but this will just work most of the time but subsequent calls will still fail. It just seems that the backend takes a while to replicate the information about the Drive...

Since the API is really inconsistent, it is also hard to test this behaviour.

The sleep timer should just be a failsafe, but it looks like it may not be enough. I could definitely try to increase it to 10 seconds, although I would prefer a more elegant and permanent solution.

I will take a look at this for the next release. As an immediate workaround you could try something with https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep.

hanneshayashi added a commit that referenced this issue Feb 5, 2023
@hanneshayashi
Copy link
Owner

@jannishuebl I was able to reproduce the issue and it still boils down to the API not being strongly consistent. After the creation of a Drive, the API immediately returns the object, but subsequent calls that reference or use the Drive may result in 404 errors for a while. Even if one or two requests succeed, the next one may still return 404.

The workaround for now is to have a longer wait time to give the backend time to replicate. I just released version v0.9.1 of the provider that introduces a new optional parameter called wait_after_create with a default value of 60 that allows you to configure the time the provider waits after the initial creation of the Drive object. Please test it out and let me know if this fixes the issue or re-open this issue if it still doesn't work.

As a side-note: In hindsight, it might have been better to create a separate resource for Drive restriction, as these cannot be set during the creation and need an update operation after the Drive has been created. I may change this in a v1.0 of the provider, as it would be a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants