The spring-cloud-vault Lease lifecycle management (renewal and revocation) documentation states that:
spring.cloud.vault.config.lifecycle.min-renewal: sets the duration that is at least required before renewing a lease. This setting prevents renewals from happening too often.
spring.cloud.vault.config.lifecycle.expiry-threshold: sets the expiry theshold. A lease is renewed the configured period of time before it expires.
I'm having a hard time understanding the difference between these two configuration options. It would be helpful to be given an example of how each of these parameters affects the lease renewal lifecycle. For example: it seems pretty clear to me that if the lease TTL is 10 minutes, and if the expiry-threshold is set to 1 minute, then 9 minutes after the lease is acquired spring-cloud-vault would renew the lease. But if that it true what is the purpose for the min-renewal configuration parameter?
The expiry threshold controls the renewal time at which the lease is renewed.
For example: it seems pretty clear to me that if the lease TTL is 10 minutes, and if the expiry-threshold is set to 1 minute, then 9 minutes after the lease is acquired spring-cloud-vault would renew the lease.
Your understanding is correct.
What's about min-renewal?
When the remaining validity time of your lease is less than 1 minute (say 30 seconds), then the calculated renewal time would be 30 seconds in the past (or now, as we cannot schedule things to happen in the past). min-renewal helps to debounce renewal requests. This is because, in such a scenario, refresh happens immediately.
Once renewed, SecretLeaseContainer schedules a subsequent renewal that reports a lease validity of slightly less than 30 seconds. We don't want to create a loop that hammers your Vault server with renewal requests if the remaining lease duration is less than expiry-threshold.
Example:
expiry-threshold: 60 seconds
min-renewal: 10 seconds
The following list of events shows with a time correlation what happens at which time assuming the TTL is final and cannot be extended:
10:00:00 Lease obtained. TTL 10 minutes (600 seconds). Schedule lease renewal in 9 minutes (10 minutes TTL - 1 minute expiry threshold -> 9 minutes)
10:09:00 Lease renewed. Remaining TTL 1 minute (60 seconds). Schedule lease renewal in 10 seconds (1 minute TTL - 1 minute expiry threshold -> 0 minutes. Fall back to 10 seconds min-renewal as that is the larger value -> 10 seconds).
10:09:10 Lease renewed. Remaining TTL 50 seconds. Schedule lease renewal in 10 seconds (50 seconds TTL - 1 minute expiry threshold -> -10 seconds. Fall back to 10 seconds min-renewal as that is the larger value -> 10 seconds).
(continue until reaching 10 seconds)
10:09:50 Lease renewed. Remaining TTL less than 10 seconds. Min-renewal is greater than the remaining TTL and the lease is considered expired.
Example where expiry threshold is greater than min-renewal:
expiry-threshold: 5 minutes (180 seconds)
min-renewal: 6 minutes (360 seconds)
The following list of events shows with a time correlation what happens at which time assuming the TTL is final and cannot be extended:
10:00:00 Lease obtained. TTL 10 minutes (600 seconds). Schedule lease renewal in 6 minutes (10 minutes TTL - 5 minute expiry threshold -> 5 minutes. Min-renewal is set to 6 minutes to issue a renewal at most once in 6 minutes -> 6 minutes)
10:06:00 Lease obtained. TTL 4 minutes (360 seconds). Schedule lease renewal in 6 minutes (4 minutes TTL - 5 minute expiry threshold -> -1 minutes. 6 minutes min-renewal as that is the is greater than the remaining TTL so the lease is considered expired)
Related
I'm trying to create a stop report for my plant while learning SQL.
The goal is to get a report containing the amount of minutes stopped planned and unplanned and the amount of stops planned and unplanned. All of this should be reported by day.
Currently I have these values:
Datum: Date
Unplanned: The amount of minutes our plant stopped that day when it was not planned
#unpplanned: the amount of stops we had that day that were unplanned
Daysunplanned: The amount of days the unplanned stop lasted
planned: The amount of minutes our plant stopped that day when it was planned
#planned: The amount of stops we had that day that were planned
dayspl: The amount of days the planned stop lasted
nextday: The amount of minutes that the stop took that should be counted to the next day. A stop can last from 20:00 7/02/2023 till 05:00 8/02/2023).
Can't embed yet :/
My issue is the following:
On 2023-02-06 the plant stopped 1130 minutes unplanned. The stop lasted till 07-02-2023. You can see this because dayunpla = 1.
So the results should be:
2023-02-07 1378
2023-02-06 1130
If dayunpla = 4 we should get:
2023-02-11 1378
2023-02-10 1440
2023-02-09 1440
2023-02-08 1440
2023-02-06 1130
1440 is 24 hours.
I can't think of a way to get from my current table to what I want.
I tried all google searches I could think of but did not find anything helpfull.
Is there a way to fix this using just SQL?
Thanks for your time!
Tried google and a lot of tinkering
Do you know how to convert this duration number 145351401 to days, hours, minutes and seconds in SQL?
I tried
SELECT CAST(STUFF(STUFF(STUFF(cast(145351401 as varchar),3,0,':'),6,0,':'),9,0,'.') AS TIME)
but it gave me the hours, minutes and seconds but no days.
The above number is the difference between the below two dates, so it should have something like 7 days and the hours, minutes and seconds in the duration.
2022-09-08 16:21:48.400
2022-09-16 07:22:31.400
I'm looking to only select values with columns x>0, y>0, z>0 if they are continuously like that for at least half the amount of time in a time interval to 2/3 of that time (interval being set by the user in a filter on a dashboard. So is from the current date to whenever they specify). The other proportion which could also be half the amount of time in the interval or 1/3 on the interval depending on the first condition, needs to have certain values as well like x= 0, y>0, z>0 for that period of time.
To re-iterate with example:
Condition 1: x>0, y>0, z>0 for minimum half the amount of time to max 2/3 in that time interval. ex. if range set by user is 14 days in filter, then needs to have those values continuously for minimum 7 days to a max of 9 days in those 14 days.
Condition 2: x= 0, y>0, z>0 for rest of remaining time which can be another half or 1/3 depending on how many days was in the first condition. ex. if range set by user is 14 days in filter, and condition 1 took up 8 days, then condition 2 has to have x=0, y>0, z>0 for 6 days continuously.
How to compare between current time and a past time in vb and check if the duration time is less than 30 mins or not ?
Example :
Current time : 11:30am
Time : 11:00am
Duration : 30 min (time should be less than 30 mins. )
If the time duration is exactly 30 min difference
Return true
Else false
If (Date.Now - myDateTime) < TimeSpan.FromMinutes(30) Then
'Time difference is less than 30 minutes.
End If
In that case, myDateTime may have been the value of Date.Now that you stored earlier or it may have been constructed in some other way.
Hmmm... I read the question again and it seems that you contradict yourself. First you say that you want to know whether the difference is less than 30 minutes and then you say that you want to return True if the difference is exactly 30 minutes. Perhaps you could make up your mind and get back to us because it's hard to provide a single answer to two contradictory questions.
How can I realize everyday local notifications in my app? So at first run I need to register first local notification at 14:00 and then everyday at 14:00 notification should appear.
User can change this time in app's settings.
How to do this mechanism?
You need to handle the notifcations on your end, but to make a timer that countsdown to a certain time every day, you would need to do something like this:
local targetDate = os.time{ year=2014, month=11, day=8, hour=0, sec=0 } -- Get the date that you want to count down to, in seconds
local text = false
local function enterFrame(event)
if text then text:removeSelf() end -- Everyframe, remove the old text object
local timeRemaining = (targetDate-os.time()) -- Take the difference between the target time and the current time
local days = timeRemaining / 86400 -- get the number of days left by dividing the remaining seconds by the number of seconds in a day
local hours = days%1 * 24 -- get the number of hours left by multiplying the remainder by the number hours in a day
local minutes = hours%1 * 60 -- get the number of minutes by multiplying the remainder by the number of minutes in an hour
local seconds = math.floor( minutes%1 * 60 + 0.5) -- multiply the remainder one more time by the number of seconds in a minute, and round to the nearest second.
-- make a new text object to display all the info
text = display.newText( "Will be available in "..math.floor(days).." days "..math.floor(hours).." hrs "..math.floor(minutes).." mins "..seconds.." secs ", 25, 140)
end
Runtime:addEventListener( "enterFrame", enterFrame )
You can repurpose your code to work with your project, but you need to use OS time and do certain calculations to each variable in order to get the time. Good luck.