Skip to content

Commit a048132

Browse files
fix: [UIE-8446] - restore backup date and time fix (#11628)
* fix: [UIE-8446] - restore backup time fix * Added changeset: Database restore backup timezone inconsistency * fix: [UIE-8446] - update CHANGELOG * fix: [UIE-8446] - update CHANGELOG
1 parent 15b219b commit a048132

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

packages/manager/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2929

3030
- Buggy Copy Token behavior on LKE details page ([#11592](https://github.com/linode/manager/pull/11592))
3131
- Longview Detail id param not found (local only) ([#11599](https://github.com/linode/manager/pull/11599))
32+
- Database restore backup timezone inconsistency ([#11628](https://github.com/linode/manager/pull/11628))
3233

3334
### Tech Stories:
3435

packages/manager/src/features/Databases/DatabaseDetail/DatabaseBackups/DatabaseBackups.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const DatabaseBackups = (props: Props) => {
102102
const isDefaultDatabase = database?.platform === 'rdbms-default';
103103

104104
const oldestBackup = database?.oldest_restore_time
105-
? DateTime.fromISO(database.oldest_restore_time)
105+
? DateTime.fromISO(`${database.oldest_restore_time}Z`)
106106
: null;
107107

108108
const unableToRestoreCopy = !oldestBackup
@@ -206,6 +206,9 @@ export const DatabaseBackups = (props: Props) => {
206206
<FormControl style={{ marginTop: 0 }}>
207207
{/* TODO: Replace Time Select to the own custom date-time picker component when it's ready */}
208208
<Autocomplete
209+
disabled={
210+
disabled || !selectedDate || versionOption === 'newest'
211+
}
209212
getOptionDisabled={(option) =>
210213
isTimeOutsideBackup(
211214
option.value,
@@ -231,9 +234,6 @@ export const DatabaseBackups = (props: Props) => {
231234
}}
232235
autoComplete={false}
233236
className={classes.timeAutocomplete}
234-
disabled={
235-
disabled || !selectedDate || versionOption === 'newest'
236-
}
237237
label=""
238238
onChange={(_, newTime) => setSelectedTime(newTime)}
239239
options={TIME_OPTIONS}

packages/manager/src/features/Databases/utilities.test.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
isDefaultDatabase,
1414
isLegacyDatabase,
1515
isTimeOutsideBackup,
16+
toFormatedDate,
1617
toISOString,
1718
upgradableVersions,
1819
useIsDatabasesEnabled,
@@ -359,30 +360,46 @@ describe('isDateOutsideBackup', () => {
359360
describe('isTimeOutsideBackup', () => {
360361
it('should return true when hour + selected date is before oldest backup', () => {
361362
const selectedDate = DateTime.fromISO('2024-10-02');
362-
const oldestBackup = DateTime.fromISO('2024-10-02T09:00:00');
363+
const oldestBackup = DateTime.fromISO('2024-10-02T09:00:00Z');
363364
const result = isTimeOutsideBackup(8, selectedDate, oldestBackup);
364365
expect(result).toEqual(true);
365366
});
366367

367368
it('should return false when hour + selected date is equal to the oldest backup', () => {
368369
const selectedDate = DateTime.fromISO('2024-10-02');
369-
const oldestBackup = DateTime.fromISO('2024-10-02T09:00:00');
370+
const oldestBackup = DateTime.fromISO('2024-10-02T09:00:00Z');
370371
const result = isTimeOutsideBackup(9, selectedDate, oldestBackup);
371372
expect(result).toEqual(false);
372373
});
373374

374375
it('should return false when hour + selected date is after the oldest backup', () => {
375376
const selectedDate = DateTime.fromISO('2024-10-03');
376-
const oldestBackup = DateTime.fromISO('2024-10-02T09:00:00');
377+
const oldestBackup = DateTime.fromISO('2024-10-02T09:00:00Z');
377378
const result = isTimeOutsideBackup(1, selectedDate, oldestBackup);
378379
expect(result).toEqual(false);
379380
});
380381
});
381382

383+
describe('toFormatedDate', () => {
384+
it('should convert a date and time to the format YYYY-MM-DD HH:mm for the dialog', () => {
385+
const selectedDate = DateTime.fromObject({ day: 15, month: 1, year: 2025 });
386+
const selectedTime: TimeOption = { label: '14:00', value: 14 };
387+
const result = toFormatedDate(selectedDate, selectedTime.value);
388+
expect(result).toContain('2025-01-15 14:00');
389+
});
390+
it('should handle newest full backup plus incremental option correctly in UTC', () => {
391+
const selectedDate = null;
392+
const today = DateTime.utc();
393+
const mockTodayWithHours = `${today.toISODate()} ${today.hour}:00`;
394+
const result = toFormatedDate(selectedDate, undefined);
395+
expect(result).toContain(mockTodayWithHours);
396+
});
397+
});
398+
382399
describe('toISOString', () => {
383400
it('should convert a date and time to ISO string format', () => {
384401
const selectedDate = DateTime.fromObject({ day: 15, month: 5, year: 2023 });
385-
const selectedTime: TimeOption = { label: '02:00', value: 14 };
402+
const selectedTime: TimeOption = { label: '14:00', value: 14 };
386403
const result = toISOString(selectedDate, selectedTime.value);
387404
expect(result).toContain('2023-05-15T14:00');
388405
});

packages/manager/src/features/Databases/utilities.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const isDateOutsideBackup = (
128128
if (!oldestBackup) {
129129
return true;
130130
}
131-
const today = DateTime.now();
131+
const today = DateTime.utc();
132132
return date < oldestBackup || date > today;
133133
};
134134

@@ -169,10 +169,10 @@ export const toSelectedDateTime = (
169169
time: number = 0
170170
) => {
171171
const isoDate = selectedDate?.toISODate();
172-
const isoTime = DateTime.now()
172+
const isoTime = DateTime.utc()
173173
.set({ hour: time, minute: 0 })
174174
?.toISOTime({ includeOffset: false });
175-
return DateTime.fromISO(`${isoDate}T${isoTime}`);
175+
return DateTime.fromISO(`${isoDate}T${isoTime}`, { zone: 'UTC' });
176176
};
177177

178178
/**
@@ -187,7 +187,7 @@ export const toFormatedDate = (
187187
selectedDate?: DateTime | null,
188188
selectedTime?: number
189189
) => {
190-
const today = DateTime.now();
190+
const today = DateTime.utc();
191191
const isoDate =
192192
selectedDate && selectedTime
193193
? toISOString(selectedDate!, selectedTime)

packages/manager/src/features/GlobalNotifications/DatabaseMigrationInfoBanner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export const DatabaseMigrationInfoBanner = () => {
1010
Legacy clusters decommission
1111
</Typography>
1212
<Typography lineHeight="20px">
13-
Legacy database clusters will only be available until the end of 2025.
14-
At that time, we’ll migrate your clusters to the new solution. For
13+
Legacy database clusters will only be available until the end of June
14+
2025. At that time, we’ll migrate your clusters to the new solution. For
1515
questions regarding the new database clusters or the migration,{' '}
1616
<SupportLink entity={{ type: 'database_id' }} text="contact support" />.
1717
</Typography>

0 commit comments

Comments
 (0)