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

Metadata TryGetTTL: adds time.ParseDuration support #3122

Merged
merged 9 commits into from Jan 16, 2024

Conversation

robertojrojas
Copy link
Contributor

Description

The metadata/utils.go.TryGetTTL doesn't appear to be parsing time.Duration correctly.

Providing a value like:

    - name: ttlInSeconds
    - value: "20s"  

causes the function to return

"ttlInSeconds value must be a valid integer: actual is '20s'"

Based on my understanding, this function should be able to parse both valid integers and time.Duration values.

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation / Created issue in the https://github.com/dapr/docs/ repo: dapr/docs#[issue number]

Signed-off-by: robertojrojas <robertojrojas@gmail.com>
@berndverst berndverst added this to the v1.13 milestone Sep 11, 2023
metadata/utils.go Outdated Show resolved Hide resolved
@berndverst
Copy link
Member

@robertojrojas and I chatted about this before. This is a good change - but as we are beyond code freeze this will be merged in 1.13.

Copy link
Contributor

@ItalyPaleAle ItalyPaleAle left a comment

Choose a reason for hiding this comment

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

I think this is a good change.

However, I'd like to ask that you rename ttlInSeconds to ttl after this change. ttlInSeconds should remain as alias, but the main property should be ttl (and if you can, please make the parser case-insensitive: this is one of the few properties that are still case-sensitive)

metadata/utils.go Outdated Show resolved Hide resolved
// Overflow
duration = math.MaxInt64
duration = time.Duration(valInt64) * time.Second
if duration < 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this to outside of the if err != nil { block. Because the duration parsed by time.ParseDuration could be < 0 too

metadata/utils.go Outdated Show resolved Hide resolved
@berndverst
Copy link
Member

FYI: Throughout contrib for every component metadata of type duration we support Duration strings, and also integers. If it's just an integer (string) then the value is interpreted as seconds. That exists primarily for backwards compatibility because duration strings are preferred instead. However, it's perfectly fine for only the duration string option to be documented.

Changing the TryGetTTL utility behavior here is consistent with the Duration behavior in Component Metadata parsing.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale label Oct 11, 2023
@ItalyPaleAle
Copy link
Contributor

@robertojrojas are you still working on this?

@github-actions github-actions bot removed the stale label Oct 11, 2023
Copy link

github-actions bot commented Dec 6, 2023

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale label Dec 6, 2023
Copy link

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot closed this Dec 13, 2023
@ItalyPaleAle ItalyPaleAle reopened this Dec 13, 2023
@github-actions github-actions bot removed the stale label Dec 13, 2023
Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale label Jan 12, 2024
…o metadata-get-ttl-fix

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
@ItalyPaleAle ItalyPaleAle marked this pull request as ready for review January 13, 2024 00:50
@ItalyPaleAle ItalyPaleAle requested review from a team as code owners January 13, 2024 00:50
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
@ItalyPaleAle
Copy link
Contributor

/ok-to-test

ItalyPaleAle
ItalyPaleAle previously approved these changes Jan 13, 2024
@dapr-bot
Copy link
Collaborator

Complete Build Matrix

The build status is currently not updated here. Please visit the action run below directly.

🔗 Link to Action run

Commit ref: dcc22f0

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 13, 2024

Components certification test

🔗 Link to Action run

Commit ref: dcc22f0

✅ All certification tests passed

All tests have reported a successful status

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 13, 2024

Components conformance test

🔗 Link to Action run

Commit ref: dcc22f0

❌ Some conformance tests failed

These tests failed:

  • state.azure.cosmosdb
  • state.postgresql.v1.azure

@github-actions github-actions bot removed the stale label Jan 13, 2024
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
@ItalyPaleAle ItalyPaleAle merged commit 28a3d64 into dapr:main Jan 16, 2024
88 of 89 checks passed
toneill818 pushed a commit to toneill818/components-contrib that referenced this pull request Jan 22, 2024
Signed-off-by: robertojrojas <robertojrojas@gmail.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Co-authored-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: Thomas O'Neill <toneill@new-innov.com>
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

Successfully merging this pull request may close these issues.

None yet

6 participants