Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Configurable operation timeouts #191

Merged
merged 2 commits into from
Jan 6, 2022

Conversation

turkenh
Copy link
Member

@turkenh turkenh commented Jan 5, 2022

Description of your changes

Fixes #176

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

  • unit tests
  • with provider gcp (WIP)

@turkenh turkenh requested a review from muvaf January 5, 2022 08:42
Signed-off-by: Hasan Turken <turkenh@gmail.com>
@turkenh turkenh force-pushed the configurable-timeouts branch from 71bbe96 to 8332b9d Compare January 5, 2022 12:46
pkg/terraform/files.go Outdated Show resolved Hide resolved
Comment on lines 192 to 195
Read *time.Duration
Create *time.Duration
Update *time.Duration
Delete *time.Duration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Read *time.Duration
Create *time.Duration
Update *time.Duration
Delete *time.Duration
Read time.Duration
Create time.Duration
Update time.Duration
Delete time.Duration

I am guessing that you had to use pointers to check whether it's given or not but there is a function (t Time) IsZero() bool we can use to do that. If that's the only reason, we could get rid of TimeDuration(d time.Duration) *time.Duration and work with value types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was the reason and I was thinking that setting timeout to 0 could be a valid scenario, e.g. no timeout. But digging the terraform sdk code, I noticed that there is no such an implementation and probably no timeout does not make sense at all.

So, I would revert pointers but to check zero value I can not use IsZero() because it is on time.Time not time.Duration. Am I missing something?

Otherwise, I will go with the following:

	if t := fp.Config.OperationTimeouts.Read.String(); t != "0s" {
		timeouts["read"] = t
	}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, I missed that IsZero wouldn't work. I think you can check like fp.Config.OperationTimeouts.Read != 0 since type Duration int64

Signed-off-by: Hasan Turken <turkenh@gmail.com>
@turkenh turkenh requested a review from muvaf January 6, 2022 07:23
Copy link
Member

@muvaf muvaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after it's tested manually. Thanks!

@turkenh turkenh marked this pull request as ready for review January 6, 2022 10:36
@turkenh turkenh merged commit 4a4dc50 into crossplane:main Jan 6, 2022
@turkenh turkenh deleted the configurable-timeouts branch January 6, 2022 12:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to configure operation timeouts
2 participants