Skip to content

Commit

Permalink
setMilisecs in point in time recovery
Browse files Browse the repository at this point in the history
Signed-off-by: SayedTahsin <[email protected]>
  • Loading branch information
SayedTahsin committed Dec 10, 2024
1 parent 7edff83 commit 0454170
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 15 deletions.
1 change: 1 addition & 0 deletions charts/kubedbcom-mariadb-editor-options/ui/create-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ steps:
- customClass: mt-10
label:
text: Recovery Timestamp
onChange: setMiliSeconds
schema:
$ref: schema#/properties/spec/properties/init/properties/archiver/properties/recoveryTimestamp
type: input
Expand Down
27 changes: 24 additions & 3 deletions charts/kubedbcom-mariadb-editor-options/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,7 @@ function getDefault({ getValue, model }, type) {
return val
}

let recoveryTimestampMiliSec = '000Z'
async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator, getValue }) {
const owner = storeGet('/route/params/user')
const cluster = storeGet('/route/params/cluster')
Expand Down Expand Up @@ -1051,20 +1052,25 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
})

const resp = snapshotsResp.data.status?.components['wal-rs0']?.walSegments[0]
const recoveryTimestampArray = resp?.end.split('.')

if (recoveryTimestampArray.length === 2) {
recoveryTimestampMiliSec = recoveryTimestampArray[1]
}

commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/minDate`,
value: resp.start.slice(0, -1),
value: resp?.start.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/maxDate`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
} catch (e) {
Expand All @@ -1087,7 +1093,22 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
}
}

function setMiliSeconds({ model, getValue, commit }) {
const recoveryTimestamp = getValue(model, '/spec/init/archiver/recoveryTimestamp')
const recoveryTimestampArray = recoveryTimestamp?.split('.')
if (recoveryTimestampArray.length === 1) return
if (recoveryTimestampMiliSec !== '000Z') {
console.log(recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1))
commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1),
force: true,
})
recoveryTimestampMiliSec = '000Z'
}
}
return {
setMiliSeconds,
setPointInTimeRecovery,
isClusterRancherManaged,
getRecoveryNames,
Expand Down
1 change: 1 addition & 0 deletions charts/kubedbcom-mongodb-editor-options/ui/create-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ steps:
- customClass: mt-10
label:
text: Recovery Timestamp
onChange: setMiliSeconds
schema:
$ref: schema#/properties/spec/properties/init/properties/archiver/properties/recoveryTimestamp
type: input
Expand Down
28 changes: 25 additions & 3 deletions charts/kubedbcom-mongodb-editor-options/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ function getDefault({ getValue, model }, type) {
return val
}

let recoveryTimestampMiliSec = '000Z'
async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator, getValue }) {
const owner = storeGet('/route/params/user')
const cluster = storeGet('/route/params/cluster')
Expand Down Expand Up @@ -1174,20 +1175,25 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
})

const resp = snapshotsResp.data.status?.components['wal-rs0']?.walSegments[0]
const recoveryTimestampArray = resp?.end.split('.')

if (recoveryTimestampArray.length === 2) {
recoveryTimestampMiliSec = recoveryTimestampArray[1]
}

commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/minDate`,
value: resp.start.slice(0, -1),
value: resp?.start.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/maxDate`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
} catch (e) {
Expand All @@ -1210,7 +1216,23 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
}
}

function setMiliSeconds({ model, getValue, commit }) {
const recoveryTimestamp = getValue(model, '/spec/init/archiver/recoveryTimestamp')
const recoveryTimestampArray = recoveryTimestamp?.split('.')
if (recoveryTimestampArray.length === 1) return
if (recoveryTimestampMiliSec !== '000Z') {
console.log(recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1))
commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1),
force: true,
})
recoveryTimestampMiliSec = '000Z'
}
}

return {
setMiliSeconds,
setPointInTimeRecovery,
checkHostnameOrIP,
isClusterRancherManaged,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ steps:
- customClass: mt-10
label:
text: Recovery Timestamp
onChange: setMiliSeconds
schema:
$ref: schema#/properties/spec/properties/init/properties/archiver/properties/recoveryTimestamp
type: input
Expand Down
27 changes: 24 additions & 3 deletions charts/kubedbcom-mssqlserver-editor-options/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ function onCustomPidChange({ getValue, discriminator, commit }) {
})
}

let recoveryTimestampMiliSec = '000Z'
async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator, getValue }) {
const owner = storeGet('/route/params/user')
const cluster = storeGet('/route/params/cluster')
Expand Down Expand Up @@ -1084,20 +1085,25 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
})

const resp = snapshotsResp.data.status?.components['wal-rs0']?.walSegments[0]
const recoveryTimestampArray = resp?.end.split('.')

if (recoveryTimestampArray.length === 2) {
recoveryTimestampMiliSec = recoveryTimestampArray[1]
}

commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/minDate`,
value: resp.start.slice(0, -1),
value: resp?.start.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/maxDate`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
} catch (e) {
Expand All @@ -1120,7 +1126,22 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
}
}

function setMiliSeconds({ model, getValue, commit }) {
const recoveryTimestamp = getValue(model, '/spec/init/archiver/recoveryTimestamp')
const recoveryTimestampArray = recoveryTimestamp?.split('.')
if (recoveryTimestampArray.length === 1) return
if (recoveryTimestampMiliSec !== '000Z') {
console.log(recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1))
commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1),
force: true,
})
recoveryTimestampMiliSec = '000Z'
}
}
return {
setMiliSeconds,
setPointInTimeRecovery,
isClusterRancherManaged,
getRecoveryNames,
Expand Down
1 change: 1 addition & 0 deletions charts/kubedbcom-mysql-editor-options/ui/create-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ steps:
- customClass: mt-10
label:
text: Recovery Timestamp
onChange: setMiliSeconds
schema:
$ref: schema#/properties/spec/properties/init/properties/archiver/properties/recoveryTimestamp
type: input
Expand Down
28 changes: 25 additions & 3 deletions charts/kubedbcom-mysql-editor-options/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ function getDefault({ getValue, model }, type) {
return val
}

let recoveryTimestampMiliSec = '000Z'
async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator, getValue }) {
const owner = storeGet('/route/params/user')
const cluster = storeGet('/route/params/cluster')
Expand Down Expand Up @@ -1050,20 +1051,25 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
})

const resp = snapshotsResp.data.status?.components['wal-rs0']?.walSegments[0]
const recoveryTimestampArray = resp?.end.split('.')

if (recoveryTimestampArray.length === 2) {
recoveryTimestampMiliSec = recoveryTimestampArray[1]
}

commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/minDate`,
value: resp.start.slice(0, -1),
value: resp?.start.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/maxDate`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
} catch (e) {
Expand All @@ -1086,7 +1092,23 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
}
}

function setMiliSeconds({ model, getValue, commit }) {
const recoveryTimestamp = getValue(model, '/spec/init/archiver/recoveryTimestamp')
const recoveryTimestampArray = recoveryTimestamp?.split('.')
if (recoveryTimestampArray.length === 1) return
if (recoveryTimestampMiliSec !== '000Z') {
console.log(recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1))
commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1),
force: true,
})
recoveryTimestampMiliSec = '000Z'
}
}

return {
setMiliSeconds,
setPointInTimeRecovery,
isClusterRancherManaged,
getRecoveryNames,
Expand Down
1 change: 1 addition & 0 deletions charts/kubedbcom-postgres-editor-options/ui/create-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ steps:
- customClass: mt-10
label:
text: Recovery Timestamp
onChange: setMiliSeconds
schema:
$ref: schema#/properties/spec/properties/init/properties/archiver/properties/recoveryTimestamp
type: input
Expand Down
28 changes: 25 additions & 3 deletions charts/kubedbcom-postgres-editor-options/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ function getDefault({ getValue, model }, type) {
return val
}

let recoveryTimestampMiliSec = '000Z'
async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator, getValue }) {
const owner = storeGet('/route/params/user')
const cluster = storeGet('/route/params/cluster')
Expand Down Expand Up @@ -1242,20 +1243,25 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
})

const resp = snapshotsResp.data.status?.components['wal-rs0']?.walSegments[0]
const recoveryTimestampArray = resp?.end.split('.')

if (recoveryTimestampArray.length === 2) {
recoveryTimestampMiliSec = recoveryTimestampArray[1]
}

commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/minDate`,
value: resp.start.slice(0, -1),
value: resp?.start.slice(0, -1),
force: true,
})
commit('wizard/model$update', {
path: `/maxDate`,
value: resp.end.slice(0, -1),
value: resp?.end.slice(0, -1),
force: true,
})
} catch (e) {
Expand All @@ -1278,7 +1284,23 @@ async function setPointInTimeRecovery({ commit, axios, storeGet, discriminator,
}
}

function setMiliSeconds({ model, getValue, commit }) {
const recoveryTimestamp = getValue(model, '/spec/init/archiver/recoveryTimestamp')
const recoveryTimestampArray = recoveryTimestamp?.split('.')
if (recoveryTimestampArray.length === 1) return
if (recoveryTimestampMiliSec !== '000Z') {
console.log(recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1))
commit('wizard/model$update', {
path: `/spec/init/archiver/recoveryTimestamp`,
value: recoveryTimestampArray[0] + '.' + recoveryTimestampMiliSec.slice(0, -1),
force: true,
})
recoveryTimestampMiliSec = '000Z'
}
}

return {
setMiliSeconds,
setPointInTimeRecovery,
isClusterRancherManaged,
getRecoveryNames,
Expand Down

0 comments on commit 0454170

Please sign in to comment.