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

data/source_aws_db_snapshot: Avoid nil pointer when snapshot is still being created #2178

Merged
merged 2 commits into from
Nov 6, 2017

Conversation

atsushi-ishibashi
Copy link
Contributor

@atsushi-ishibashi
Copy link
Contributor Author

atsushi-ishibashi commented Nov 5, 2017

This commit set fmt.Sprintf("creating at %s", time.Now().UTC().Format(time.RFC3339)) as snapshot_create_time because snapshot.SnapshotCreateTime is nil under creating. But if snapshot_create_time is important, it should be better to wail until finish.
Depending on the size of DB and region, it may take a long time...

Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

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

Hey @atsushi-ishibashi

Thanks for the provided fix. Just left a comment to discuss before taking any action there :)

d.Set("snapshot_create_time", snapshot.SnapshotCreateTime.Format(time.RFC3339))
} else {
d.Set("snapshot_create_time", fmt.Sprintf("creating at %s", time.Now().UTC().Format(time.RFC3339)))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

In the case where SnapshotCreateTime is nil, the attribute is set as a sentence containing the formatted time: this exposes a wrong information to the end user, and is not consistent with the other case, being just a formatted time.

I think we should only check for the case where it is not nil, because we have the correct snapshot creation time. THoughts? :)

Copy link
Contributor Author

@atsushi-ishibashi atsushi-ishibashi Nov 5, 2017

Choose a reason for hiding this comment

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

I agree with you. It's inconsistent with the formatted time.

@Ninir Ninir added the bug Addresses a defect in current functionality. label Nov 5, 2017
Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks a lot for the work hre @atsushi-ishibashi :)

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSDbSnapshotDataSource_'   
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSDbSnapshotDataSource_ -timeout 120m
=== RUN   TestAccAWSDbSnapshotDataSource_basic
--- PASS: TestAccAWSDbSnapshotDataSource_basic (594.84s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	594.890s

@Ninir Ninir changed the title Avoid nil pointer when snapshot is still being created data/source_aws_db_snapshot: Avoid nil pointer when snapshot is still being created Nov 6, 2017
@Ninir Ninir merged commit 0319fef into hashicorp:master Nov 6, 2017
@ghost
Copy link

ghost commented Apr 10, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants