Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • osl/code/org.etsi.osl.cridge
1 result
Show changes
Commits on Source (4)
......@@ -2,5 +2,5 @@ FROM ibm-semeru-runtimes:open-17.0.7_7-jdk
MAINTAINER openslice.io
RUN mkdir /opt/shareclasses
RUN mkdir -p /opt/openslice/lib/
COPY target/org.etsi.osl.cridge-1.1.0-exec.jar /opt/openslice/lib/
CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.cridge-1.1.0-exec.jar"]
COPY target/org.etsi.osl.cridge-1.2.0-SNAPSHOT-exec.jar /opt/openslice/lib/
CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.cridge-1.2.0-SNAPSHOT-exec.jar"]
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.etsi.osl</groupId>
<artifactId>org.etsi.osl.main</artifactId>
<version>2024Q4</version>
<version>2025Q2-SNAPSHOT</version>
<relativePath>../org.etsi.osl.main</relativePath>
</parent>
......
......@@ -57,8 +57,8 @@ public class CRRouteBuilder extends RouteBuilder{
.bean( kubernetesClientResource, "patchCR(${headers}, ${body})")
.convertBodyTo( String.class );
// every 120000 ms (2 minutes)
from( "timer://processUpdateResources?period=120000" )
// every 300000 ms (5 minutes)
from( "timer://processUpdateResources?period=300000" )
.log(LoggingLevel.INFO, log, " process nameSpacesTobeDeleted!")
.to("log:DEBUG?showBody=true&showHeaders=true")
.bean( CRRouteBuilder.class , "processNameSpacesTobeDeleted()");
......@@ -73,9 +73,9 @@ public class CRRouteBuilder extends RouteBuilder{
long diffInMillies = Math.abs(currentTime .getTime() - datetime.getTime());
long diff = TimeUnit.MINUTES.convert(diffInMillies, TimeUnit.MILLISECONDS);
if (diff<=2) { //after 2 minutes this namespace will be deleted
if (diff<=10) { //after 10 minutes this namespace will be deleted
return;
}
}
try (final KubernetesClient k8s = new KubernetesClientBuilder().build()) {
logger.info("Trying to delete namespace {}", nameSpaceName);
......@@ -85,6 +85,11 @@ public class CRRouteBuilder extends RouteBuilder{
.endMetadata().build();
k8s.namespaces().resource(ns).delete();
NamespaceWatcher watchersForNamespace = kubernetesClientResource.getWatchersForNamespaces().get( nameSpaceName );
if ( watchersForNamespace!= null) {
watchersForNamespace.disableNamespace( nameSpaceName );
}
kubernetesClientResource.getWatchersForNamespaces().remove(nameSpaceName);
kubernetesClientResource.getNameSpacesTobeDeleted().remove(nameSpaceName);
}catch (Exception e) {
e.printStackTrace();
......
......@@ -419,7 +419,7 @@ public class KubernetesClientResource {
if ( this.watchersForNamespaces.get(nameSpacename) == null ) {
//SharedIndexInformer<Secret> result = createWatchersFornamespace( nameSpacename, headers );
NamespaceWatcher result = NamespaceWatcher.getNew( kubernetesClient, catalogClient, nameSpacename, headers);
NamespaceWatcher result = NamespaceWatcher.getNew( kubernetesClient, catalogClient, nameSpacename, headers, this);
this.watchersForNamespaces.put(nameSpacename, result);
}
......@@ -481,13 +481,6 @@ public class KubernetesClientResource {
this.nameSpacesTobeDeleted.put(nameSpacename, new Date() );
NamespaceWatcher watchersForNamespace = this.watchersForNamespaces.get(nameSpacename);
if ( watchersForNamespace!= null) {
watchersForNamespace.disableNamespace( nameSpacename );
}
this.watchersForNamespaces.remove(nameSpacename);
}catch (Exception e) {
e.printStackTrace();
......
......@@ -14,6 +14,7 @@ import org.etsi.osl.tmf.ri639.model.ResourceCreate;
import org.etsi.osl.tmf.ri639.model.ResourceStatusType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.yaml.snakeyaml.Yaml;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ObjectMeta;
......@@ -45,13 +46,16 @@ public class NamespaceWatcher {
List< SharedIndexInformer<?>> informers = new ArrayList<>();
private KubernetesClientResource kubernetesClientResource;
public NamespaceWatcher(KubernetesClient kubernetesClient, CatalogClient catalogClient, String anameSpacename, Map<String, Object> aheaders) {
public NamespaceWatcher(KubernetesClient kubernetesClient, CatalogClient catalogClient, String anameSpacename, Map<String, Object> aheaders, KubernetesClientResource akubernetesClientResource) {
super();
this.kubernetesClient = kubernetesClient;
this.catalogClient = catalogClient;
this.nameSpacename = anameSpacename;
this.headers = aheaders;
this.kubernetesClientResource = akubernetesClientResource;
kubernetesSecretResourceSpec = catalogClient.retrieveResourceSpecByNameCategoryVersion(
KubernetesSecret.OSL_KUBSECRET_RSPEC_NAME,
......@@ -70,9 +74,9 @@ public class NamespaceWatcher {
KubernetesConfigMap.OSL_KUBCMAP_RSPEC_VERSION);
}
public static NamespaceWatcher getNew(KubernetesClient kubernetesClient2, CatalogClient catalogClient2, String anameSpacename, Map<String, Object> aheaders) {
public static NamespaceWatcher getNew(KubernetesClient kubernetesClient2, CatalogClient catalogClient2, String anameSpacename, Map<String, Object> aheaders, KubernetesClientResource akubernetesClientResource) {
NamespaceWatcher aNamespaceWatchers = new NamespaceWatcher(kubernetesClient2, catalogClient2, anameSpacename, aheaders);
NamespaceWatcher aNamespaceWatchers = new NamespaceWatcher(kubernetesClient2, catalogClient2, anameSpacename, aheaders, akubernetesClientResource);
SharedIndexInformer<Secret> rSecret = aNamespaceWatchers.createSecretWatchersFornamespace(anameSpacename, aheaders);
aNamespaceWatchers.informers.add( rSecret );
......@@ -140,7 +144,11 @@ public class NamespaceWatcher {
newObj.getMetadata().getName(),
newObj.getMetadata().getUid(),
newObj.getMetadata().getNamespace());
updateKubernetesSecretResourceInOSLCatalog( newObj, false );
if ( kubernetesClientResource.getNameSpacesTobeDeleted().get( newObj.getMetadata().getNamespace())==null ) {
updateKubernetesSecretResourceInOSLCatalog( newObj, false );
} else {
updateKubernetesSecretResourceInOSLCatalog( newObj, true );
}
}
......@@ -283,7 +291,12 @@ public class NamespaceWatcher {
newObj.getMetadata().getName(),
newObj.getMetadata().getUid(),
newObj.getMetadata().getNamespace());
updateKubernetesServiceResourceInOSLCatalog( newObj, false );
//check if namespace is under deletion so to ignore any changes
if ( kubernetesClientResource.getNameSpacesTobeDeleted().get( newObj.getMetadata().getNamespace()) == null ) {
updateKubernetesServiceResourceInOSLCatalog( newObj, false );
} else {
updateKubernetesServiceResourceInOSLCatalog( newObj, true );
}
}
......@@ -449,7 +462,13 @@ public class NamespaceWatcher {
newObj.getMetadata().getName(),
newObj.getMetadata().getUid(),
newObj.getMetadata().getNamespace());
updateKubernetesConfigMapResourceInOSLCatalog( newObj, false );
//check if namespace is under deletion so to ignore any changes
if ( kubernetesClientResource.getNameSpacesTobeDeleted().get( newObj.getMetadata().getNamespace()) == null ) {
updateKubernetesConfigMapResourceInOSLCatalog( newObj, false );
} else {
updateKubernetesConfigMapResourceInOSLCatalog( newObj, true );
}
}
......