Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nmaas Platform
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nmaas
nmaas Platform
Commits
f408f8db
Commit
f408f8db
authored
11 months ago
by
kbeyro
Browse files
Options
Downloads
Patches
Plain Diff
Delete base when all the versions are set to DELETED
parent
2534d8bf
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!10
Remove app instances on base removal
Pipeline
#87464
passed
11 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/geant/nmaas/portal/api/market/ApplicationController.java
+20
-14
20 additions, 14 deletions
.../geant/nmaas/portal/api/market/ApplicationController.java
with
20 additions
and
14 deletions
src/main/java/net/geant/nmaas/portal/api/market/ApplicationController.java
+
20
−
14
View file @
f408f8db
...
@@ -10,12 +10,7 @@ import net.geant.nmaas.notifications.MailAttributes;
...
@@ -10,12 +10,7 @@ import net.geant.nmaas.notifications.MailAttributes;
import
net.geant.nmaas.notifications.NotificationEvent
;
import
net.geant.nmaas.notifications.NotificationEvent
;
import
net.geant.nmaas.notifications.templates.MailType
;
import
net.geant.nmaas.notifications.templates.MailType
;
import
net.geant.nmaas.orchestration.AppLifecycleManager
;
import
net.geant.nmaas.orchestration.AppLifecycleManager
;
import
net.geant.nmaas.portal.api.domain.AppRateView
;
import
net.geant.nmaas.portal.api.domain.*
;
import
net.geant.nmaas.portal.api.domain.ApplicationBaseView
;
import
net.geant.nmaas.portal.api.domain.ApplicationStateChangeRequest
;
import
net.geant.nmaas.portal.api.domain.ApplicationView
;
import
net.geant.nmaas.portal.api.domain.Id
;
import
net.geant.nmaas.portal.api.domain.UserView
;
import
net.geant.nmaas.portal.api.exception.MarketException
;
import
net.geant.nmaas.portal.api.exception.MarketException
;
import
net.geant.nmaas.portal.api.exception.MissingElementException
;
import
net.geant.nmaas.portal.api.exception.MissingElementException
;
import
net.geant.nmaas.portal.api.exception.ProcessingException
;
import
net.geant.nmaas.portal.api.exception.ProcessingException
;
...
@@ -73,6 +68,8 @@ public class ApplicationController extends AppBaseController {
...
@@ -73,6 +68,8 @@ public class ApplicationController extends AppBaseController {
private
final
AppLifecycleManager
appLifecycleManager
;
private
final
AppLifecycleManager
appLifecycleManager
;
private
final
AppInstanceController
appInstanceController
;
/*
/*
* Application Base Part
* Application Base Part
*/
*/
...
@@ -151,14 +148,8 @@ public class ApplicationController extends AppBaseController {
...
@@ -151,14 +148,8 @@ public class ApplicationController extends AppBaseController {
ApplicationState
state
=
ApplicationState
.
DELETED
;
ApplicationState
state
=
ApplicationState
.
DELETED
;
for
(
ApplicationVersion
appVersion
:
base
.
getVersions
())
{
for
(
ApplicationVersion
appVersion
:
base
.
getVersions
())
{
Application
app
=
getApp
(
appVersion
.
getAppVersionId
());
Application
app
=
getApp
(
appVersion
.
getAppVersionId
());
applicationService
.
changeApplicationState
(
app
,
state
);
if
(
app
.
getState
()
!=
ApplicationState
.
DELETED
)
throw
new
ProcessingException
(
"Can not delete base, version "
+
app
.
getVersion
()
+
" is not deleted"
);
List
<
AppInstance
>
instanceList
=
applicationInstanceService
.
findAllByApplication
(
app
);
instanceList
.
forEach
(
instance
->
{
appLifecycleManager
.
removeApplication
(
instance
.
getInternalId
());
});
appVersion
.
setState
(
state
);
}
}
appBaseService
.
deleteAppBase
(
base
);
appBaseService
.
deleteAppBase
(
base
);
}
}
...
@@ -323,8 +314,23 @@ public class ApplicationController extends AppBaseController {
...
@@ -323,8 +314,23 @@ public class ApplicationController extends AppBaseController {
@PatchMapping
(
value
=
"/state/{id}"
)
@PatchMapping
(
value
=
"/state/{id}"
)
@PreAuthorize
(
"hasRole('ROLE_SYSTEM_ADMIN')"
)
@PreAuthorize
(
"hasRole('ROLE_SYSTEM_ADMIN')"
)
@Transactional
@Transactional
public
void
changeApplicationState
(
@PathVariable
long
id
,
@RequestBody
ApplicationStateChangeRequest
stateChangeRequest
)
{
public
void
changeApplicationState
(
@PathVariable
long
id
,
@RequestBody
ApplicationStateChangeRequest
stateChangeRequest
,
Principal
principal
)
{
Application
app
=
getApp
(
id
);
Application
app
=
getApp
(
id
);
if
(
stateChangeRequest
.
getState
().
equals
(
ApplicationState
.
DELETED
))
{
applicationInstanceService
.
findAllByApplication
(
app
).
forEach
(
ai
->
{
AppInstanceStatus
instanceState
=
appInstanceController
.
getState
(
ai
.
getId
(),
principal
);
int
numberOfRunningInstances
=
0
;
if
(!(
instanceState
.
getState
().
equals
(
AppInstanceState
.
DONE
)
||
instanceState
.
getState
().
equals
(
AppInstanceState
.
FAILURE
)
||
instanceState
.
getState
().
equals
(
AppInstanceState
.
REMOVED
)
))
{
numberOfRunningInstances
=
+
1
;
}
if
(
numberOfRunningInstances
>
0
)
{
throw
new
ProcessingException
(
"Can not delete app version. You still have "
+
numberOfRunningInstances
+
" running instances of this version."
);
}
}
);
}
applicationService
.
changeApplicationState
(
app
,
stateChangeRequest
.
getState
());
applicationService
.
changeApplicationState
(
app
,
stateChangeRequest
.
getState
());
appBaseService
.
updateApplicationVersionState
(
app
.
getName
(),
app
.
getVersion
(),
stateChangeRequest
.
getState
());
appBaseService
.
updateApplicationVersionState
(
app
.
getName
(),
app
.
getVersion
(),
stateChangeRequest
.
getState
());
this
.
sendMails
(
app
,
stateChangeRequest
);
this
.
sendMails
(
app
,
stateChangeRequest
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment