Skip to content

Commit 52af20d

Browse files
committed
minor bugfixes
1 parent 34f9207 commit 52af20d

File tree

5 files changed

+22
-53
lines changed

5 files changed

+22
-53
lines changed

server/config/serverconfiguartions/haproxy.cfg

-36
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ frontend fe_https
3636

3737
use_backend bac_web_systemconfig if { hdr(host) -i havrak.xyz }
3838
use_backend bac_web_c203 if { hdr(host) -i otesanek.LiMItYNeMuZOubYTnUloVe.krystof.havranek.havrak.xyz }
39-
use_backend bac_web_c211 if { hdr(host) -i Container1.Projectwithlimits.vladimir.vavra.havrak.xyz }
40-
use_backend bac_web_c212 if { hdr(host) -i Container3.Projectwithoutlimits.vladimir.vavra.havrak.xyz }
4139

4240

4341
frontend fe_http
@@ -46,8 +44,6 @@ frontend fe_http
4644

4745
use_backend bac_web_systemconfig if { hdr(host) -i havrak.xyz }
4846
use_backend bac_web_c203 if { hdr(host) -i otesanek.LiMItYNeMuZOubYTnUloVe.krystof.havranek.havrak.xyz }
49-
use_backend bac_web_c211 if { hdr(host) -i Container1.Projectwithlimits.vladimir.vavra.havrak.xyz }
50-
use_backend bac_web_c212 if { hdr(host) -i Container3.Projectwithoutlimits.vladimir.vavra.havrak.xyz }
5147

5248

5349
frontend fe_rest
@@ -59,8 +55,6 @@ frontend fe_rest
5955

6056
use_backend bac_rest_systemconfig if { hdr(host) -i havrak.xyz }
6157
use_backend bac_rest_c203 if { hdr(host) -i otesanek.LiMItYNeMuZOubYTnUloVe.krystof.havranek.havrak.xyz }
62-
use_backend bac_rest_c211 if { hdr(host) -i Container1.Projectwithlimits.vladimir.vavra.havrak.xyz }
63-
use_backend bac_rest_c212 if { hdr(host) -i Container3.Projectwithoutlimits.vladimir.vavra.havrak.xyz }
6458

6559

6660
frontend fe_ssh
@@ -69,8 +63,6 @@ frontend fe_ssh
6963
tcp-request content set-var(sess.dst) ssl_fc_sni
7064

7165
use_backend bac_ssh_c203 if { var(sess.dst) -i otesanek.LiMItYNeMuZOubYTnUloVe.krystof.havranek.havrak.xyz }
72-
use_backend bac_ssh_c211 if { var(sess.dst) -i Container1.Projectwithlimits.vladimir.vavra.havrak.xyz }
73-
use_backend bac_ssh_c212 if { var(sess.dst) -i Container3.Projectwithoutlimits.vladimir.vavra.havrak.xyz }
7466

7567

7668
backend bac_web_systemconfig
@@ -83,16 +75,6 @@ backend bac_web_c203
8375
redirect scheme https if !{ ssl_fc }
8476
server c203 c203.lxd:80 check
8577

86-
backend bac_web_c211
87-
http-request set-header X-Client-IP %[src]
88-
redirect scheme https if !{ ssl_fc }
89-
server c211 c211.lxd:80 check
90-
91-
backend bac_web_c212
92-
http-request set-header X-Client-IP %[src]
93-
redirect scheme https if !{ ssl_fc }
94-
server c212 c212.lxd:80 check
95-
9678

9779
backend bac_rest_systemconfig
9880
http-request set-header X-Client-IP %[src]
@@ -104,25 +86,7 @@ backend bac_rest_c203
10486
redirect scheme https if !{ ssl_fc }
10587
server c203 c203.lxd:3000 check
10688

107-
backend bac_rest_c211
108-
http-request set-header X-Client-IP %[src]
109-
redirect scheme https if !{ ssl_fc }
110-
server c211 c211.lxd:3000 check
111-
112-
backend bac_rest_c212
113-
http-request set-header X-Client-IP %[src]
114-
redirect scheme https if !{ ssl_fc }
115-
server c212 c212.lxd:3000 check
116-
11789

11890
backend bac_ssh_c203
11991
mode tcp
12092
server c203 c203.lxd:22 check
121-
122-
backend bac_ssh_c211
123-
mode tcp
124-
server c211 c211.lxd:22 check
125-
126-
backend bac_ssh_c212
127-
mode tcp
128-
server c212 c212.lxd:22 check

server/src/routes/apiRoute.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,17 @@ app.patch(
382382
projectSQL
383383
.updateProjectLimits(req.body, req.params.projectId, req.user.email)
384384
.then((result) => {
385-
if (result.haproxy) reloadHaproxy();
386-
getProjectObject(req.params.projectId).then((result) => {
387-
if (result.statusCode && result.statusCode != 200)
388-
res.status(400).send({ message: result.status });
389-
res.send(result);
390-
});
385+
if (result.statusCode == 400) {
386+
res.statusCode == 400;
387+
res.send({ message: result.status });
388+
} else {
389+
if (result.haproxy) reloadHaproxy();
390+
getProjectObject(req.params.projectId).then((result) => {
391+
if (result.statusCode && result.statusCode != 200)
392+
res.status(400).send({ message: result.status });
393+
res.send(result);
394+
});
395+
}
391396
});
392397
}
393398
);

server/src/services/routeHelpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export function reloadHaproxy() {
164164
.execInstance(
165165
"haproxy",
166166
"default",
167-
["sleep 5; systemctl reload haproxy.service"], // it takes a little bit of time for new container to react
167+
"sleep 5; systemctl reload haproxy.service", // it takes a little bit of time for new container to react
168168
false
169169
)
170170
.then((result) => {

server/src/services/sql/projectSQL.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default class projectSQL {
5454
userLimits.internet.upload -= rows[i].upload;
5555
userLimits.internet.download -= rows[i].download;
5656
if (++counter == desiredCount) {
57+
console.log(resolve);
5758
con.end();
5859
resolve(userLimits);
5960
}
@@ -63,7 +64,6 @@ export default class projectSQL {
6364
[rows[i].project_id],
6465
(err, rows) => {
6566
if (err) throw err;
66-
counter++;
6767
if (rows[0] != undefined) {
6868
rows[0].forEach((row) => {
6969
userLimits.RAM -= row.ram;
@@ -135,14 +135,14 @@ export default class projectSQL {
135135
downloadChange >= 0
136136
) {
137137
this.createCreateProjectData(email).then((result) => {
138+
console.log(result);
138139
if (
139140
ramChange <= result.RAM &&
140141
cpuChange <= result.CPU &&
141142
diskChange <= result.disk &&
142143
uploadChange <= result.internet.upload &&
143144
downloadChange <= result.internet.download
144145
) {
145-
console.log(id);
146146
con.query(
147147
"UPDATE projectsResourcesLimits SET ram=?, cpu=?, disk=?, upload=?, download=? WHERE project_id=?",
148148
[
@@ -155,7 +155,7 @@ export default class projectSQL {
155155
],
156156
(err, rows) => {
157157
if (err) throw err;
158-
console.log("update sucessfull");
158+
console.log("update successful");
159159
resolve({
160160
status: "Limits successfully updated",
161161
statusCode: 200,

testClient/src/appPatchLimitsProject.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
const https = require("http");
22

3-
const route = "/api/projects/69";
3+
const route = "/api/projects/82";
44
const data = JSON.stringify({
5-
name: "LiMItY NeMuZOu bYT nUloVe",
5+
name: "cool coo2l",
66
limits: {
7-
RAM: 1610612931,
8-
CPU: 2200000000,
9-
disk: 8589934692,
7+
RAM: 2,
8+
CPU: 2,
9+
disk: 2,
1010
internet: {
11-
download: 800020,
12-
upload: 800020,
11+
download: 20,
12+
upload: 20,
1313
},
1414
},
1515
});

0 commit comments

Comments
 (0)