Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conflicts in pekko-http lib dependencies #725

Merged
merged 8 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [2.125.1](https://github.com/open-horizon/exchange-api/pull/725) - 2024-10-22
- Issue 724: Version conflicts in library(pekko-http) dependencies
- pekko-http 1.0.1 -> 1.1.0
- pekko-http-jackson 2.3.3 -> 3.0.0
- pekko-http-cors 1.0.1 -> 1.1.0
- pekko-slf4j 1.0.1 -> 1.1.1
- swagger-pekko-http 2.12.0 -> 2.14.0
- Fixed warnings

## [2.125.0](https://github.com/open-horizon/exchange-api/pull/720) - 2024-09-30
- Removed support for TLS v1.2.
- Removed an API key authentication pathway.
Expand Down
12 changes: 6 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ lazy val root = (project in file("."))
description := "'Containerized exchange-api'",
name := "amd64_exchange-api",
organization := "org.openhorizon",
pekkoHttpVersion := "[1.0.1]",
pekkoHttpVersion := "[1.1.0]",
naphelps marked this conversation as resolved.
Show resolved Hide resolved
pekkoVersion := "[1.0.2]",
release := sys.env.getOrElse("GIT_SHORT_SHA", versionFunc()),
resolvers += Classpaths.typesafeReleases,
Expand All @@ -51,16 +51,16 @@ lazy val root = (project in file("."))
"org.apache.pekko" %% "pekko-http-xml" % pekkoHttpVersion.value,
// "org.apache.pekko" %% "pekko-stream" % "[2.6.14,)",
// "org.apache.pekko" %% "pekko-http-spray-json" % "[10.2.1,)",
"com.github.pjfanning" %% "pekko-http-jackson" % "[2.3.3,)",
"org.apache.pekko" %% "pekko-http-cors" % "[1.0.0]",
"org.apache.pekko" %% "pekko-slf4j" % "[1.0.1]",
"com.github.pjfanning" %% "pekko-http-jackson" % "[3.0.0,)",
"org.apache.pekko" %% "pekko-http-cors" % "[1.1.0]",
"org.apache.pekko" %% "pekko-slf4j" % "[1.1.1]",

"org.json4s" %% "json4s-native" % "4.0.6",
"org.json4s" %% "json4s-jackson" % "4.0.6",

"jakarta.ws.rs" % "jakarta.ws.rs-api" % "[3.1.0]",
// "org.glassfish.jersey.core" % "jersey-common" % "1.2.1", // Required at runtime by javax.ws.rs-api
"com.github.swagger-akka-http" %% "swagger-pekko-http" % "[2.12.0]", // Deprecated in v2.8.0 due to Akka license change to BSL v1.1
"com.github.swagger-akka-http" %% "swagger-pekko-http" % "[2.14.0]",
"com.github.swagger-akka-http" %% "swagger-scala-module" % "[2.12.0,)",
//"io.swagger.core.v3" % "swagger-core-jakarta" % "[2.1.12]", // Version 2.1.13+ requires newer versions of slick and slick-hikaricp
//"io.swagger.core.v3" % "swagger-jaxrs2-jakarta" % "[2.1.12]", // Version 2.1.13+ requires newer versions of slick and slick-hikaricp
Expand Down
107 changes: 107 additions & 0 deletions docs/QuickStart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
copyright:
years: 2024
lastupdated: "2024-10-22"
layout: page
title: "Exchange API Server"
description: "Quick start"

nav_order: 3
parent: Management Hub
---

# Exchange API Server quick start

## Intro

This document describes the environment and the set of steps aiming to create a
local development and debugging environment.

## Prerequisites

* OS: Ubuntu 24.04 LTS.

## Dependencies

* [Java 17](https://www.java.com/en/)
* [SBT](https://www.scala-sbt.org/)
* [PostgreSQL](https://www.postgresql.org/)

## Installation

### Create a new user (optional)

For development purposes recommended not to use root user. Command below will create
a new Ubuntu user.

```bash
useradd -d /home/new_user -s /bin/bash -m new_user
sudo passwd new_user
usermod -aG sudo new_user
```

### Install Java 17

```bash
sudo apt-get update
sudo apt install openjdk-17-jdk -y
```

### Install SBT

```bash
sudo apt-get update
sudo apt-get install apt-transport-https curl gnupg -yqq
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo -H gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import
sudo chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
sudo apt-get update
sudo apt-get install sbt
```

### Install Postgresql

```bash
sudo apt-get update
sudo apt-get install postgresql
sudo systemctl status postgresql
```

### Configure firewall rule for Postgresql port 5432

```bash
sudo iptables -A INPUT -p tcp --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
```

### Create a new DB

```bash
sudo -u postgres psql
postgres=# CREATE USER new_user WITH PASSWORD 'password';
postgres=# CREATE DATABASE horizon OWNER new_user;
\q
```

### Test connection to DB

```bash
psql "host=localhost dbname=horizon user=kevin password='password'"
```

### Export environment variables

```bash
export EXCHANGE_DB_NAME=openhorizon
export EXCHANGE_DB_PW=password
export EXCHANGE_DB_USER=new_user
export EXCHANGE_ROOT_PW=root_password
```

### Clone exchange-api and run it

```bash
https://github.com/open-horizon/exchange-api.git
~/exchange-api$ sbt
sbt:amd64_exchange-api> reStart
```
2 changes: 1 addition & 1 deletion docs/openapi-3-developer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name" : "Apache License Version 2.0",
"url" : "https://www.apache.org/licenses/LICENSE-2.0"
},
"version" : "2.125.0"
"version" : "2.125.1"
},
"externalDocs" : {
"description" : "Open-horizon ExchangeAPI",
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi-3-user.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name" : "Apache License Version 2.0",
"url" : "https://www.apache.org/licenses/LICENSE-2.0"
},
"version" : "2.125.0"
"version" : "2.125.1"
},
"externalDocs" : {
"description" : "Open-horizon ExchangeAPI",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.125.0
2.125.1
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ trait AgentConfigurationManagement extends JacksonSupport with AuthenticationSup
certificate <- AgentCertificateVersionsTQ.delete

timestamp: Timestamp = ApiTime.nowUTCTimestamp

naphelps marked this conversation as resolved.
Show resolved Hide resolved


checkAgentVersionsResult <- AgentVersionsChangedTQ.getChanged("IBM").result

changed <-
if(AgentVersionsChangedTQ.getChanged("IBM").result == 0)
if(checkAgentVersionsResult == 0)
AgentVersionsChangedTQ += (timestamp, "IBM")
else
AgentVersionsChangedTQ.getChanged("IBM").update(timestamp)

configuration <- AgentConfigurationVersionsTQ.delete
resource <- ResourceChangesTQ += ResourceChangeRow(category = ResChangeCategory.ORG.toString,
changeId = 0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.openhorizon.exchangeapi.utility.ApiTime.fixFormatting
import org.openhorizon.exchangeapi.ExchangeApiApp.{exchAuth, validateWithMsg}
import org.openhorizon.exchangeapi.auth.{Access, AccessDeniedException, AuthCache, AuthRoles, AuthenticationSupport, BadInputException, DBProcessingError, IUser, Identity, OrgAndId, Password, ResourceNotFoundException, TNode}
import org.openhorizon.exchangeapi.table.deploymentpattern.{PatternRow, Patterns, PatternsTQ}
import org.openhorizon.exchangeapi.table.node.{Node, NodeRow, NodeType, NodesTQ}
import org.openhorizon.exchangeapi.table.node.{NodeRow, NodeType, NodesTQ}
import org.openhorizon.exchangeapi.table.node.group.NodeGroupTQ
import org.openhorizon.exchangeapi.table.node.group.assignment.NodeGroupAssignmentTQ
import org.openhorizon.exchangeapi.table.organization.{OrgLimits, OrgsTQ}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.apache.pekko.http.scaladsl.model.{StatusCode, StatusCodes}
import org.apache.pekko.http.scaladsl.server.Directives.{as, complete, delete, entity, get, patch, path, post, put, _}
import org.apache.pekko.http.scaladsl.server.Route
import org.openhorizon.exchangeapi.auth.{Access, AuthCache, AuthenticationSupport, BadInputException, IUser, Identity, OrgAndId, Password, Role, TUser}
import org.openhorizon.exchangeapi.table.user.{User, UserRow, UsersTQ}
import org.openhorizon.exchangeapi.table.user.{User => UserTable, UserRow, UsersTQ}
import org.openhorizon.exchangeapi.utility.{ApiRespType, ApiResponse, ApiTime, ExchMsg, ExchangePosgtresErrorHandling, HttpCode, StrConstants}
import slick.jdbc.PostgresProfile.api._

Expand Down Expand Up @@ -92,7 +92,7 @@ trait User extends JacksonSupport with AuthenticationSupport {
logger.debug(s"GET /orgs/$organization/users/$realUsername result size: ${list.size}")

val users: Map[String, org.openhorizon.exchangeapi.table.user.User] =
list.map(e => e.username -> User(if (identity.isSuperUser || identity.isHubAdmin) e.hashedPw else StrConstants.hiddenPw, e.admin, e.hubAdmin, e.email, e.lastUpdated, e.updatedBy)).toMap
list.map(e => e.username -> UserTable(if (identity.isSuperUser || identity.isHubAdmin) e.hashedPw else StrConstants.hiddenPw, e.admin, e.hubAdmin, e.email, e.lastUpdated, e.updatedBy)).toMap
val code: StatusCode =
if (users.nonEmpty)
StatusCodes.OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class TestPatchUserRoute extends AnyFunSuite with BeforeAndAfterAll with BeforeA
Await.ready(DBCONNECTION.run(
TESTUSERS(0).updateUser() andThen
TESTUSERS(2).updateUser() andThen
TESTUSERS(4).updateUser
TESTUSERS(4).updateUser()
), AWAITDURATION)
}

Expand Down
Loading