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
432220be
Commit
432220be
authored
4 weeks ago
by
Lukasz Lopatowski
Browse files
Options
Downloads
Patches
Plain Diff
Minor update of RemoteClusterManager
parent
9aeccfee
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#94341
passed
4 weeks ago
Stage: test
Stage: sonar
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/geant/nmaas/externalservices/kubernetes/RemoteClusterManager.java
+21
-22
21 additions, 22 deletions
...aas/externalservices/kubernetes/RemoteClusterManager.java
with
21 additions
and
22 deletions
src/main/java/net/geant/nmaas/externalservices/kubernetes/RemoteClusterManager.java
+
21
−
22
View file @
432220be
...
...
@@ -105,12 +105,24 @@ public class RemoteClusterManager implements ClusterMonitoringService {
log
.
debug
(
"Filed saved in: {}"
,
savedPath
);
entity
.
setPathConfigFile
(
savedPath
);
KCluster
cluster
=
this
.
clusterRepository
.
save
(
entity
);
log
.
debug
(
"Cluster saved: {}"
,
cluster
.
toString
()
);
KCluster
cluster
=
clusterRepository
.
save
(
entity
);
log
.
debug
(
"Cluster saved: {}"
,
cluster
);
sendMail
(
cluster
,
MailType
.
REMOTE_CLUSTER_WELCOME_SUPPORT
);
return
toView
(
cluster
);
}
private
void
checkRequest
(
KCluster
entity
)
{
if
(
entity
.
getName
()
==
null
)
{
throw
new
IllegalArgumentException
(
"Name of the cluster is null"
);
}
if
(
entity
.
getCodename
()
==
null
)
{
throw
new
IllegalArgumentException
(
"Codename of the cluster is null"
);
}
if
(
entity
.
getDescription
()
==
null
)
{
throw
new
IllegalArgumentException
(
"Description of the cluster is null"
);
}
}
public
RemoteClusterView
readClusterFile
(
RemoteClusterView
view
,
MultipartFile
file
)
{
checkRequest
(
view
);
...
...
@@ -139,7 +151,7 @@ public class RemoteClusterManager implements ClusterMonitoringService {
.
state
(
KClusterState
.
UNKNOWN
)
.
contactEmail
(
view
.
getContactEmail
())
.
currentStateSince
(
OffsetDateTime
.
now
())
.
domains
(!
view
.
getDomainNames
().
isEmpty
()
?
view
.
getDomainNames
().
stream
().
map
(
d
->
{
.
domains
(!
view
.
getDomainNames
().
isEmpty
()
?
view
.
getDomainNames
().
stream
().
map
(
d
->
{
Optional
<
Domain
>
dom
=
domainService
.
findDomain
(
d
);
return
dom
.
orElse
(
null
);
}
...
...
@@ -200,18 +212,6 @@ public class RemoteClusterManager implements ClusterMonitoringService {
}
}
private
void
checkRequest
(
KCluster
entity
)
{
if
(
entity
.
getName
()
==
null
)
{
throw
new
IllegalArgumentException
(
"Name of the cluster is null"
);
}
if
(
entity
.
getCodename
()
==
null
)
{
throw
new
IllegalArgumentException
(
"Codename of the cluster is null"
);
}
if
(
entity
.
getDescription
()
==
null
)
{
throw
new
IllegalArgumentException
(
"Description of the cluster is null"
);
}
}
private
static
String
computeSHA256
(
MultipartFile
file
)
throws
IOException
,
NoSuchAlgorithmException
{
MessageDigest
digest
=
MessageDigest
.
getInstance
(
"SHA-256"
);
try
(
InputStream
is
=
file
.
getInputStream
();
...
...
@@ -244,7 +244,7 @@ public class RemoteClusterManager implements ClusterMonitoringService {
@Override
public
void
updateAllClusterState
()
{
restoreFileIfMissing
();
restore
Kubeconfig
FileIfMissing
();
List
<
KCluster
>
kClusters
=
clusterRepository
.
findAll
();
kClusters
.
forEach
(
cluster
->
{
Config
config
=
null
;
...
...
@@ -262,8 +262,7 @@ public class RemoteClusterManager implements ClusterMonitoringService {
updateStateIfNeeded
(
cluster
,
KClusterState
.
UP
);
}
catch
(
KubernetesClientException
e
)
{
log
.
error
(
"Can not connect to cluster {}"
,
cluster
.
getCodename
());
log
.
error
(
e
.
getMessage
());
log
.
warn
(
"Can't connect to cluster {} (message: {})"
,
cluster
.
getCodename
(),
e
.
getMessage
());
updateStateIfNeeded
(
cluster
,
KClusterState
.
DOWN
);
}
catch
(
RuntimeException
ex
)
{
log
.
error
(
"Runtime error while checking health of cluster {}"
,
ex
.
getMessage
());
...
...
@@ -288,8 +287,8 @@ public class RemoteClusterManager implements ClusterMonitoringService {
private
void
sendMail
(
KCluster
kCluster
,
MailType
mailType
)
{
UserView
recipient
;
if
(
userService
.
existsByEmail
(
kCluster
.
getContactEmail
()))
{
recipient
=
modelMapper
.
map
(
userService
.
findByEmail
(
kCluster
.
getContactEmail
()),
UserView
.
class
);
if
(
userService
.
existsByEmail
(
kCluster
.
getContactEmail
()))
{
recipient
=
modelMapper
.
map
(
userService
.
findByEmail
(
kCluster
.
getContactEmail
()),
UserView
.
class
);
}
else
{
recipient
=
UserView
.
builder
().
email
(
kCluster
.
getContactEmail
()).
username
(
kCluster
.
getContactEmail
()).
selectedLanguage
(
"EN"
).
build
();
}
...
...
@@ -307,7 +306,7 @@ public class RemoteClusterManager implements ClusterMonitoringService {
this
.
eventPublisher
.
publishEvent
(
new
NotificationEvent
(
this
,
mailAttributes
));
}
p
ublic
void
restoreFileIfMissing
()
{
p
rivate
void
restore
Kubeconfig
FileIfMissing
()
{
List
<
KCluster
>
clusters
=
clusterRepository
.
findAll
();
clusters
.
forEach
(
cluster
->
{
if
(!
isFileAvailable
(
cluster
.
getPathConfigFile
()))
{
...
...
@@ -326,7 +325,7 @@ public class RemoteClusterManager implements ClusterMonitoringService {
});
}
p
ublic
boolean
isFileAvailable
(
String
pathStr
)
{
p
rivate
boolean
isFileAvailable
(
String
pathStr
)
{
Path
path
=
Paths
.
get
(
pathStr
);
return
Files
.
exists
(
path
)
&&
Files
.
isRegularFile
(
path
)
&&
Files
.
isReadable
(
path
);
}
...
...
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