From ada866314b69b240ef6f977b204089b7b4e5f332 Mon Sep 17 00:00:00 2001 From: ErmiasG Date: Thu, 5 Oct 2023 15:02:03 +0200 Subject: [PATCH] [HWORKS-590] HA testing (#1409) --- .../test/ruby/spec/helpers/project_helper.rb | 3 ++- .../dao/jupyter/MaterializedJWTFacade.java | 2 +- .../python/commands/CommandsController.java | 6 ++--- .../custom/CustomCommandsController.java | 5 ++-- .../environment/EnvironmentController.java | 5 ++-- .../python/library/LibraryInstaller.java | 4 ++++ .../entity/python/CondaCommands.java | 23 +++++++++---------- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/hopsworks-IT/src/test/ruby/spec/helpers/project_helper.rb b/hopsworks-IT/src/test/ruby/spec/helpers/project_helper.rb index d38fa50296..f48b2fb8d5 100644 --- a/hopsworks-IT/src/test/ruby/spec/helpers/project_helper.rb +++ b/hopsworks-IT/src/test/ruby/spec/helpers/project_helper.rb @@ -117,7 +117,8 @@ def raw_delete_project(project, response, headers) method: "post", followlocation: true, ssl_verifypeer: false, - ssl_verifyhost: 0) + ssl_verifyhost: 0, + forbid_reuse: true) end def delete_project(project) diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/dao/jupyter/MaterializedJWTFacade.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/dao/jupyter/MaterializedJWTFacade.java index 59978ee32b..d19cb9ed9a 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/dao/jupyter/MaterializedJWTFacade.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/dao/jupyter/MaterializedJWTFacade.java @@ -1,6 +1,6 @@ /* * This file is part of Hopsworks - * Copyright (C) 2019, Logical Clocks AB. All rights reserved + * Copyright (C) 2023, Hopsworks AB. All rights reserved * * Hopsworks is free software: you can redistribute it and/or modify it under the terms of * the GNU Affero General Public License as published by the Free Software Foundation, diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/commands/CommandsController.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/commands/CommandsController.java index d26ec6fc34..6aa5633233 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/commands/CommandsController.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/commands/CommandsController.java @@ -40,7 +40,6 @@ import javax.ejb.TransactionAttributeType; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.List; import java.util.Optional; import java.util.logging.Level; @@ -167,9 +166,8 @@ public PythonDep condaOp(CondaOp op, Users user, CondaInstallType installType, P proj.setPythonDepCollection(depsInProj); projectFacade.update(proj); - CondaCommands cc = new CondaCommands(user, op, - CondaStatus.NEW, installType, proj, lib, version, channelUrl, - new Date(), arg, null, false, gitBackend, apiKeyName); + CondaCommands cc = new CondaCommands(user, op, CondaStatus.NEW, installType, proj, lib, version, channelUrl, + arg, null, false, gitBackend, apiKeyName); condaCommandFacade.save(cc); } catch (Exception ex) { throw new GenericException(RESTCodes.GenericErrorCode.UNKNOWN_ERROR, Level.SEVERE, "condaOp failed", diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/commands/custom/CustomCommandsController.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/commands/custom/CustomCommandsController.java index 7b8b38b473..711e5bd7b3 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/commands/custom/CustomCommandsController.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/commands/custom/CustomCommandsController.java @@ -42,7 +42,6 @@ import javax.ejb.TransactionAttributeType; import java.io.IOException; import java.util.ArrayList; -import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; @@ -68,8 +67,8 @@ public CondaCommands buildEnvWithCustomCommands(Project project, Users users, Cu validateArtifacts(cmdSettings); } CondaCommands cc = new CondaCommands(users, CondaOp.CUSTOM_COMMANDS, CondaStatus.NEW, - CondaInstallType.CUSTOM_COMMANDS, project, null, version, null, new Date(), - cmdSettings.getArtifacts(), null, false, null, null); + CondaInstallType.CUSTOM_COMMANDS, project, null, version, null, cmdSettings.getArtifacts(), null, false, null, + null); cc.setCustomCommandsFile(cmdSettings.getCommandsFile()); commandsController.create(cc); return cc; diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/environment/EnvironmentController.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/environment/EnvironmentController.java index ee74ad3838..14b2d78500 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/environment/EnvironmentController.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/environment/EnvironmentController.java @@ -48,7 +48,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; import java.util.List; import java.util.Optional; import java.util.logging.Level; @@ -201,7 +200,7 @@ private void condaEnvironmentOp(CondaOp op, String pythonVersion, Project proj, throw new IllegalStateException("Tried to execute a conda env op on a reserved project name"); } CondaCommands cc = new CondaCommands(user, op, CondaStatus.NEW, CondaInstallType.ENVIRONMENT, proj, - pythonVersion, "", "defaults", new Date(), arg, environmentFile, installJupyter); + pythonVersion, "", "defaults", arg, environmentFile, installJupyter); condaCommandFacade.save(cc); } @@ -288,7 +287,7 @@ public Project createEnv(Project project, Users user) throws PythonException { CondaCommands cc = new CondaCommands(user, CondaOp.SYNC_BASE_ENV, CondaStatus.NEW, CondaInstallType.ENVIRONMENT, project, settings.getDockerBaseImagePythonVersion(), - null, null, new Date(), null, null, false); + null, null, null, null, false); condaCommandFacade.save(cc); return projectFacade.update(project); diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/library/LibraryInstaller.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/library/LibraryInstaller.java index 0f42d93d48..067d6f2db8 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/library/LibraryInstaller.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/python/library/LibraryInstaller.java @@ -611,6 +611,10 @@ public int compare(T t, T t1) { } private int condaCommandCompare(final CondaCommands t, final CondaCommands t1) { + int comp = t.getCreated().compareTo(t1.getCreated()); + if (comp != 0) { + return comp; + } return t.getId().compareTo(t1.getId()); } diff --git a/hopsworks-persistence/src/main/java/io/hops/hopsworks/persistence/entity/python/CondaCommands.java b/hopsworks-persistence/src/main/java/io/hops/hopsworks/persistence/entity/python/CondaCommands.java index 58fc09703d..4705ce430a 100644 --- a/hopsworks-persistence/src/main/java/io/hops/hopsworks/persistence/entity/python/CondaCommands.java +++ b/hopsworks-persistence/src/main/java/io/hops/hopsworks/persistence/entity/python/CondaCommands.java @@ -45,6 +45,7 @@ import java.io.Serializable; import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; import java.util.Date; import javax.persistence.Basic; import javax.persistence.Column; @@ -175,8 +176,7 @@ public class CondaCommands implements Serializable { @Enumerated(EnumType.STRING) private CondaInstallType installType; @Basic(optional = false) - @NotNull - @Column(name = "created") + @Column(name = "created", insertable = false, updatable = false) @Temporal(TemporalType.TIMESTAMP) private Date created; @JoinColumn(name = "project_id", @@ -201,16 +201,15 @@ public class CondaCommands implements Serializable { public CondaCommands() { } - public CondaCommands(Users userId, CondaOp op, - CondaStatus status, CondaInstallType installType, Project project, String lib, String version, - String channelUrl, Date created, String arg, String environmentFile, Boolean installJupyter) { - this(userId, op, status, installType, project, lib, version, channelUrl, created, arg, - environmentFile, installJupyter, null, null); + public CondaCommands(Users userId, CondaOp op, CondaStatus status, CondaInstallType installType, Project project, + String lib, String version, String channelUrl, String arg, String environmentFile, Boolean installJupyter) { + this(userId, op, status, installType, project, lib, version, channelUrl, arg, environmentFile, installJupyter, null, + null); } public CondaCommands(Users userId, CondaOp op, CondaStatus status, CondaInstallType installType, Project project, String lib, String version, - String channelUrl, Date created, String arg, String environmentFile, Boolean installJupyter, + String channelUrl, String arg, String environmentFile, Boolean installJupyter, GitBackend gitBackend, String gitApiKeyName) { if (op == null || project == null) { throw new NullPointerException("Op/project cannot be null"); @@ -220,7 +219,6 @@ public CondaCommands(Users userId, CondaOp op, this.projectId = project; this.status = status; this.installType = installType; - this.created = created; this.channelUrl = channelUrl; this.lib = lib; this.version = version; @@ -369,9 +367,10 @@ public boolean equals(Object object) { @Override public String toString() { String projectName = projectId != null ? projectId.getName() : "unknown"; - return "[ id=" + id + ", proj=" + projectName + ", op=" + op + ", installType=" + installType - + ", lib=" + lib + ", version=" + version + ", arg=" + arg - + ", channel=" + channelUrl + "]"; + return "[ id=" + id + ", proj=" + projectName + ", op=" + op + ", installType=" + installType + + ", lib=" + lib + ", version=" + version + ", arg=" + arg + + ", channel=" + channelUrl + ", created=" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(created) + + "]"; } public Users getUserId() {