Skip to content

Commit

Permalink
fix registry sync & fsm issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangcheng870518 committed Jan 26, 2023
1 parent 570b0b3 commit afa290d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/server/api/registry/controllers/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ module.exports = {

async refresh(ctx) {
const result = await strapi.controllers.registry.update(ctx);
try {
ctx.headers.schema_id = ctx.request.body.input.where.id;
ctx.headers.namespace = '_all';
ctx.headers.schema_type = 'k8s';
await strapi.services.service.fetchServices(ctx);
} catch {
}
return {
registry: result,
};
Expand Down
10 changes: 8 additions & 2 deletions packages/server/config/functions/kubeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ module.exports = {
name: item.metadata.namespace,
});
data.namespace = ns.id;
} else if (type == 'service') {
const ns = await strapi.query('namespace').findOne({
registry: k8s_cluster_id,
name: item.metadata.namespace,
});
data.ns = ns.id;
}

await strapi.query(type).create(data);
Expand All @@ -123,9 +129,9 @@ module.exports = {
const json = YAML.parse(reg.config)
const context = json.contexts.find((e) => e.name == json['current-context']);
const cluster = json.clusters.find((e) => e.name == context.context.cluster);
const user = json.users.find((e) => e.name == context.user);
const user = json.users.find((e) => e.name == context.context.user);

if (user.user.token) {
if (user?.user?.token) {
return axios.create({
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
baseURL: cluster.cluster.server,
Expand Down

0 comments on commit afa290d

Please sign in to comment.