Skip to content

Commit 89db8a2

Browse files
committed
merge latest changes from main
2 parents b042167 + fd3d605 commit 89db8a2

File tree

99 files changed

+2299
-861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2299
-861
lines changed

.asf.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ github:
5454
- gpordeus
5555
- hsato03
5656
- bernardodemarco
57-
- abh1sar
5857
- FelipeM525
5958
- lucas-a-martins
6059
- nicoschmdt
60+
- abh1sar
61+
- sudo87
6162

6263
protected_branches: ~
6364

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Contributing to Apache CloudStack (ACS)
44
Summary
55
-------
66
This document covers how to contribute to the ACS project. ACS uses GitHub PRs to manage code contributions.
7-
These instructions assume you have a GitHub.com account, so if you don't have one you will have to create one. Your proposed code changes will be published to your own fork of the ACS project and you will submit a Pull Request for your changes to be added.
7+
These instructions assume you have a GitHub.com account, so if you don't have one you will have to create one. Your proposed code changes will be published to your own fork of the ACS project, and you will submit a Pull Request for your changes to be added.
88

9-
_Lets get started!!!_
9+
_Let's get started!!!_
1010

1111
Bug fixes
1212
---------
@@ -26,7 +26,7 @@ No back porting / cherry-picking features to existing branches!
2626

2727
PendingReleaseNotes file
2828
------------------------
29-
When developing a new feature or making a (major) change to a existing feature you are encouraged to append this to the PendingReleaseNotes file so that the Release Manager can
29+
When developing a new feature or making a (major) change to an existing feature you are encouraged to append this to the PendingReleaseNotes file so that the Release Manager can
3030
use this file as a source of information when compiling the Release Notes for a new release.
3131

3232
When adding information to the PendingReleaseNotes file make sure that you write a good and understandable description of the new feature or change which you have developed.
@@ -38,9 +38,9 @@ Fork the code
3838

3939
In your browser, navigate to: [https://github.com/apache/cloudstack](https://github.com/apache/cloudstack)
4040

41-
Fork the repository by clicking on the 'Fork' button on the top right hand side. The fork will happen and you will be taken to your own fork of the repository. Copy the Git repository URL by clicking on the clipboard next to the URL on the right hand side of the page under '**HTTPS** clone URL'. You will paste this URL when doing the following `git clone` command.
41+
Fork the repository by clicking on the 'Fork' button on the top right hand side. The fork will happen, and you will be taken to your own fork of the repository. Copy the Git repository URL by clicking on the clipboard next to the URL on the right hand side of the page under '**HTTPS** clone URL'. You will paste this URL when doing the following `git clone` command.
4242

43-
On your computer, follow these steps to setup a local repository for working on ACS:
43+
On your computer, follow these steps to set up a local repository for working on ACS:
4444

4545
```bash
4646
$ git clone https://github.com/YOUR_ACCOUNT/cloudstack.git
@@ -92,9 +92,9 @@ $ git rebase main
9292
Make a GitHub Pull Request to contribute your changes
9393
-----------------------------------------------------
9494

95-
When you are happy with your changes and you are ready to contribute them, you will create a Pull Request on GitHub to do so. This is done by pushing your local changes to your forked repository (default remote name is `origin`) and then initiating a pull request on GitHub.
95+
When you are happy with your changes, and you are ready to contribute them, you will create a Pull Request on GitHub to do so. This is done by pushing your local changes to your forked repository (default remote name is `origin`) and then initiating a pull request on GitHub.
9696

97-
Please include JIRA id, detailed information about the bug/feature, what all tests are executed, how the reviewer can test this feature etc. Incase of UI PRs, a screenshot is preferred.
97+
Please include JIRA id, detailed information about the bug/feature, what all tests are executed, how the reviewer can test this feature etc. In case of UI PRs, a screenshot is preferred.
9898

9999
> **IMPORTANT:** Make sure you have rebased your `feature_x` branch to include the latest code from `upstream/main` _before_ you do this.
100100

INSTALL.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Setup up NodeJS (LTS):
3737
Start the MySQL service:
3838

3939
$ service mysqld start
40+
$ mysql_secure_installation
4041

4142
### Using jenv and/or pyenv for Version Management
4243

@@ -86,13 +87,33 @@ Start the management server:
8687

8788
If this works, you've successfully setup a single server Apache CloudStack installation.
8889

89-
Open the following URL on your browser to access the Management Server UI:
90-
91-
http://localhost:8080/client/
90+
To access the Management Server UI, follow the following procedure:
9291

9392
The default credentials are; user: admin, password: password and the domain
9493
field should be left blank which is defaulted to the ROOT domain.
9594

95+
## To bring up CloudStack UI
96+
97+
Move to UI Directory
98+
99+
$ cd /path/to/cloudstack/ui
100+
101+
To install dependencies.
102+
103+
$ npm install
104+
105+
To build the project.
106+
107+
$ npm build
108+
109+
For Development Mode.
110+
111+
$ npm start
112+
113+
Make sure to set CS_URL=http://localhost:8080/client on .env.local file on ui.
114+
115+
You should be able to run the management server on http://localhost:5050
116+
96117
## Building with non-redistributable plugins
97118

98119
CloudStack supports several plugins that depend on libraries with distribution restrictions.

agent/bindir/cloud-setup-agent.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ import os
2020
import logging
2121
import sys
2222
import socket
23+
24+
# ---- This snippet of code adds the sources path and the waf configured PYTHONDIR to the Python path ----
25+
# ---- We do this so cloud_utils can be looked up in the following order:
26+
# ---- 1) Sources directory
27+
# ---- 2) waf configured PYTHONDIR
28+
# ---- 3) System Python path
29+
for pythonpath in (
30+
"@PYTHONDIR@",
31+
os.path.join(os.path.dirname(__file__),os.path.pardir,os.path.pardir,"python","lib"),
32+
):
33+
if os.path.isdir(pythonpath): sys.path.insert(0,pythonpath)
34+
# ---- End snippet of code ----
35+
2336
from cloudutils.cloudException import CloudRuntimeException, CloudInternalException
2437
from cloudutils.utilities import initLoging, bash
2538
from cloudutils.configFileOps import configFileOps

agent/bindir/libvirtqemuhook.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ import sys
2020
import os
2121
import subprocess
2222
from threading import Timer
23+
24+
# ---- This snippet of code adds the sources path and the waf configured PYTHONDIR to the Python path ----
25+
# ---- We do this so cloud_utils can be looked up in the following order:
26+
# ---- 1) Sources directory
27+
# ---- 2) waf configured PYTHONDIR
28+
# ---- 3) System Python path
29+
for pythonpath in (
30+
"@PYTHONDIR@",
31+
os.path.join(os.path.dirname(__file__),os.path.pardir,os.path.pardir,"python","lib"),
32+
):
33+
if os.path.isdir(pythonpath): sys.path.insert(0,pythonpath)
34+
# ---- End snippet of code ----
35+
2336
from xml.dom.minidom import parse
2437
from cloudutils.configFileOps import configFileOps
2538
from cloudutils.networkConfig import networkConfig

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public void start() {
342342
logger.info("Attempted to connect to the server, but received an unexpected exception, trying again...", e);
343343
}
344344
}
345-
shell.updateConnectedHost();
345+
shell.updateConnectedHost(((NioClient)connection).getHost());
346346
scavengeOldAgentObjects();
347347
}
348348

@@ -617,15 +617,11 @@ public Task create(final Task.Type type, final Link link, final byte[] data) {
617617
}
618618

619619
protected void reconnect(final Link link) {
620-
reconnect(link, null, null, false);
620+
reconnect(link, null, false);
621621
}
622622

623-
protected void reconnect(final Link link, String preferredHost, List<String> avoidHostList, boolean forTransfer) {
623+
protected void reconnect(final Link link, String preferredMSHost, boolean forTransfer) {
624624
if (!(forTransfer || reconnectAllowed)) {
625-
return;
626-
}
627-
628-
if (!reconnectAllowed) {
629625
logger.debug("Reconnect requested but it is not allowed {}", () -> getLinkLog(link));
630626
return;
631627
}
@@ -637,19 +633,26 @@ protected void reconnect(final Link link, String preferredHost, List<String> avo
637633
serverResource.disconnected();
638634
logger.info("Lost connection to host: {}. Attempting reconnection while we still have {} commands in progress.", shell.getConnectedHost(), commandsInProgress.get());
639635
stopAndCleanupConnection(true);
636+
String host = preferredMSHost;
637+
if (org.apache.commons.lang3.StringUtils.isBlank(host)) {
638+
host = shell.getNextHost();
639+
}
640+
List<String> avoidMSHostList = shell.getAvoidHosts();
640641
do {
641-
final String host = shell.getNextHost();
642-
connection = new NioClient(getAgentName(), host, shell.getPort(), shell.getWorkers(), shell.getSslHandshakeTimeout(), this);
643-
logger.info("Reconnecting to host: {}", host);
644-
try {
645-
connection.start();
646-
} catch (final NioConnectionException e) {
647-
logger.info("Attempted to re-connect to the server, but received an unexpected exception, trying again...", e);
648-
stopAndCleanupConnection(false);
642+
if (CollectionUtils.isEmpty(avoidMSHostList) || !avoidMSHostList.contains(host)) {
643+
connection = new NioClient(getAgentName(), host, shell.getPort(), shell.getWorkers(), shell.getSslHandshakeTimeout(), this);
644+
logger.info("Reconnecting to host: {}", host);
645+
try {
646+
connection.start();
647+
} catch (final NioConnectionException e) {
648+
logger.info("Attempted to re-connect to the server, but received an unexpected exception, trying again...", e);
649+
stopAndCleanupConnection(false);
650+
}
649651
}
650652
shell.getBackoffAlgorithm().waitBeforeRetry();
653+
host = shell.getNextHost();
651654
} while (!connection.isStartup());
652-
shell.updateConnectedHost();
655+
shell.updateConnectedHost(((NioClient)connection).getHost());
653656
logger.info("Connected to the host: {}", shell.getConnectedHost());
654657
}
655658

@@ -922,7 +925,7 @@ private Answer setupAgentCertificate(final SetupCertificateCommand cmd) {
922925
return new SetupCertificateAnswer(true);
923926
}
924927

925-
private void processManagementServerList(final List<String> msList, final String lbAlgorithm, final Long lbCheckInterval) {
928+
private void processManagementServerList(final List<String> msList, final List<String> avoidMsList, final String lbAlgorithm, final Long lbCheckInterval) {
926929
if (CollectionUtils.isNotEmpty(msList) && StringUtils.isNotEmpty(lbAlgorithm)) {
927930
try {
928931
final String newMSHosts = String.format("%s%s%s", com.cloud.utils.StringUtils.toCSVList(msList), IAgentShell.hostLbAlgorithmSeparator, lbAlgorithm);
@@ -934,6 +937,7 @@ private void processManagementServerList(final List<String> msList, final String
934937
throw new CloudRuntimeException("Could not persist received management servers list", e);
935938
}
936939
}
940+
shell.setAvoidHosts(avoidMsList);
937941
if ("shuffle".equals(lbAlgorithm)) {
938942
scheduleHostLBCheckerTask(0);
939943
} else {
@@ -942,16 +946,18 @@ private void processManagementServerList(final List<String> msList, final String
942946
}
943947

944948
private Answer setupManagementServerList(final SetupMSListCommand cmd) {
945-
processManagementServerList(cmd.getMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval());
949+
processManagementServerList(cmd.getMsList(), cmd.getAvoidMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval());
946950
return new SetupMSListAnswer(true);
947951
}
948952

949953
private Answer migrateAgentToOtherMS(final MigrateAgentConnectionCommand cmd) {
950954
try {
951955
if (CollectionUtils.isNotEmpty(cmd.getMsList())) {
952-
processManagementServerList(cmd.getMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval());
956+
processManagementServerList(cmd.getMsList(), cmd.getAvoidMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval());
953957
}
954-
migrateAgentConnection(cmd.getAvoidMsList());
958+
Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("MigrateAgentConnection-Job")).schedule(() -> {
959+
migrateAgentConnection(cmd.getAvoidMsList());
960+
}, 3, TimeUnit.SECONDS);
955961
} catch (Exception e) {
956962
String errMsg = "Migrate agent connection failed, due to " + e.getMessage();
957963
logger.debug(errMsg, e);
@@ -972,25 +978,26 @@ private void migrateAgentConnection(List<String> avoidMsList) {
972978
throw new CloudRuntimeException("No other Management Server hosts to migrate");
973979
}
974980

975-
String preferredHost = null;
981+
String preferredMSHost = null;
976982
for (String msHost : msHostsList) {
977983
try (final Socket socket = new Socket()) {
978984
socket.connect(new InetSocketAddress(msHost, shell.getPort()), 5000);
979-
preferredHost = msHost;
985+
preferredMSHost = msHost;
980986
break;
981987
} catch (final IOException e) {
982988
throw new CloudRuntimeException("Management server host: " + msHost + " is not reachable, to migrate connection");
983989
}
984990
}
985991

986-
if (preferredHost == null) {
992+
if (preferredMSHost == null) {
987993
throw new CloudRuntimeException("Management server host(s) are not reachable, to migrate connection");
988994
}
989995

990-
logger.debug("Management server host " + preferredHost + " is found to be reachable, trying to reconnect");
996+
logger.debug("Management server host " + preferredMSHost + " is found to be reachable, trying to reconnect");
991997
shell.resetHostCounter();
998+
shell.setAvoidHosts(avoidMsList);
992999
shell.setConnectionTransfer(true);
993-
reconnect(link, preferredHost, avoidMsList, true);
1000+
reconnect(link, preferredMSHost, true);
9941001
}
9951002

9961003
public void processResponse(final Response response, final Link link) {
@@ -1003,14 +1010,21 @@ public void processResponse(final Response response, final Link link) {
10031010
for (final IAgentControlListener listener : controlListeners) {
10041011
listener.processControlResponse(response, (AgentControlAnswer)answer);
10051012
}
1006-
} else if (answer instanceof PingAnswer && (((PingAnswer) answer).isSendStartup()) && reconnectAllowed) {
1007-
logger.info("Management server requested startup command to reinitialize the agent");
1008-
sendStartup(link);
1013+
} else if (answer instanceof PingAnswer) {
1014+
processPingAnswer((PingAnswer) answer);
10091015
} else {
10101016
updateLastPingResponseTime();
10111017
}
10121018
}
10131019

1020+
private void processPingAnswer(final PingAnswer answer) {
1021+
if ((answer.isSendStartup()) && reconnectAllowed) {
1022+
logger.info("Management server requested startup command to reinitialize the agent");
1023+
sendStartup(link);
1024+
}
1025+
shell.setAvoidHosts(answer.getAvoidMsList());
1026+
}
1027+
10141028
public void processReadyCommand(final Command cmd) {
10151029
final ReadyCommand ready = (ReadyCommand)cmd;
10161030
// Set human readable sizes;
@@ -1027,7 +1041,7 @@ public void processReadyCommand(final Command cmd) {
10271041
}
10281042

10291043
verifyAgentArch(ready.getArch());
1030-
processManagementServerList(ready.getMsHostList(), ready.getLbAlgorithm(), ready.getLbCheckInterval());
1044+
processManagementServerList(ready.getMsHostList(), ready.getAvoidMsHostList(), ready.getLbAlgorithm(), ready.getLbCheckInterval());
10311045

10321046
logger.info("Ready command is processed for agent [id: {}, uuid: {}, name: {}]", getId(), getUuid(), getName());
10331047
}
@@ -1374,26 +1388,26 @@ protected void runInContext() {
13741388
if (msList == null || msList.length < 1) {
13751389
return;
13761390
}
1377-
final String preferredHost = msList[0];
1391+
final String preferredMSHost = msList[0];
13781392
final String connectedHost = shell.getConnectedHost();
13791393
logger.debug("Running preferred host checker task, connected host={}, preferred host={}",
1380-
connectedHost, preferredHost);
1381-
if (preferredHost == null || preferredHost.equals(connectedHost) || link == null) {
1394+
connectedHost, preferredMSHost);
1395+
if (preferredMSHost == null || preferredMSHost.equals(connectedHost) || link == null) {
13821396
return;
13831397
}
13841398
boolean isHostUp = false;
13851399
try (final Socket socket = new Socket()) {
1386-
socket.connect(new InetSocketAddress(preferredHost, shell.getPort()), 5000);
1400+
socket.connect(new InetSocketAddress(preferredMSHost, shell.getPort()), 5000);
13871401
isHostUp = true;
13881402
} catch (final IOException e) {
1389-
logger.debug("Host: {} is not reachable", preferredHost);
1403+
logger.debug("Host: {} is not reachable", preferredMSHost);
13901404
}
13911405
if (isHostUp && link != null && commandsInProgress.get() == 0) {
13921406
if (logger.isDebugEnabled()) {
1393-
logger.debug("Preferred host {} is found to be reachable, trying to reconnect", preferredHost);
1407+
logger.debug("Preferred host {} is found to be reachable, trying to reconnect", preferredMSHost);
13941408
}
13951409
shell.resetHostCounter();
1396-
reconnect(link);
1410+
reconnect(link, preferredMSHost, false);
13971411
}
13981412
} catch (Throwable t) {
13991413
logger.error("Error caught while attempting to connect to preferred host", t);

0 commit comments

Comments
 (0)