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

project: switch to concord-client2 #821

Merged
merged 30 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ef9cfd0
switch to client2
brig Oct 10, 2023
b9e9b53
Merge remote-tracking branch 'origin/master' into brig/client2-switch
brig Oct 10, 2023
0c67e70
cleanup
brig Oct 10, 2023
406db2e
tests
brig Oct 10, 2023
0a0cf39
client2: not initialize object by default
brig Oct 11, 2023
f816f5f
tests up
brig Oct 11, 2023
a6993c3
its: fix sha1 calculate for GH event
brig Oct 11, 2023
7169495
Merge branch 'master' into brig/client2-switch
brig Oct 12, 2023
2d1aeb3
Merge remote-tracking branch 'origin/master' into brig/client2-switch
brig Nov 5, 2023
d11912d
merge with master
brig Nov 6, 2023
4a68664
client1 support
brig Nov 7, 2023
005c83b
cleanup client2 pom
brig Nov 8, 2023
9261519
remove javadocs from generated clients, useless and generates a lof o…
brig Nov 8, 2023
987eadb
revapi version up
brig Nov 8, 2023
61c3bb0
Merge remote-tracking branch 'origin/master' into brig/client2-switch
brig Nov 8, 2023
6b9349c
client2: fix deps scope
brig Nov 8, 2023
92def59
MultipartInput removed from swagger.yaml
brig Nov 8, 2023
9a82e32
merge with master
brig Dec 5, 2023
ec77247
usgin WrokingDirectory from runtime-v2
brig Dec 5, 2023
f155b82
Merge branch 'master' into brig/client2-switch
brig Dec 8, 2023
d0778c6
Merge branch 'master' into brig/client2-switch
brig Dec 10, 2023
86adfbd
Merge branch 'master' into brig/client2-switch
ibodrov Dec 13, 2023
ee7d417
Merge branch 'brig/client2-switch' of https://github.com/walmartlabs/…
brig Dec 25, 2023
5ffbdd5
AttachmentsUploader retry upload
brig Dec 25, 2023
19aca19
deps up
brig Dec 26, 2023
2d7861c
resolve v1 client by default
brig Dec 26, 2023
250e4db
Merge branch 'master' into brig/client2-switch
brig Dec 26, 2023
f6c8fb5
Merge branch 'master' into brig/client2-switch
brig Dec 26, 2023
f0958f9
compile fix
brig Dec 27, 2023
c0233c1
cleanup
brig Dec 27, 2023
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
7 changes: 1 addition & 6 deletions agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</dependency>
<dependency>
<groupId>com.walmartlabs.concord</groupId>
<artifactId>concord-client</artifactId>
<artifactId>concord-client2</artifactId>
</dependency>
<dependency>
<groupId>com.walmartlabs.concord</groupId>
Expand Down Expand Up @@ -105,11 +105,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.walmartlabs.concord.agent.guice.WorkerModule;
import com.walmartlabs.concord.agent.mmode.MaintenanceModeListener;
import com.walmartlabs.concord.agent.mmode.MaintenanceModeNotifier;
import com.walmartlabs.concord.client.ProcessEntry.StatusEnum;
import com.walmartlabs.concord.client2.ProcessEntry.StatusEnum;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.server.queueclient.QueueClient;
import com.walmartlabs.concord.server.queueclient.message.ProcessRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,16 @@
* =====
*/

import com.walmartlabs.concord.client.ClientUtils;
import com.walmartlabs.concord.client.ProcessApi;
import com.walmartlabs.concord.client2.ClientUtils;
import com.walmartlabs.concord.client2.ProcessApi;
import com.walmartlabs.concord.common.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.io.File;
import java.nio.file.Path;
import java.io.InputStream;
import java.nio.file.StandardCopyOption;

public class DefaultStateFetcher implements StateFetcher {

private static final Logger log = LoggerFactory.getLogger(DefaultStateFetcher.class);

private final ProcessApi processApi;

@Inject
Expand All @@ -44,26 +39,9 @@ public DefaultStateFetcher(ProcessApi processApi) {

@Override
public void downloadState(JobRequest job) throws Exception {
File payload = null;
try {
payload = ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> processApi.downloadState(job.getInstanceId()));
IOUtils.unzip(payload.toPath(), job.getPayloadDir(), StandardCopyOption.REPLACE_EXISTING);
} finally {
if (payload != null) {
delete(payload.toPath());
}
}
}

private static void delete(Path dir) {
if (dir == null) {
return;
}

try {
IOUtils.deleteRecursively(dir);
} catch (Exception e) {
log.warn("delete ['{}'] -> error", dir, e);
try (InputStream is = ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> processApi.downloadState(job.getInstanceId()))){
IOUtils.unzip(is, job.getPayloadDir(), StandardCopyOption.REPLACE_EXISTING);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.walmartlabs.concord.agent.cfg.GitConfiguration;
import com.walmartlabs.concord.agent.cfg.RepositoryCacheConfiguration;
import com.walmartlabs.concord.client.SecretClient;
import com.walmartlabs.concord.client2.SecretClient;
import com.walmartlabs.concord.imports.Import.SecretDefinition;
import com.walmartlabs.concord.repository.*;
import com.walmartlabs.concord.sdk.Secret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.walmartlabs.concord.agent.guice.AgentImportManager;
import com.walmartlabs.concord.agent.logging.ProcessLog;
import com.walmartlabs.concord.agent.remote.ProcessStatusUpdater;
import com.walmartlabs.concord.client.ProcessEntry.StatusEnum;
import com.walmartlabs.concord.client2.ProcessEntry.StatusEnum;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.imports.Import.SecretDefinition;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class AgentConfiguration {
private final long pollInterval;
private final int maintenanceModeListenerPort;

private final boolean explicitlyResolveV1Client;

@Inject
public AgentConfiguration(Config cfg) {
this.agentId = getStringOrDefault(cfg, "id", () -> UUID.randomUUID().toString());
Expand All @@ -82,6 +84,8 @@ public AgentConfiguration(Config cfg) {
this.maintenanceModeListenerPort = cfg.getInt("maintenanceModeListenerPort");

this.pollInterval = cfg.getDuration("pollInterval", TimeUnit.MILLISECONDS);

this.explicitlyResolveV1Client = cfg.getBoolean("explicitlyResolveV1Client");
}

public String getAgentId() {
Expand Down Expand Up @@ -139,4 +143,8 @@ public long getPollInterval() {
public int getMaintenanceModeListenerPort() {
return maintenanceModeListenerPort;
}

public boolean isExplicitlyResolveV1Client() {
return explicitlyResolveV1Client;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import com.typesafe.config.Config;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.time.Duration;

import static com.walmartlabs.concord.agent.cfg.Utils.getStringOrDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public DependencyManagerConfiguration get() {
.cacheDir(cfg.getDependencyCacheDir())
.strictRepositories(cfg.dependencyStrictRepositories())
.exclusions(cfg.dependencyExclusions())
.explicitlyResolveV1Client(cfg.isExplicitlyResolveV1Client())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import com.walmartlabs.concord.ApiClient;
import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.agent.DefaultStateFetcher;
import com.walmartlabs.concord.agent.StateFetcher;
import com.walmartlabs.concord.agent.logging.*;
import com.walmartlabs.concord.agent.remote.ApiClientFactory;
import com.walmartlabs.concord.agent.remote.ProcessStatusUpdater;
import com.walmartlabs.concord.client.ProcessApi;
import com.walmartlabs.concord.client.SecretClient;
import com.walmartlabs.concord.dependencymanager.DependencyManagerConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.walmartlabs.concord.client.LogSegmentUpdateRequest;
import com.walmartlabs.concord.client2.LogSegmentUpdateRequest;
import org.immutables.value.Value;

import javax.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -20,17 +20,13 @@
* =====
*/

import com.walmartlabs.concord.ApiClient;
import com.walmartlabs.concord.ApiException;
import com.walmartlabs.concord.agent.AgentConstants;
import com.walmartlabs.concord.client.ClientUtils;
import com.walmartlabs.concord.client.LogSegmentUpdateRequest;
import com.walmartlabs.concord.client.ProcessApi;
import com.walmartlabs.concord.client.ProcessLogV2Api;
import com.walmartlabs.concord.client2.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.io.ByteArrayInputStream;
import java.util.UUID;

public class RemoteLogAppender implements LogAppender {
Expand All @@ -48,11 +44,9 @@ public RemoteLogAppender(ApiClient apiClient) {

@Override
public void appendLog(UUID instanceId, byte[] ab) {
String path = "/api/v1/process/" + instanceId + "/log";

try {
ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> {
ClientUtils.postData(processApi.getApiClient(), path, ab);
processApi.appendProcessLog(instanceId, new ByteArrayInputStream(ab));
return null;
});
} catch (ApiException e) {
Expand All @@ -63,11 +57,9 @@ public void appendLog(UUID instanceId, byte[] ab) {

@Override
public boolean appendLog(UUID instanceId, long segmentId, byte[] ab) {
String path = "/api/v2/process/" + instanceId + "/log/segment/" + segmentId + "/data";

try {
ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> {
ClientUtils.postData(processApi.getApiClient(), path, ab);
processLogV2Api.appendProcessLogSegment(instanceId, segmentId, new ByteArrayInputStream(ab));
return null;
});
return true;
Expand All @@ -81,17 +73,17 @@ public boolean appendLog(UUID instanceId, long segmentId, byte[] ab) {
@Override
public boolean updateSegment(UUID instanceId, long segmentId, LogSegmentStats stats) {
LogSegmentUpdateRequest request = new LogSegmentUpdateRequest()
.setStatus(stats.status())
.setWarnings(stats.warnings())
.setErrors(stats.errors());
.status(stats.status())
.warnings(stats.warnings())
.errors(stats.errors());

try {
ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY,
() -> processLogV2Api.updateSegment(instanceId, segmentId, request));
() -> processLogV2Api.updateProcessLogSegment(instanceId, segmentId, request));
return true;
} catch (Exception e) {
log.warn("updateSegment ['{}', '{}', '{}'] -> error: {}", instanceId, segmentId, stats, e.getMessage());
}
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* =====
*/

import com.walmartlabs.concord.client.LogSegmentUpdateRequest;
import com.walmartlabs.concord.client2.LogSegmentUpdateRequest;

import java.util.*;
import java.util.function.Consumer;
Expand Down
Loading