Skip to content

Commit 6d3a01d

Browse files
authored
feat: [DEL-4338]: Change versioning of immutable delegate (#35396)
* [DEL-4337]: separate version for immutable delegates * [DEL-4338]: Separate build.prop for 260-delegate * [DEL-4338]: metrics addition
1 parent 0865729 commit 6d3a01d

8 files changed

Lines changed: 55 additions & 0 deletions

File tree

260-delegate/build.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build.majorVersion=22
2+
build.minorVersion=7
3+
build.number=76100
4+
build.patch=000

260-delegate/src/main/java/io/harness/delegate/service/DelegateAgentServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ private void initDelegateProcess(final boolean watched) {
594594
.sampleDelegate(isSample)
595595
.location(Paths.get("").toAbsolutePath().toString())
596596
.heartbeatAsObject(true)
597+
.immutable(isImmutableDelegate)
597598
.ceEnabled(Boolean.parseBoolean(System.getenv("ENABLE_CE")));
598599

599600
delegateId = registerDelegate(builder);

400-rest/src/main/java/software/wings/service/impl/DelegateServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import static io.harness.metrics.impl.DelegateMetricsServiceImpl.DELEGATE_DISCONNECTED;
3737
import static io.harness.metrics.impl.DelegateMetricsServiceImpl.DELEGATE_REGISTRATION_FAILED;
3838
import static io.harness.metrics.impl.DelegateMetricsServiceImpl.DELEGATE_RESTARTED;
39+
import static io.harness.metrics.impl.DelegateMetricsServiceImpl.IMMUTABLE_DELEGATES;
40+
import static io.harness.metrics.impl.DelegateMetricsServiceImpl.MUTABLE_DELEGATES;
3941
import static io.harness.mongo.MongoUtils.setUnset;
4042
import static io.harness.obfuscate.Obfuscator.obfuscate;
4143
import static io.harness.persistence.HQuery.excludeAuthority;
@@ -2591,6 +2593,10 @@ public DelegateRegisterResponse register(final DelegateParams delegateParams) {
25912593

25922594
log.info("Registering delegate for Hostname: {} IP: {}", delegateParams.getHostName(), delegateParams.getIp());
25932595

2596+
// publish delegateType metrics at account level.
2597+
String delegateTypeMetric = delegateParams.isImmutable() ? IMMUTABLE_DELEGATES : MUTABLE_DELEGATES;
2598+
delegateMetricsService.recordDelegateMetricsPerAccount(delegateParams.getAccountId(), delegateTypeMetric);
2599+
25942600
String delegateGroupId = delegateParams.getDelegateGroupId();
25952601
if (isBlank(delegateGroupId) && isNotBlank(delegateParams.getDelegateGroupName())) {
25962602
final DelegateGroup delegateGroup =
@@ -2674,6 +2680,7 @@ public DelegateRegisterResponse register(final DelegateParams delegateParams) {
26742680
.ceEnabled(delegateParams.isCeEnabled())
26752681
.delegateTokenName(delegateTokenName.orElse(null))
26762682
.heartbeatAsObject(delegateParams.isHeartbeatAsObject())
2683+
.immutable(delegateParams.isImmutable())
26772684
.build();
26782685

26792686
if (ECS.equals(delegateParams.getDelegateType())) {

400-rest/src/main/resources/metrics/metricDefinitions/delegate_metrics.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ metrics:
2222
metricDefinition: Delegate self destruct
2323
type: Count
2424
unit: "1"
25+
- metricName: immutable_delegates
26+
metricDefinition: Immutable delegate count
27+
type: Count
28+
unit: "1"
29+
- metricName: mutable_delegates
30+
metricDefinition: Mutable delegate count
31+
type: Count
32+
unit: "1"
2533

420-delegate-service/src/main/java/io/harness/delegate/beans/Delegate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public static List<MongoIndex> mongoIndexes() {
126126

127127
private boolean heartbeatAsObject;
128128

129+
private boolean immutable;
130+
129131
@Override
130132
public void updateNextIteration(String fieldName, long nextIteration) {
131133
if (DelegateKeys.taskExpiryCheckNextIteration.equals(fieldName)) {

420-delegate-service/src/main/java/io/harness/metrics/impl/DelegateMetricsServiceImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public class DelegateMetricsServiceImpl implements DelegateMetricsService {
5858
public static final String SECRETS_CACHE_LOOKUPS = "delegate_secret_cache_lookups";
5959
public static final String SECRETS_CACHE_INSERTS = "delegate_secret_cache_inserts";
6060

61+
public static final String IMMUTABLE_DELEGATES = "immutable_delegates";
62+
63+
public static final String MUTABLE_DELEGATES = "mutable_delegates";
64+
6165
@Inject private MetricService metricService;
6266
@Inject private DelegateTaskMetricContextBuilder metricContextBuilder;
6367

920-delegate-agent-beans/src/main/java/io/harness/delegate/beans/DelegateParams.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class DelegateParams {
5050
boolean proxy;
5151
boolean ceEnabled;
5252
boolean heartbeatAsObject;
53+
boolean immutable;
5354

5455
List<String> supportedTaskTypes;
5556

scripts/jenkins/release-branch.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,34 @@ git commit -m "Branching to release/${PURPOSE}/${VERSION}xx. New version ${NEW_V
146146
git push origin develop
147147
print_err "$?" "Pushing build.properties to develop branch failed"
148148

149+
# Bumping version in delegate's build.properties in develop branch.
150+
# TODO: This will be separated to different release-branch.sh in 260-delegate when we separate release branch for delegate.
151+
echo "STEP3: INFO: Bumping version in delegate's build.properties in develop branch."
152+
git fetch origin refs/heads/develop; git checkout develop && git branch
153+
check_branch_name "develop"
154+
155+
export DELEGATE_VERSION_FILE=260-delegate/build.properties
156+
157+
export VERSION=`cat ${DELEGATE_VERSION_FILE} | grep 'build.number=' | sed -e 's: *build.number=::g'`
158+
export MAJOR_VERSION=`cat ${DELEGATE_VERSION_FILE} | grep 'build.majorVersion=' | sed -e 's: *build.majorVersion=::g'`
159+
export MINOR_VERSION=`cat ${DELEGATE_VERSION_FILE} | grep 'build.minorVersion=' | sed -e 's: *build.minorVersion=::g'`
160+
161+
YEAR=$(date +%y)
162+
MONTH=$(date +%m)
163+
164+
export VERSION=${VERSION%??}
165+
export NEW_VERSION=$(( ${VERSION}+1 ))
166+
167+
sed -i "s:build.number=${VERSION}00:build.number=${NEW_VERSION}00:g" ${DELEGATE_VERSION_FILE}
168+
sed -i "s:build.majorVersion=${MAJOR_VERSION}:build.majorVersion=${YEAR}:g" ${DELEGATE_VERSION_FILE}
169+
sed -i "s:build.minorVersion=${MINOR_VERSION}:build.minorVersion=${MONTH}:g" ${DELEGATE_VERSION_FILE}
170+
171+
172+
git add ${DELEGATE_VERSION_FILE}
173+
git commit -m "Branching to release/${PURPOSE}/${VERSION}xx. New version ${NEW_VERSION}xx"
174+
git push origin develop
175+
print_err "$?" "Pushing delegate build.properties to develop branch failed"
176+
149177
# Update jira issues
150178
echo "STEP4: INFO: Update jira issues"
151179
git fetch origin refs/heads/master; git checkout master && git branch

0 commit comments

Comments
 (0)