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

Release 0.5.3 #142

Merged
merged 28 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a25017e
Add snyk workflow to github actions
Bdegraaf1234 Apr 18, 2024
38f1904
Merge pull request #125 from RADAR-base/add-snyk-workflow
yatharthranjan Apr 22, 2024
4f26630
Update the versions of our dependencies to the latest available
Bdegraaf1234 Apr 18, 2024
5607b7a
Merge pull request #126 from RADAR-base/security-updates
Bdegraaf1234 Apr 22, 2024
f72531a
Update Versions.kt
mpgxvii May 8, 2024
7e1af09
Merge pull request #131 from RADAR-base/release-0.5.2
mpgxvii May 8, 2024
7908a49
Update Oura request backoff times
mpgxvii May 28, 2024
17d0d45
Merge pull request #134 from RADAR-base/fix/oura-backoff
mpgxvii May 29, 2024
0430499
Uninstall java 11 and install java 17 in the base docker images from …
Bdegraaf1234 Jun 18, 2024
8b6360a
Merge pull request #138 from RADAR-base/fix-dockerfile
Bdegraaf1234 Jun 20, 2024
78c20fe
Check if transfer-Encoding header is set, if so the response has a body
Bdegraaf1234 Jun 19, 2024
ef2f2f8
Merge pull request #139 from RADAR-base/fix-get-users
Bdegraaf1234 Jul 9, 2024
9971d00
Fix initialisation of kakfa offset manager
mpgxvii Jul 10, 2024
5b32e99
Add backoff time when no records are found
mpgxvii Jul 10, 2024
c24c89e
UUpdate back off times
mpgxvii Jul 10, 2024
1aebe6a
Merge pull request #141 from RADAR-base/fix/offset-manager
mpgxvii Jul 10, 2024
593f50d
Bump version
mpgxvii Jul 10, 2024
2e0cd88
Allow null end dates for continuous pull of data
mpgxvii Jul 10, 2024
67af964
Update back off time for no records to ONE_DAY
mpgxvii Jul 10, 2024
5d87b76
Refactor checking of end date for brevity
mpgxvii Jul 10, 2024
2c3bc7e
Merge pull request #143 from RADAR-base/feat/allow-null-end
mpgxvii Jul 10, 2024
f7d3f33
Fix isComplete check for User
mpgxvii Jul 12, 2024
6b9dc43
Merge pull request #145 from RADAR-base/fix/user
mpgxvii Jul 15, 2024
dbcd7dc
Fix lint errors
mpgxvii Jul 15, 2024
7f0dcb1
Fix Oura offset times
mpgxvii Jul 26, 2024
db44b53
Merge pull request #147 from RADAR-base/feat/offset-times
mpgxvii Aug 9, 2024
8544aa9
Fix lint errors
mpgxvii Aug 9, 2024
27e5a19
Bump vulnerable deps
mpgxvii Aug 19, 2024
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
34 changes: 34 additions & 0 deletions .github/workflows/snyk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Snyk test

on:
- pull_request

jobs:
security:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: snyk/actions/setup@master
with:
snyk-version: v1.1032.0

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run Snyk to check for vulnerabilities
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: >
snyk test
--all-projects
--configuration-matching="^runtimeClasspath$"
--fail-on=upgradable
--org=radar-base
--policy-path=.snyk
--severity-threshold=high
22 changes: 10 additions & 12 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@Suppress("ConstPropertyName", "MemberVisibilityCanBePrivate")
object Versions {
const val project = "0.5.2"
const val project = "0.5.3"

const val java = 17
const val kotlin = "1.9.10"
const val kotlin = "1.9.22"
const val wrapper = "8.4"

const val radarCommons = "1.1.2"
Expand All @@ -14,20 +14,18 @@ object Versions {
const val managementPortal = "2.0.0"

// From image
const val jackson = "2.16.1"
const val jackson = "2.17.0"

const val log4j2 = "2.20.0"
const val slf4j = "2.0.9"
const val log4j2 = "2.23.1"
const val slf4j = "2.0.13"

const val okhttp = "4.12.0"

const val firebaseAdmin = "9.1.0"
const val firebaseAdmin = "9.2.0"
const val radarSchemas = "0.8.7-hotfix"
const val ktor = "2.3.5"
const val ktor = "2.3.10"

const val junit = "5.9.3"
const val wiremock = "2.27.2"
const val mockito = "5.3.1"

const val kotlinVersion = "1.9.10"
const val junit = "5.10.2"
const val wiremock = "3.0.1"
const val mockito = "5.11.0"
}
7 changes: 7 additions & 0 deletions kafka-connect-fitbit-source/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ RUN gradle jar

FROM confluentinc/cp-kafka-connect-base:7.5.0

USER root

RUN yum remove -y zulu11-ca-jdk-headless && yum remove -y zulu11-ca-jre-headless
RUN yum install -y zulu17-ca-jdk-headless && yum install -y zulu17-ca-jre-headless

USER appuser

MAINTAINER Joris Borgdorff <joris@thehyve.nl>

LABEL description="Kafka REST API Source connector"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ class ServiceUserRepository : UserRepository {
): T = withContext(Dispatchers.IO) {
val response = client.request(builder)
val contentLength = response.contentLength()
val hasBody = contentLength != null && contentLength > 0
// if Transfer-Encoding: chunked, then the request has data but contentLength will be null.
val transferEncoding = response.headers["Transfer-Encoding"]
val hasBody = (contentLength != null && contentLength > 0) ||
(transferEncoding != null && transferEncoding.contains("chunked"))
if (response.status == HttpStatusCode.NotFound) {
throw NoSuchElementException("URL " + response.request.url + " does not exist")
} else if (!response.status.isSuccess() || !hasBody) {
Expand Down
7 changes: 7 additions & 0 deletions kafka-connect-oura-source/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ RUN gradle jar

FROM confluentinc/cp-kafka-connect-base:7.5.0

USER root

RUN yum remove -y zulu11-ca-jdk-headless && yum remove -y zulu11-ca-jre-headless
RUN yum install -y zulu17-ca-jdk-headless && yum install -y zulu17-ca-jre-headless

USER appuser

MAINTAINER Pauline Conde <pauline.conde@kcl.ac.uk>

LABEL description="Kafka Oura REST API Source connector"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void initialize(List<Map<String, Object>> partitions) {
.filter(e -> e.getValue() != null && e.getValue().containsKey(TIMESTAMP_OFFSET_KEY))
.collect(Collectors.toMap(
e -> (String) e.getKey().get("user") + "-" + e.getKey().get("route"),
e -> Instant.ofEpochMilli(((Number) e.getValue().get(TIMESTAMP_OFFSET_KEY)).longValue())));
e -> Instant.ofEpochSecond(((Number) e.getValue().get(TIMESTAMP_OFFSET_KEY)).longValue())));
} else {
logger.warn("Offset storage reader is null, will resume from an empty state.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,11 @@

package org.radarbase.connect.rest;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.resetAllRequests;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.jupiter.api.Assertions.assertEquals;

import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.VerificationException;
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.github.tomakehurst.wiremock.verification.NearMiss;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.kafka.connect.source.SourceRecord;
import org.apache.kafka.connect.source.SourceTaskContext;
import org.apache.kafka.connect.storage.OffsetStorageReader;
Expand All @@ -56,6 +40,23 @@
import org.radarbase.connect.rest.single.SingleRestSourceConnector;
import org.radarbase.connect.rest.single.SingleRestSourceConnectorConfig;

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

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.resetAllRequests;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.jupiter.api.Assertions.assertEquals;

@ExtendWith(WireMockRule.class)
public class RestTaskTest {

Expand Down Expand Up @@ -167,7 +168,7 @@ public void afterEach(ExtensionContext context) {
}
}

private void checkForUnmatchedRequests() {
public void checkForUnmatchedRequests() {
List<LoggedRequest> unmatchedRequests = findAllUnmatchedRequests();
if (!unmatchedRequests.isEmpty()) {
List<NearMiss> nearMisses = findNearMissesForAllUnmatchedRequests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ constructor(
offsetTime.coerceAtLeast(startDate)
}
val endDate = if (user.endDate >= Instant.now()) Instant.now() else user.endDate
if (Duration.between(startOffset, endDate).toDays() <= ONE_DAY) {
if (Duration.between(startOffset, endDate) <= ONE_DAY) {
logger.info("Interval between dates is too short. Backing off..")
userNextRequest[user.versionedId] = Instant.now().plus(USER_BACK_OFF_TIME)
return emptySequence()
Expand Down Expand Up @@ -145,11 +145,13 @@ constructor(
?: nextRequestTime
} else {
if (request.startDate.plus(TIME_AFTER_REQUEST).isBefore(Instant.now())) {
logger.info("No records found, updating offsets to end date..")
ouraOffsetManager.updateOffsets(
request.route,
request.user,
request.endDate,
)
userNextRequest[request.user.versionedId] = Instant.now().plus(BACK_OFF_TIME)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update to ONE_DAY

}
}
return records
Expand Down Expand Up @@ -240,10 +242,10 @@ constructor(
companion object {
private val logger = LoggerFactory.getLogger(OuraRequestGenerator::class.java)
private val BACK_OFF_TIME = Duration.ofMinutes(10L)
private val ONE_DAY = 1L
private val ONE_DAY = Duration.ofDays(1L)
private val TIME_AFTER_REQUEST = Duration.ofDays(30)
private val USER_BACK_OFF_TIME = Duration.ofMinutes(2L)
private val SUCCESS_BACK_OFF_TIME = Duration.ofSeconds(3L)
private val USER_BACK_OFF_TIME = Duration.ofHours(12L)
private val SUCCESS_BACK_OFF_TIME = Duration.ofMinutes(1L)
private val USER_MAX_REQUESTS = 20
val JSON_FACTORY = JsonFactory()
val JSON_READER = ObjectMapper(JSON_FACTORY).registerModule(JavaTimeModule()).reader()
Expand Down
Loading