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

chore(web&server): database repair, rollback on dependency restart... #2017

Merged
merged 9 commits into from
Jun 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class DedicatedDatabaseService {
limitMemory,
requestCPU,
requestMemory,
capacity,
capacity: capacity / 1024,
replicas,
})

Expand Down Expand Up @@ -200,6 +200,7 @@ export class DedicatedDatabaseService {
options: {
authSource: 'admin',
replicaSet: `${name}-mongodb`,
readPreference: 'secondaryPreferred',
w: 'majority',
},
scheme: 'mongodb',
Expand Down
21 changes: 9 additions & 12 deletions server/src/dependency/dependency.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ export class DependencyService {
const new_deps = dto.map((dep) => `${dep.name}@${dep.spec}`)
const deps = extras.concat(new_deps)

const res = await this.db
await this.db
.collection<ApplicationConfiguration>('ApplicationConfiguration')
.findOneAndUpdate(
.updateOne(
{ appid },
{ $set: { dependencies: deps, updatedAt: new Date() } },
{ returnDocument: 'after' },
)
await this.confService.publish(res.value)

return true
}

Expand All @@ -87,14 +86,13 @@ export class DependencyService {

const deps = filtered.concat(new_deps)

const res = await this.db
await this.db
.collection<ApplicationConfiguration>('ApplicationConfiguration')
.findOneAndUpdate(
.updateOne(
{ appid },
{ $set: { dependencies: deps, updatedAt: new Date() } },
{ returnDocument: 'after' },
)
await this.confService.publish(res.value)

return true
}

Expand All @@ -107,14 +105,13 @@ export class DependencyService {

if (filtered.length === deps.length) return false

const res = await this.db
await this.db
.collection<ApplicationConfiguration>('ApplicationConfiguration')
.findOneAndUpdate(
.updateOne(
{ appid },
{ $set: { dependencies: filtered, updatedAt: new Date() } },
{ returnDocument: 'after' },
)
await this.confService.publish(res.value)

return true
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/initializer/deploy-manifest/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: <%- capacity %>Mi
storage: <%- capacity %>Gi
terminationPolicy: Delete
tolerations: []
6 changes: 3 additions & 3 deletions server/src/instance/instance-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ export class InstanceTaskService {
return
}

// create instance
await this.instanceService.create(app.appid)

const appid = app.appid

const ddb = await this.dedicatedDatabaseService.findOne(appid)
Expand All @@ -152,6 +149,9 @@ export class InstanceTaskService {
}
}

// create instance
await this.instanceService.create(app.appid)

const instance = await this.instanceService.get(appid)
const unavailable =
instance.deployment?.status?.unavailableReplicas || false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export default function DatabaseMonitor() {
metric: Record<string, string>;
values: Array<[number, string]>;
}[] = resourceData?.data?.memory;

const podList = useMemo(() => {
if (!cpuData || !memoryData) return [];
const cpuPods = cpuData.map((item) => item.metric.pod);
const memoryPods = memoryData.map((item) => item.metric.pod);

Expand Down
Loading