Skip to content

Commit

Permalink
feat: kubernetes parameters and buttons (not functional yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmanelphe committed Jan 26, 2024
1 parent 79be0a0 commit b40d647
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 4 deletions.
14 changes: 14 additions & 0 deletions arc-core/src/main/resources/BdD/script_global.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ delete from arc.parameter where key='ApiFiltrageService.MAX_PARALLEL_WORKERS';
INSERT INTO arc.parameter VALUES ('MappingService.MAX_PARALLEL_WORKERS','4');
UPDATE arc.parameter set description='parameter.parallel.numberOfThread.p4.mapmodel' where key='MappingService.MAX_PARALLEL_WORKERS';

-- kubernetes parameters
INSERT INTO arc.parameter VALUES ('ArcAction.enableKube','false');
UPDATE arc.parameter set description='parameter.ihm.enableKube' where key='ArcAction.enableKube';

INSERT INTO arc.parameter VALUES ('ArcAction.nbExecutorPods','10');
UPDATE arc.parameter set description='parameter.ihm.nbExecutorPods' where key='ArcAction.nbExecutorPods';

INSERT INTO arc.parameter VALUES ('BatchArc.enableKube','false');
UPDATE arc.parameter set description='parameter.batch.enableKube' where key='BatchArc.enableKube';

INSERT INTO arc.parameter VALUES ('BatchArc.nbExecutorPods','10');
UPDATE arc.parameter set description='parameter.batch.nbExecutorPods' where key='BatchArc.nbExecutorPods';


-- patch 23/06/2023
-- remove deprecated parameters
DELETE FROM arc.parameter WHERE key='LanceurARC.MAX_PARALLEL_RUNNER_PER_PHASE';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestParam;

import fr.insee.arc.core.dataobjects.ArcDatabase;
import fr.insee.arc.core.dataobjects.DataObjectService;
import fr.insee.arc.core.service.global.bo.Sandbox;
import fr.insee.arc.core.service.p0initialisation.dbmaintenance.BddPatcher;
import fr.insee.arc.core.util.BDParameters;
import fr.insee.arc.core.util.LoggerDispatcher;
import fr.insee.arc.utils.ressourceUtils.PropertiesHandler;
import fr.insee.arc.utils.structure.AttributeValue;
Expand Down Expand Up @@ -97,6 +99,9 @@ public abstract class ArcWebGenericService<T extends ArcModel, D extends IDao> i

/** Is the current environment a production environment?*/
private boolean isEnvProd;

/** Are the Kubernetes options enabled?*/
private boolean isKube;

protected boolean isRefreshMonitoring = false;

Expand Down Expand Up @@ -164,10 +169,11 @@ public void initializeModel(@ModelAttribute T arcModel, Model model,
this.isEnvProd = Sandbox.isEnvSetForProduction(this.bacASable);
this.dataObjectService.setSandboxSchema(this.bacASable);

this.isKube = Boolean.parseBoolean(new BDParameters(ArcDatabase.COORDINATOR).getString(null, "ArcAction.enableKube","false"));

dao.initialize(vObjectService, dataObjectService);

this.scope = scope;

initialize(arcModel);
refreshGenericModelAttributes(model);
extraModelAttributes(model);
Expand All @@ -185,6 +191,7 @@ private void refreshGenericModelAttributes(Model model) {
model.addAttribute("version", getVersion());
model.addAttribute("isEnvProd", isEnvProd());
model.addAttribute("application", getApplication());
model.addAttribute("isKube", isKube());
}

/** Adds (if overridden) more attributes to the model.*/
Expand Down Expand Up @@ -415,6 +422,14 @@ public boolean isDataBaseOk() {
public void setDataBaseOk(boolean isDataBaseOK) {
this.isDataBaseOK = isDataBaseOK;
}

public boolean isKube() {
return isKube;
}

public void setKube(boolean isKube) {
this.isKube = isKube;
}

protected Session getSession() {
return session;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
public class MaintenanceOperationsModel implements ArcModel {

private VObject viewOperations;
private VObject viewKube;


public MaintenanceOperationsModel() {
this.viewOperations = new ViewOperations();
this.viewKube = new ViewKube();
}

public VObject getViewOperations() {
Expand All @@ -23,4 +25,12 @@ public void setViewOperations(VObject viewOperations) {
this.viewOperations = viewOperations;
}

public VObject getViewKube() {
return viewKube;
}

public void setViewKube(VObject viewKube) {
this.viewKube = viewKube;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package fr.insee.arc.web.gui.maintenanceoperation.model;

import java.util.HashMap;
import java.util.Map;

import fr.insee.arc.web.gui.all.util.ConstantVObject;
import fr.insee.arc.web.gui.all.util.ConstantVObject.ColumnRendering;
import fr.insee.arc.web.gui.all.util.VObject;


public class ViewKube extends VObject {

private static final Map<String, ColumnRendering> columnMap= new HashMap<>();

static {
columnMap.put("i", new ColumnRendering(false, "i", "0%", "text", null, false));
columnMap.put("key", new ColumnRendering(true, "label.key", "15%", "text", null, true));
columnMap.put("val", new ColumnRendering(true, "label.val", "15%", "text", null, true));
columnMap.put("description", new ColumnRendering(true, "label.description", "70%", "text", null, false));

}

public ViewKube() {
super();
this.setTitle("view.kube");
this.setSessionName("viewKube");
this.setDefaultPaginationSize(20);
this.setConstantVObject(new ConstantVObject(columnMap));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ public class InteractorMaintenanceOperations extends ArcWebGenericService<Mainte
@Override
protected void putAllVObjects(MaintenanceOperationsModel arcModel) {
views.setViewOperations(this.vObjectService.preInitialize(arcModel.getViewOperations()));
views.setViewKube(this.vObjectService.preInitialize(arcModel.getViewKube()));

putVObject(views.getViewOperations(), t -> initializeOperations());
putVObject(views.getViewKube(), t -> initializeKube());
}

public void initializeOperations() {
Map<String, String> defaultInputFields = new HashMap<>();
this.vObjectService.initialize(views.getViewOperations(), new ArcPreparedStatementBuilder("SELECT true"), "arc.operations", defaultInputFields);
}

public void initializeKube() {
Map<String, String> defaultInputFields = new HashMap<>();
this.vObjectService.initialize(views.getViewKube(), new ArcPreparedStatementBuilder("SELECT true"), "arc.kube", defaultInputFields);
}

@Override
public String getActionName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public String generateErrorMessageInLogsOperations(Model model) {
}

public String selectOperations(Model model) {

return generateDisplay(model, RESULT_SUCCESS);
}

Expand Down
8 changes: 8 additions & 0 deletions arc-web/src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ gui.button.exportStart=Start exports
gui.button.downloadFileExport=Download

gui.button.generateErrorMessageInLogs=Generate a test error message to check loggers configuration
gui.button.createPods=Create executor pods
gui.button.createPods.confirm=Executor pods will be created. Are you sure?
gui.button.deletePods=Delete executor pods
gui.button.deletePods.confirm=Executor pods will be deleted. Are you sure?

gui.button.importDDI=Load DDI model

Expand Down Expand Up @@ -347,3 +351,7 @@ parameter.batch.execution.maxCompressedArchiveSizeRegisteredInReceptionModule=Ma
parameter.batch.execution.maxNumberOfFilesProceedInLoadModule=Maximum number of files processed by the load phase which is the first processing pipeline module
parameter.batch.execution.maxNumberOfFilesToProceedPerModule=Default maximum number of files processed by pipeline modules
parameter.ihm.sandbox.numberOfSandboxes=Define the number of sandbox available in the application
parameter.ihm.kube.enableKube=Activate the Kubernetes action buttons in the maintenance page
parameter.ihm.kube.nbExecutorPods=Number of executor pods created by action
parameter.batch.enableKube=Activate Kubernetes for batch processing
parameter.batch.nbExecutorPods=Number of executor pods for batch processing
8 changes: 8 additions & 0 deletions arc-web/src/main/resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ gui.button.exportStart=Lancer les exports
gui.button.downloadFileExport=T\u00e9l\u00e9charger

gui.button.generateErrorMessageInLogs=G\u00e9n\u00e9rer un message d''erreur pour tester les loggers
gui.button.createPods=Cr\u00e9er les pods d''ex\u00e9cution
gui.button.createPods.confirm=\u00cates-vous s\u00fbr(e) de vouloir cr\u00e9er les pods d''ex\u00e9cution ?
gui.button.deletePods=Supprimer les pods d''ex\u00e9cution
gui.button.deletePods.confirm=\u00cates-vous s\u00fbr(e) de vouloir supprimer les pods d''ex\u00e9cution ?

gui.button.importDDI=Charger un mod\u00e8le DDI

Expand Down Expand Up @@ -347,3 +351,7 @@ parameter.batch.execution.maxCompressedArchiveSizeRegisteredInReceptionModule=Ta
parameter.batch.execution.maxNumberOfFilesProceedInLoadModule=Nombre maximum de fichiers trait\u00e9s par la phase de chargement qui est le premier module du pipeline de traitement
parameter.batch.execution.maxNumberOfFilesToProceedPerModule=Nombre maximum par d\u00e9faut de fichiers trait\u00e9s par les modules de pipeline
parameter.ihm.sandbox.numberOfSandboxes=D\u00e9finir le nombre de bac \u00e0 sable disponible dans l''application
parameter.ihm.enableKube=Activer les boutons d''action Kubernetes dans la page de maintenance
parameter.ihm.nbExecutorPods=Nombre de pods d''ex\u00e9cution cr\u00e9\u00e9s par action
parameter.batch.enableKube=Activer Kubernetes pour les traitements batch
parameter.batch.nbExecutorPods=Nombre de pods d''ex\u00e9cution pour les traitements batch
32 changes: 30 additions & 2 deletions arc-web/src/main/webapp/WEB-INF/jsp/maintenanceOperations.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

<form
spellcheck="false"
action="selectExport.action"
id="selectExport"
action="selectOperations.action"
id="selectOperations"
method="post"
accept-charset="UTF-8"
>
Expand Down Expand Up @@ -47,6 +47,34 @@ value="<spring:message code="gui.button.generateErrorMessageInLogs"/>"
</div>
</div>
</div>

<c:if test="${isKube}">
<hr />
<div class="row">
<div class="col-md-12">
<h2>
Kubernetes
</h2>
<div class="row">
<div class="col-md">
<div id="viewKube">
<input type="submit" class="btn btn-primary btn-sm"
id="viewOperations.createPods"
value="<spring:message code="gui.button.createPods"/>"
scope="viewOperations;" doAction="createPods"
onclick="return confirm('<spring:message code="gui.button.createPods.confirm" javaScriptEscape="true"/>');" />
<input type="submit" class="btn btn-primary btn-sm"
id="viewOperations.deletePods"
value="<spring:message code="gui.button.deletePods"/>"
scope="viewOperations;" doAction="deletePods"
onclick="return confirm('<spring:message code="gui.button.deletePods.confirm" javaScriptEscape="true"/>');" />
</div>
</div>
</div>
</div>
</div>
</c:if>

</div>
</form>

Expand Down

0 comments on commit b40d647

Please sign in to comment.