From 62741a54d2b767d05b762a2c8a37d25ce5c359d5 Mon Sep 17 00:00:00 2001 From: Railag Date: Tue, 29 Jan 2019 19:42:02 +0300 Subject: [PATCH 01/21] Master -> Develop merge (#198) --- client/pom.xml | 2 +- daemon/pom.xml | 2 +- iofog_version_controller/pom.xml | 2 +- pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index 7a45902a..44f4b580 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -16,7 +16,7 @@ org.eclipse iofog-agent - 1.0.10 + 1.0.11 ../pom.xml diff --git a/daemon/pom.xml b/daemon/pom.xml index b4728540..81a82987 100644 --- a/daemon/pom.xml +++ b/daemon/pom.xml @@ -16,7 +16,7 @@ org.eclipse iofog-agent - 1.0.10 + 1.0.11 ../pom.xml diff --git a/iofog_version_controller/pom.xml b/iofog_version_controller/pom.xml index 17651632..c9650016 100644 --- a/iofog_version_controller/pom.xml +++ b/iofog_version_controller/pom.xml @@ -16,7 +16,7 @@ iofog-agent org.eclipse - 1.0.10 + 1.0.11 4.0.0 diff --git a/pom.xml b/pom.xml index 9825025c..197ef635 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 4.0.0 org.eclipse iofog-agent - 1.0.10 + 1.0.11 iofog-agent pom From f201d808748641ece41d78713d77e92eb2c764d3 Mon Sep 17 00:00:00 2001 From: MaksimChepelev Date: Wed, 30 Jan 2019 15:48:43 +0300 Subject: [PATCH 02/21] feat(tracking) tracking (ENG-260) --- .../iofog/command_line/CommandLineAction.java | 4 + .../eclipse/iofog/field_agent/FieldAgent.java | 23 +- .../eclipse/iofog/supervisor/Supervisor.java | 5 + .../org/eclipse/iofog/tracking/Tracker.java | 224 ++++++++++++++++++ .../eclipse/iofog/tracking/TrackingEvent.java | 68 ++++++ .../iofog/tracking/TrackingEventType.java | 21 ++ .../iofog/tracking/TrackingEventsStorage.java | 20 ++ .../iofog/tracking/TrackingInfoUtils.java | 44 ++++ .../org/eclipse/iofog/utils/Constants.java | 5 +- .../utils/configuration/Configuration.java | 12 +- 10 files changed, 423 insertions(+), 3 deletions(-) create mode 100644 daemon/src/org/eclipse/iofog/tracking/Tracker.java create mode 100644 daemon/src/org/eclipse/iofog/tracking/TrackingEvent.java create mode 100644 daemon/src/org/eclipse/iofog/tracking/TrackingEventType.java create mode 100644 daemon/src/org/eclipse/iofog/tracking/TrackingEventsStorage.java create mode 100644 daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java diff --git a/daemon/src/org/eclipse/iofog/command_line/CommandLineAction.java b/daemon/src/org/eclipse/iofog/command_line/CommandLineAction.java index 4e9e9462..f342cbab 100644 --- a/daemon/src/org/eclipse/iofog/command_line/CommandLineAction.java +++ b/daemon/src/org/eclipse/iofog/command_line/CommandLineAction.java @@ -14,6 +14,8 @@ package org.eclipse.iofog.command_line; import org.eclipse.iofog.field_agent.FieldAgent; +import org.eclipse.iofog.tracking.Tracker; +import org.eclipse.iofog.tracking.TrackingEventType; import org.eclipse.iofog.utils.Constants.ConfigSwitcherState; import org.eclipse.iofog.utils.configuration.Configuration; import org.eclipse.iofog.utils.logging.LoggingService; @@ -114,6 +116,7 @@ public String perform(String[] args) { status = "Error"; LoggingService.logInfo(MODULE_NAME, "error de-provisioning"); } + Tracker.getInstance().handleEvent(TrackingEventType.DEPROVISION, status); return format(getDeprovisionMessage(), status); } }, @@ -170,6 +173,7 @@ public String perform(String[] args) { } else { result = format(getProvisionStatusErrorMessage(), provisioningResult.getString("errorMessage")); } + Tracker.getInstance().handleEvent(TrackingEventType.PROVISION, result); return format(getProvisionMessage(), provisionKey, result); } }, diff --git a/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java b/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java index 133037d2..fe93d2d2 100644 --- a/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java +++ b/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java @@ -28,6 +28,10 @@ import org.eclipse.iofog.proxy.SshConnection; import org.eclipse.iofog.proxy.SshProxyManager; import org.eclipse.iofog.status_reporter.StatusReporter; +import org.eclipse.iofog.tracking.Tracker; +import org.eclipse.iofog.tracking.TrackingEventType; +import org.eclipse.iofog.tracking.TrackingInfoUtils; +import org.eclipse.iofog.utils.Constants; import org.eclipse.iofog.utils.Orchestrator; import org.eclipse.iofog.utils.configuration.Configuration; import org.eclipse.iofog.utils.logging.LoggingService; @@ -223,6 +227,14 @@ private boolean notProvisioned() { } }; + public final void postTracking(JsonObject events) { + try { + orchestrator.request("tracking", RequestType.POST, null, events); + } catch (Exception e) { + logWarning("Unable to send tracking logs : " + e.getMessage()); + } + } + /** * logs and sets appropriate status when controller * certificate is not verified @@ -301,6 +313,9 @@ private void verificationFailed(Exception e) { processRoutes(microservices); MessageBus.getInstance().update(); } + + Tracker.getInstance().handleEvent(TrackingEventType.MICROSERVICE, + loadMicroservicesJsonFile()); } if (changes.getBoolean("tunnel") && !initialization) { sshProxyManager.update(getProxyConfig()); @@ -473,6 +488,12 @@ private void processRoutes(List microservices) { microserviceManager.setRoutes(routes); } + private JsonArray loadMicroservicesJsonFile() { + String filename = MICROSERVICE_FILE; + JsonArray microservicesJson = readFile(filesPath + filename); + return microservicesJson; + } + /** * gets list of Microservices from file or IOFog controller * @@ -484,7 +505,7 @@ private List loadMicroservices(boolean fromFile) { return new ArrayList<>(); } - String filename = "microservices.json"; + String filename = MICROSERVICE_FILE; JsonArray microservicesJson; try { if (fromFile) { diff --git a/daemon/src/org/eclipse/iofog/supervisor/Supervisor.java b/daemon/src/org/eclipse/iofog/supervisor/Supervisor.java index 2fdd613d..a17684b6 100644 --- a/daemon/src/org/eclipse/iofog/supervisor/Supervisor.java +++ b/daemon/src/org/eclipse/iofog/supervisor/Supervisor.java @@ -20,6 +20,9 @@ import org.eclipse.iofog.resource_consumption_manager.ResourceConsumptionManager; import org.eclipse.iofog.resource_manager.ResourceManager; import org.eclipse.iofog.status_reporter.StatusReporter; +import org.eclipse.iofog.tracking.Tracker; +import org.eclipse.iofog.tracking.TrackingEventType; +import org.eclipse.iofog.tracking.TrackingInfoUtils; import org.eclipse.iofog.utils.configuration.Configuration; import org.eclipse.iofog.utils.logging.LoggingService; @@ -85,6 +88,7 @@ public void start() throws Exception { startModule(FieldAgent.getInstance()); startModule(ProcessManager.getInstance()); startModule(new ResourceManager()); + startModule(Tracker.getInstance()); messageBus = MessageBus.getInstance(); startModule(messageBus); @@ -96,6 +100,7 @@ public void start() throws Exception { StatusReporter.setSupervisorStatus().setDaemonStatus(RUNNING); logInfo("started"); + Tracker.getInstance().handleEvent(TrackingEventType.START, TrackingInfoUtils.getStartTrackingInfo()); operationDuration(); } diff --git a/daemon/src/org/eclipse/iofog/tracking/Tracker.java b/daemon/src/org/eclipse/iofog/tracking/Tracker.java new file mode 100644 index 00000000..05360124 --- /dev/null +++ b/daemon/src/org/eclipse/iofog/tracking/Tracker.java @@ -0,0 +1,224 @@ +package org.eclipse.iofog.tracking; + +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClients; +import org.eclipse.iofog.IOFogModule; +import org.eclipse.iofog.field_agent.FieldAgent; +import org.eclipse.iofog.status_reporter.StatusReporter; +import org.eclipse.iofog.utils.Constants; + +import javax.json.*; +import javax.xml.bind.DatatypeConverter; +import java.io.IOException; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.*; + +public class Tracker implements IOFogModule { + private final String MODULE_NAME = "Tracker"; + private static Tracker instance = null; + public static Tracker getInstance() { + if (instance == null) { + synchronized (Tracker.class) { + if (instance == null) + instance = new Tracker(); + } + } + return instance; + } + + private String uuid; + private Timer loggerTimer = null; + private Timer senderTimer = null; + private TrackingEventsStorage eventsStorage = new TrackingEventsStorage(); + @Override + public void start() throws Exception { + this.uuid = getUniqueTrackingUuid(); + + loggerTimer = new Timer(); + TimeLoggerTask timeLoggerTask = new TimeLoggerTask(); + loggerTimer.schedule(timeLoggerTask, + timeLoggerTask.getTimeTrackingTimeoutMin() * 60 * 1000, + timeLoggerTask.getTimeTrackingTimeoutMin() * 60 * 1000); + + senderTimer = new Timer(); + SenderTask senderTask = new SenderTask(); + senderTimer.schedule(senderTask, + senderTask.getSendTimeoutMin() * 60 * 1000, + senderTask.getSendTimeoutMin() * 60 * 1000); + } + + @Override + public int getModuleIndex() { + return Constants.TRACKER; + } + + @Override + public String getModuleName() { + return MODULE_NAME; + } + + private String getUniqueTrackingUuid() throws NoSuchAlgorithmException { + String id; + try { + List macs = getAllMacs(); + StringBuffer stringBuffer = new StringBuffer(); + macs.forEach(s -> stringBuffer.append(s + '-')); + + id = stringBuffer.toString(); + } catch (SocketException e) { + id = "random_" + generateRandomString(32); + } + + MessageDigest md5 = MessageDigest.getInstance("md5"); + byte[] digest = md5.digest(id.getBytes()); + id = DatatypeConverter.printHexBinary(digest); + + return id; + } + + private String generateRandomString(final int size) { + + StringBuffer randString = new StringBuffer(); + final String possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ"; + Random random = new Random(); + + for (int i = 0; i < size; i++) { + randString.append(possible.charAt(random.nextInt(possible.length()))); + } + + return randString.toString(); + } + + private List getAllMacs() throws SocketException { + List macs = new ArrayList<>(); + Enumeration networks = NetworkInterface.getNetworkInterfaces(); + NetworkInterface inter; + while (networks.hasMoreElements()) { + inter = networks.nextElement(); + if (!inter.isVirtual()) { + byte[] mac = inter.getHardwareAddress(); + if (mac != null) { + StringBuffer macStr = new StringBuffer(); + for (byte b : mac) { + String s = String.format("%02X", b); + macStr.append(s); + } + + macs.add(macStr.toString()); + } + } + } + return macs; + } + + public void handleEvent(TrackingEventType type, String value) { + JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder(); + JsonObject valueObj = null; + switch (type) { + case TIME: + valueObj = jsonObjectBuilder.add("deltaTime", value + " min").build(); + break; + case ERROR: + valueObj = jsonObjectBuilder.add("message", value).build(); + break; + case PROVISION: + valueObj = jsonObjectBuilder.add("provisionStatus", value).build(); + break; + case DEPROVISION: + valueObj = jsonObjectBuilder.add("deprovisionStatus", value).build(); + break; + default: + //other events types not handled because should be used with handleEvent(TrackingEventType type, JsonStructure value) method + throw new IllegalArgumentException("unhandled event type"); + } + handleEvent(type, valueObj); + } + + public void handleEvent(TrackingEventType type, JsonStructure value) { + TrackingEvent event = new TrackingEvent(this.uuid, new Date().getTime(), type, value); + eventsStorage.pushEvent(event); + } + + private class TimeLoggerTask extends TimerTask { + private final int timeTrackingTimeoutMin = 5; + private int iterations = 0; + + public int getTimeTrackingTimeoutMin() { + return timeTrackingTimeoutMin; + } + + @Override + public boolean cancel() { + return super.cancel(); + } + + @Override + public long scheduledExecutionTime() { + return super.scheduledExecutionTime(); + } + + @Override + public void run() { + iterations++; + handleEvent(TrackingEventType.TIME, Long.toString(iterations * timeTrackingTimeoutMin)); + } + } + + private class SenderTask extends TimerTask { + private final int sendTimeoutMin = 5; + HttpClient httpClient = HttpClients.createDefault(); + + public int getSendTimeoutMin() { + return sendTimeoutMin; + } + + @Override + public boolean cancel() { + return super.cancel(); + } + + @Override + public long scheduledExecutionTime() { + return super.scheduledExecutionTime(); + } + + @Override + public void run() { + List events = eventsStorage.popAllEvents(); + JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder(); + + events + .forEach(el -> { + jsonArrayBuilder.add(el.toJsonObject()); + }); + + JsonObject eventsListObject = Json.createObjectBuilder() + .add("events", jsonArrayBuilder.build()) + .build(); + + HttpPost postMethod = null; + if (StatusReporter.getFieldAgentStatus().getControllerStatus().equals(Constants.ControllerStatus.OK)) { + //send to controller + FieldAgent.getInstance().postTracking(eventsListObject); + } else { + //send directly + StringEntity requestEntity = new StringEntity(eventsListObject.toString(), ContentType.APPLICATION_JSON); + postMethod = new HttpPost("https://analytics.iofog.org/post"); + postMethod.setEntity(requestEntity); + + try { + HttpResponse response = httpClient.execute(postMethod); + } catch (IOException e) { + logWarning(e.getMessage()); + } + } + } + } +} diff --git a/daemon/src/org/eclipse/iofog/tracking/TrackingEvent.java b/daemon/src/org/eclipse/iofog/tracking/TrackingEvent.java new file mode 100644 index 00000000..2234f1fa --- /dev/null +++ b/daemon/src/org/eclipse/iofog/tracking/TrackingEvent.java @@ -0,0 +1,68 @@ +package org.eclipse.iofog.tracking; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonStructure; + +public class TrackingEvent { + private String uuid; + private String sourceType; + private Long timestamp; + private TrackingEventType type; + private JsonStructure data; + + public TrackingEvent(String uuid, Long timestamp, TrackingEventType type, JsonStructure data) { + this.uuid = uuid; + this.timestamp = timestamp; + this.sourceType = "agent"; + this.type = type; + this.data = data; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public Long getTimestamp() { + return timestamp; + } + + public void setTimestamp(Long timestamp) { + this.timestamp = timestamp; + } + + public TrackingEventType getType() { + return type; + } + + public void setType(TrackingEventType type) { + this.type = type; + } + + public JsonStructure getData() { + return data; + } + + public void setData(JsonStructure data) { + this.data = data; + } + + @Override + public String toString() { + return toJsonObject().toString(); + } + + public JsonObject toJsonObject() { + return Json.createObjectBuilder() + .add("uuid", uuid) + .add("timestamp", timestamp) + .add("sourceType", sourceType) + .add("type", type.getName()) + .add("data", data) + .build(); + } +} diff --git a/daemon/src/org/eclipse/iofog/tracking/TrackingEventType.java b/daemon/src/org/eclipse/iofog/tracking/TrackingEventType.java new file mode 100644 index 00000000..05ea5e9c --- /dev/null +++ b/daemon/src/org/eclipse/iofog/tracking/TrackingEventType.java @@ -0,0 +1,21 @@ +package org.eclipse.iofog.tracking; + +public enum TrackingEventType { + START("application started"), + PROVISION("provision"), + DEPROVISION("deprovision"), + CONFIG("config updated"), + TIME("running time"), + MICROSERVICE("microservices were updated"), + ERROR("error"); + + private String name; + + TrackingEventType(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/daemon/src/org/eclipse/iofog/tracking/TrackingEventsStorage.java b/daemon/src/org/eclipse/iofog/tracking/TrackingEventsStorage.java new file mode 100644 index 00000000..8f8593cd --- /dev/null +++ b/daemon/src/org/eclipse/iofog/tracking/TrackingEventsStorage.java @@ -0,0 +1,20 @@ +package org.eclipse.iofog.tracking; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +public class TrackingEventsStorage { + + private List events = new ArrayList<>(); + + protected synchronized void pushEvent(TrackingEvent event) { + events.add(event); + } + + protected synchronized List popAllEvents() { + List res = new ArrayList<>(events); + events.clear(); + return res; + } +} diff --git a/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java b/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java new file mode 100644 index 00000000..0b4538fa --- /dev/null +++ b/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java @@ -0,0 +1,44 @@ +package org.eclipse.iofog.tracking; + +import org.eclipse.iofog.status_reporter.StatusReporter; +import org.eclipse.iofog.utils.CmdProperties; +import org.eclipse.iofog.utils.configuration.Configuration; + +import javax.json.Json; +import javax.json.JsonObject; + +public class TrackingInfoUtils { + public static JsonObject getStartTrackingInfo() { + JsonObject startInfo = null; + try { + String gpsCoordinates = Configuration.getGpsCoordinates(); + String gpsMode = Configuration.getGpsMode().name(); + boolean developerMode = Configuration.isDeveloperMode(); + String networkInterface = Configuration.getNetworkInterfaceInfo(); + String version = CmdProperties.getVersion(); + String agentStatus = StatusReporter.getFieldAgentStatus().getControllerStatus().name().toLowerCase(); + + startInfo = Json.createObjectBuilder() + .add("gpsCoordinates", gpsCoordinates) + .add("gpsMode", gpsMode) + .add("developerMode", developerMode) + .add("networkInterface", networkInterface) + .add("version", version) + .add("agentStatus", agentStatus) + .build(); + + } catch(Exception e) { + startInfo = Json.createObjectBuilder() + .add("error", "can't parse start config") + .build(); + } + return startInfo; + } + + public static JsonObject getConfigUpdateInfo(String option, String newValue) { + JsonObject info = Json.createObjectBuilder() + .add(option, newValue) + .build(); + return info; + } +} diff --git a/daemon/src/org/eclipse/iofog/utils/Constants.java b/daemon/src/org/eclipse/iofog/utils/Constants.java index a5deb850..30ac817f 100755 --- a/daemon/src/org/eclipse/iofog/utils/Constants.java +++ b/daemon/src/org/eclipse/iofog/utils/Constants.java @@ -66,7 +66,7 @@ public String fullValue() { } } - public static final int NUMBER_OF_MODULES = 7; + public static final int NUMBER_OF_MODULES = 8; public static final int RESOURCE_CONSUMPTION_MANAGER = 0; public static final int PROCESS_MANAGER = 1; @@ -75,6 +75,7 @@ public String fullValue() { public static final int MESSAGE_BUS = 4; public static final int FIELD_AGENT = 5; public static final int RESOURCE_MANAGER = 6; + public static final int TRACKER= 7; public static PrintStream systemOut; @@ -105,4 +106,6 @@ public String fullValue() { public static final String SWITCHER_NODE = "current_config"; public static final String OS_GROUP = "iofog-agent"; public static final String IOFOG_DOCKER_CONTAINER_NAME_PREFIX = "iofog_"; + + public static final String MICROSERVICE_FILE = "microservices.json"; } \ No newline at end of file diff --git a/daemon/src/org/eclipse/iofog/utils/configuration/Configuration.java b/daemon/src/org/eclipse/iofog/utils/configuration/Configuration.java index f0b9b2c0..367e9264 100644 --- a/daemon/src/org/eclipse/iofog/utils/configuration/Configuration.java +++ b/daemon/src/org/eclipse/iofog/utils/configuration/Configuration.java @@ -22,6 +22,9 @@ import org.eclipse.iofog.process_manager.ProcessManager; import org.eclipse.iofog.resource_consumption_manager.ResourceConsumptionManager; import org.eclipse.iofog.supervisor.Supervisor; +import org.eclipse.iofog.tracking.Tracker; +import org.eclipse.iofog.tracking.TrackingEventType; +import org.eclipse.iofog.tracking.TrackingInfoUtils; import org.eclipse.iofog.utils.Constants; import org.eclipse.iofog.utils.device_info.ArchitectureType; import org.eclipse.iofog.utils.logging.LoggingService; @@ -563,6 +566,13 @@ public static HashMap setConfig(Map commandLineM default: throw new ConfigurationItemException("Invalid parameter -" + option); } + + //to correct info in tracking event + if (cmdOption.equals(GPS_COORDINATES)) { + value = Configuration.getGpsCoordinates(); + } + Tracker.getInstance().handleEvent(TrackingEventType.CONFIG, + TrackingInfoUtils.getConfigUpdateInfo(cmdOption.name().toLowerCase(), value)); } saveConfigUpdates(); @@ -981,7 +991,7 @@ private static String buildReportLine(String messageDescription, String value) { return rightPad(messageDescription, 40, ' ') + " : " + value + "\\n"; } - private static String getNetworkInterfaceInfo() { + public static String getNetworkInterfaceInfo() { return NETWORK_INTERFACE.getDefaultValue().equals(networkInterface) ? IOFogNetworkInterface.getNetworkInterface() + "(" + NETWORK_INTERFACE.getDefaultValue() + ")" : networkInterface; From 45601c34b3b19bdd5cfbd243ee0d4b74d8e243e7 Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Wed, 30 Jan 2019 19:38:08 +0300 Subject: [PATCH 03/21] fix removing docker containers --- iofog-agent-packaging-rpm/remove.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iofog-agent-packaging-rpm/remove.sh b/iofog-agent-packaging-rpm/remove.sh index 10ecdc63..966907bb 100644 --- a/iofog-agent-packaging-rpm/remove.sh +++ b/iofog-agent-packaging-rpm/remove.sh @@ -7,4 +7,7 @@ rm -rf /var/run/iofog-agent #rm -rf /var/backups/iofog-agent rm -rf /usr/share/iofog-agent -docker stop $(docker ps -f name=iofog_ -aq) +containers=$(docker ps | grep iofog_ | awk --posix '{print $1}') +if [ "$containers" != "" ]; then +docker stop $containers +fi From 97791b4e92f052ef2fce0e95c60f9264021b6593 Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Wed, 30 Jan 2019 19:38:14 +0300 Subject: [PATCH 04/21] fix removing docker containers --- iofog-agent-packaging/remove.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iofog-agent-packaging/remove.sh b/iofog-agent-packaging/remove.sh index 10ecdc63..966907bb 100644 --- a/iofog-agent-packaging/remove.sh +++ b/iofog-agent-packaging/remove.sh @@ -7,4 +7,7 @@ rm -rf /var/run/iofog-agent #rm -rf /var/backups/iofog-agent rm -rf /usr/share/iofog-agent -docker stop $(docker ps -f name=iofog_ -aq) +containers=$(docker ps | grep iofog_ | awk --posix '{print $1}') +if [ "$containers" != "" ]; then +docker stop $containers +fi From 08e1a54c3bbe411a2f528686cd3d084cb5403329 Mon Sep 17 00:00:00 2001 From: MaksimChepelev Date: Mon, 4 Feb 2019 15:47:32 +0300 Subject: [PATCH 05/21] feat(tracking): Tracking (#199) fix message format for microservies Closes: ENG-260 --- daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java | 2 +- .../src/org/eclipse/iofog/tracking/TrackingInfoUtils.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java b/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java index fe93d2d2..94c41555 100644 --- a/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java +++ b/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java @@ -315,7 +315,7 @@ private void verificationFailed(Exception e) { } Tracker.getInstance().handleEvent(TrackingEventType.MICROSERVICE, - loadMicroservicesJsonFile()); + TrackingInfoUtils.getMicroservicesInfo(loadMicroservicesJsonFile())); } if (changes.getBoolean("tunnel") && !initialization) { sshProxyManager.update(getProxyConfig()); diff --git a/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java b/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java index 0b4538fa..5ccb98f1 100644 --- a/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java +++ b/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java @@ -5,6 +5,7 @@ import org.eclipse.iofog.utils.configuration.Configuration; import javax.json.Json; +import javax.json.JsonArray; import javax.json.JsonObject; public class TrackingInfoUtils { @@ -41,4 +42,11 @@ public static JsonObject getConfigUpdateInfo(String option, String newValue) { .build(); return info; } + + public static JsonObject getMicroservicesInfo(JsonArray microservices) { + JsonObject info = Json.createObjectBuilder() + .add("microservices", microservices) + .build(); + return info; + } } From da739574f589397f3a33203efbdfba74fc550dc4 Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Tue, 5 Feb 2019 15:13:20 +0300 Subject: [PATCH 06/21] Travis CI improvements + dev packages (#193) * Create pushyunk.sh * Create release.sh * Create prerelease.sh * Create deploy.sh * Delete prerelease.sh * Update and rename release.sh to packaging.sh * Update .travis.yml * test packaging * try to fix permission deny * Update packaging.sh * Update packaging.sh * Update pushyunk.sh * Update packaging.sh * Update packaging.sh * Update .travis.yml * Update packaging.sh * Rename pushyunk.sh to pushyank.sh * Update pushyank.sh * update rpm package name * Update pushyank.sh * Update deploy.sh * Update packaging.sh * Update .travis.yml * Update deploy.sh * Update deploy.sh * Update .travis.yml * add upgrade/rollback option for dev packages * add upgrade/rollback option for dev packages * fix upgrade/rollback fields for controller * fix upgrade script * fix to execute bash scripts * Update .travis.yml * Update deploy.sh --- .travis.yml | 107 +++--------------- .../iofog/field_agent/VersionHandler.java | 35 +++--- .../usr/share/iofog-agent/rollback.sh | 9 +- .../usr/share/iofog-agent/upgrade.sh | 11 +- .../usr/share/iofog-agent/rollback.sh | 9 +- .../usr/share/iofog-agent/upgrade.sh | 11 +- .../util/CommandShellExecutor.java | 2 +- scripts/deploy.sh | 13 +++ scripts/packaging.sh | 20 ++++ scripts/pushyank.sh | 44 +++++++ 10 files changed, 135 insertions(+), 126 deletions(-) create mode 100644 scripts/deploy.sh create mode 100644 scripts/packaging.sh create mode 100644 scripts/pushyank.sh diff --git a/.travis.yml b/.travis.yml index 0f002021..e0cdfdea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,14 @@ notifications: email: false slack: rooms: - - secure: GVT7WQ6zLSEPdfyWKpe2KHtJcRnG3Ga41jFG5ThKUzNLAQxF00MzPPqqx9azrWdxJlNCwamz3tXM2npWP8BMcftwHUT1pljsSusLeUzzy1CAQvaDE0Jw0m3A8s9OqjYXm0BapP9L/dgp5STkHYh6vI55FihJ/DnPJDTh81ix+mfgdKZagaIEEsXDEOvsjzyq6i6YrRhJKe4PMMem5NPoNmwc/dtGZ8AcMN/l2KsGKeNL1SZvIsQjVRxM4b5RRNPv9njkEHucWAfrnIIrbnvIBDKcVVGucxciENcpPEpsR0pXqm7CD+gm1wPCwCllACFp5hEITC3Qu89rYDzuaKPpbmjcbM6GjalVacx6c14qLOE8mGfzGQacYkT7a2a9oh7OuCULP5S2dVb+obd/snJemzu+o6svKDTfEOlWqmzGATJG6Xm04DNcdEkR4HQFGhAWbWuLrm1B/SwSgZE/lA5SGdMEeE0XufVTORw0kLR6/Fv9fuRj0nDaYfflDHh5n/ZfdwHmsmImXBTrs9GxaAcDPRoQ09SEWi6jKgwrbe0ZG5e21CYh5j8NU3CeKpnKtnIm8tgqIPB0q0UrVc7WcMLfMs9CqFAl1XmDX36RSMw4kedXJCXsP3QQK4R0opN5SNUoo9xjzW4QO+5UwN2/VjGOXOjz1SEx/vuV75v59IWIkTE= + - secure: u/jR29mk4jya2Va1KfyFtjB3IWlSMl5IPr/5uWAhgmzN1jK/gqjArYGRFc6CY1p+P0SuPrZ0UzcU/av3RZBpzQjQEAzODR1/+lZESunMOw12TpqcUTZlTMCENWBHrWS5C4sfTBnRNwOt5qezYnzeRcvEApXPzBLFmtVLK1ZnaCRqoOLE2PlbPF/Ou0lJIsQaHt2MrO9zG/pN5fUDbdzDyOqNQ5SXvzEsay5MMJvxf0kN2dmYiQj3z/uy2kWc8HPHqJR78rLEWWKvMJgk3d3F/2Z/9rukvXCsSfPs9c+YNFNamwD/pOOdRczDw8oIc01V9sdtVgERy3wsovY1DVHIE4Z5wDcAmS2B0NDxT1moa2Xb67Ltx4QFncEDCwm2umxX/1X8lXZKOqnQHVn82UiMl5C6pfi/RxyJc592LVZx+NqD3SPHGmPy6HfdMu5fTvgxeGsnIz3aR3ZGbCjhWgUiG39tTEjFXY9Gc2J5WquYdn0TrwIDS9l1AOmdBSW/09PglT+Q9QgSf4SdsZBEx4VzVx4qNPBZrzdRxlFWeLVzFeD7RkRa6Z6sewe1DBZsz+t4QhjePx71Visj9vrpD9GSG6fu1IWgmyPL6X25+/7WVhbhbpxi0o0NkkwXw3A6gVJKll2Uw+UuFvvqZ+7WTdxMMyLwBFbncajYfLSmwd/9JFk= on_success: always on_failure: always template: - - Repo `%{repository_slug}` *%{result}* build (<%{build_url}|#%{build_number}>) - for commit (<%{compare_url}|%{commit}>) on branch `%{branch}`. - - 'Execution time: *%{duration}*' - - 'Message: %{message}' + - Repo `%{repository_slug}` *%{result}* build (<%{build_url}|#%{build_number}>) + for commit (<%{compare_url}|%{commit}>) on branch `%{branch}`. + - 'Execution time: *%{duration}*' + - 'Message: %{message}' stages: - name: build if: type = pull_request @@ -29,99 +29,21 @@ jobs: before_install: - sudo apt-get install sshpass xml-twig-tools script: - - sshpass -p $DEV_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $DEV_MACHINE_USERNAME@$DEV_MACHINE_IP - "service iofog-agent stop" - - sshpass -p $DEV_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no daemon/target/iofog-agent-daemon-jar-with-dependencies.jar - $DEV_MACHINE_USERNAME@$DEV_MACHINE_IP:/usr/bin/iofog-agentd.jar - - sshpass -p $DEV_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no client/target/iofog-agent-client-jar-with-dependencies.jar - $DEV_MACHINE_USERNAME@$DEV_MACHINE_IP:/usr/bin/iofog-agent.jar - - sshpass -p $DEV_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $DEV_MACHINE_USERNAME@$DEV_MACHINE_IP - "service iofog-agent start" + - bash scripts/deploy.sh $DEV_MACHINE_PASSWORD $DEV_MACHINE_USERNAME $DEV_MACHINE_IP - stage: pre_release before_install: - sudo apt-get install sshpass xml-twig-tools script: - - sshpass -p $PREPROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PREPROD_MACHINE_USERNAME@$PREPROD_MACHINE_IP - "service iofog-agent stop; sudo apt-get install --only-upgrade -y iofog-agent" - - sshpass -p $PREPROD_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no daemon/target/iofog-agent-daemon-jar-with-dependencies.jar - $PREPROD_MACHINE_USERNAME@$PREPROD_MACHINE_IP:/usr/bin/iofog-agentd.jar - - sshpass -p $PREPROD_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no client/target/iofog-agent-client-jar-with-dependencies.jar - $PREPROD_MACHINE_USERNAME@$PREPROD_MACHINE_IP:/usr/bin/iofog-agent.jar - - sshpass -p $PREPROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PREPROD_MACHINE_USERNAME@$PREPROD_MACHINE_IP - "service iofog-agent start" + - export VERSION=`xml_grep --cond='project/version' pom.xml --text_only` + - export DEV=-dev + - bash scripts/packaging.sh + - bash scripts/deploy.sh $PREPROD_MACHINE_PASSWORD $PREPROD_MACHINE_USERNAME $PREPROD_MACHINE_IP - stage: release before_install: - sudo apt-get install sshpass xml-twig-tools script: - - export VERSION=`xml_grep 'version' pom.xml --text_only` - - sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP - "rm -rf /iofog-agent-packaging-rpm/*; rm -rf /iofog-agent-packaging/*;" - - sshpass -p $STAGE_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no -r iofog-agent-packaging-rpm/* - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/ - - sshpass -p $STAGE_MACHINE_PASSWORD scp -r iofog-agent-packaging/* $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/ - - sshpass -p $STAGE_MACHINE_PASSWORD scp daemon/target/iofog-agent-daemon-jar-with-dependencies.jar - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agentd.jar - - sshpass -p $STAGE_MACHINE_PASSWORD scp client/target/iofog-agent-client-jar-with-dependencies.jar - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agent.jar - - sshpass -p $STAGE_MACHINE_PASSWORD scp daemon/target/iofog-agent-daemon-jar-with-dependencies.jar - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agentd.jar - - sshpass -p $STAGE_MACHINE_PASSWORD scp client/target/iofog-agent-client-jar-with-dependencies.jar - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agent.jar - - sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP - "cd /iofog-agent-packaging; fpm -s dir -t deb -n \"iofog-agent\" -v $VERSION - -a all --deb-no-default-config-files --after-install debian.sh --after-remove - remove.sh --before-upgrade upgrade.sh --after-upgrade debian.sh etc usr; package_cloud - yank iofog/iofog-agent/ubuntu/precise iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/ubuntu/precise iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/ubuntu/trusty iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/ubuntu/trusty iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/ubuntu/utopic iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/ubuntu/utopic iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/ubuntu/vivid iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/ubuntu/vivid iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/ubuntu/wily iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/ubuntu/wily iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/ubuntu/xenial iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/ubuntu/xenial iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/ubuntu/bionic iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/ubuntu/bionic iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/debian/wheezy iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/debian/wheezy iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/debian/jessie iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/debian/jessie iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/debian/stretch iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/debian/stretch iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/debian/buster iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/debian/buster iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/raspbian/wheezy iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/raspbian/wheezy iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/raspbian/jessie iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/raspbian/jessie iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/raspbian/stretch iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/raspbian/stretch iofog-agent_${VERSION}_all.deb; - package_cloud yank iofog/iofog-agent/raspbian/buster iofog-agent_${VERSION}_all.deb; - package_cloud push iofog/iofog-agent/raspbian/buster iofog-agent_${VERSION}_all.deb; - cd /iofog-agent-packaging-rpm; fpm -s dir -t rpm -n \"iofog-agent\" -v - $VERSION -a all --rpm-os 'linux' --after-install rpm.sh --after-remove remove.sh - --before-upgrade upgrade.sh --after-upgrade rpm.sh etc usr; package_cloud yank - iofog/iofog-agent/fedora/22 iofog-agent-${VERSION}-1.noarch.rpm; package_cloud - push iofog/iofog-agent/fedora/22 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud yank iofog/iofog-agent/fedora/23 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud push iofog/iofog-agent/fedora/23 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud yank iofog/iofog-agent/fedora/24 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud push iofog/iofog-agent/fedora/24 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud yank iofog/iofog-agent/fedora/25 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud push iofog/iofog-agent/fedora/25 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud yank iofog/iofog-agent/fedora/26 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud push iofog/iofog-agent/fedora/26 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud yank iofog/iofog-agent/fedora/27 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud push iofog/iofog-agent/fedora/27 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud yank iofog/iofog-agent/fedora/28 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud push iofog/iofog-agent/fedora/28 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud yank iofog/iofog-agent/el/6 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud push iofog/iofog-agent/el/6 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud yank iofog/iofog-agent/el/7 iofog-agent-${VERSION}-1.noarch.rpm; - package_cloud push iofog/iofog-agent/el/7 iofog-agent-${VERSION}-1.noarch.rpm" + - export VERSION=`xml_grep --cond='project/version' pom.xml --text_only` + - ./scripts/packaging.sh before_deploy: - git config --global user.name "${GH_USERNAME}"; - git config credential.helper "store --file=.git/credentials"; @@ -130,10 +52,9 @@ jobs: deploy: provider: releases api_key: "${GH_TOKEN}" - name: "v${VERSION} ($(date +'%m/%d/%Y'))" + name: v${VERSION} ($(date +'%m/%d/%Y')) skip_cleanup: true on: branch: master after_deploy: - - sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PROD_MACHINE_USERNAME@$PROD_MACHINE_IP - "service iofog-agent stop; sudo apt-get install --only-upgrade -y iofog-agent; service iofog-agent start" + - bash scripts/deploy.sh $PROD_MACHINE_PASSWORD $PROD_MACHINE_USERNAME $PROD_MACHINE_IP diff --git a/daemon/src/org/eclipse/iofog/field_agent/VersionHandler.java b/daemon/src/org/eclipse/iofog/field_agent/VersionHandler.java index 68d1fd9c..fd7fe3bc 100755 --- a/daemon/src/org/eclipse/iofog/field_agent/VersionHandler.java +++ b/daemon/src/org/eclipse/iofog/field_agent/VersionHandler.java @@ -41,9 +41,11 @@ public class VersionHandler { private final static String GET_LINUX_DISTRIBUTION_NAME = "grep = /etc/os-release | awk -F\"[=]\" '{print $2}' | sed -n 1p"; private static String GET_IOFOG_PACKAGE_INSTALLED_VERSION; + private static String GET_IOFOG_PACKAGE_DEV_VERSION; private static String GET_IOFOG_PACKAGE_CANDIDATE_VERSION; private static String UPDATE_PACKAGE_REPOSITORY; private static String GET_PACKAGE_MANAGER_LOCK_FILE_CONTENT; + private static String DEV; static { if (SystemUtils.IS_OS_LINUX) { @@ -51,24 +53,26 @@ public class VersionHandler { if (distrName.contains("ubuntu") || distrName.contains("debian") || distrName.contains("raspbian")) { - GET_IOFOG_PACKAGE_INSTALLED_VERSION = "apt-cache policy " + PACKAGE_NAME + " | grep Installed | awk '{print $2}'"; - GET_IOFOG_PACKAGE_CANDIDATE_VERSION = "apt-cache policy " + PACKAGE_NAME + " | grep Candidate | awk '{print $2}'"; + GET_IOFOG_PACKAGE_DEV_VERSION = "(apt-cache policy " + PACKAGE_NAME + "-dev && apt-cache policy " + PACKAGE_NAME + ") | grep -A1 ^iofog | awk '$2 ~ /^[0-9]/ {print a}{a=$0}' | sed -e 's/iofog-agent\\(.*\\):/\\1/'"; + DEV = getIofogPackageDevVersion(); + GET_IOFOG_PACKAGE_INSTALLED_VERSION = "apt-cache policy " + PACKAGE_NAME + DEV + " | grep Installed | awk '{print $2}'"; + GET_IOFOG_PACKAGE_CANDIDATE_VERSION = "apt-cache policy " + PACKAGE_NAME + DEV + " | grep Candidate | awk '{print $2}'"; UPDATE_PACKAGE_REPOSITORY = "apt-get update"; GET_PACKAGE_MANAGER_LOCK_FILE_CONTENT = "cat /var/lib/apt/lists/lock /var/cache/apt/archives/lock"; } else if (distrName.contains("fedora")) { - GET_IOFOG_PACKAGE_INSTALLED_VERSION = "dnf --showduplicates list " + PACKAGE_NAME + " | grep iofog | awk '{print $2}' | sed -n 1p"; - GET_IOFOG_PACKAGE_CANDIDATE_VERSION = "dnf --showduplicates list " + PACKAGE_NAME + " | grep iofog | awk '{print $2}' | sed -n \"$p\""; + GET_IOFOG_PACKAGE_DEV_VERSION = "(dnf --showduplicates list installed " + PACKAGE_NAME + "-dev && dnf --showduplicates list installed " + PACKAGE_NAME + ") | grep iofog | awk '{print $1}' | sed -e 's/iofog-agent\\(.*\\).noarch/\\1/')"; + DEV = getIofogPackageDevVersion(); + GET_IOFOG_PACKAGE_INSTALLED_VERSION = "dnf --showduplicates list installed " + PACKAGE_NAME + DEV + " | grep iofog | awk '{print $2}'"; + GET_IOFOG_PACKAGE_CANDIDATE_VERSION = "dnf --showduplicates list " + PACKAGE_NAME + DEV + " | grep iofog | awk '{print $2}' | sed -n \\$p\\"; UPDATE_PACKAGE_REPOSITORY = "dnf update"; GET_PACKAGE_MANAGER_LOCK_FILE_CONTENT = "cat /var/cache/dnf/metadata_lock.pid"; } else if (distrName.contains("red hat") - || distrName.contains("centos")) { - GET_IOFOG_PACKAGE_INSTALLED_VERSION = "yum --showduplicates list " + PACKAGE_NAME + " | grep iofog | awk '{print $2}' | sed -n 1p"; - GET_IOFOG_PACKAGE_CANDIDATE_VERSION = "yum --showduplicates list " + PACKAGE_NAME + " | grep iofog | awk '{print $2}' | sed -n \"$p\""; - UPDATE_PACKAGE_REPOSITORY = "yum update"; - GET_PACKAGE_MANAGER_LOCK_FILE_CONTENT = "cat /var/run/yum.pid"; - } else if (distrName.contains("amazon")) { - GET_IOFOG_PACKAGE_INSTALLED_VERSION = "yum --showduplicates list | grep iofog | awk '{print $2}' | sed -n 1p"; - GET_IOFOG_PACKAGE_CANDIDATE_VERSION = "yum --showduplicates list | grep iofog | awk '{print $2}' | sed -n \"$p\""; + || distrName.contains("centos") + || distrName.contains("amazon")) { + GET_IOFOG_PACKAGE_DEV_VERSION = "(yum --showduplicates list installed " + PACKAGE_NAME + "-dev && yum --showduplicates list installed " + PACKAGE_NAME + ") | grep iofog | awk '{print $1}' | sed -e 's/iofog-agent\\(.*\\).noarch/\\1/')"; + DEV = getIofogPackageDevVersion(); + GET_IOFOG_PACKAGE_INSTALLED_VERSION = "yum --showduplicates list installed | grep " + PACKAGE_NAME + DEV + " | awk '{print $2}'"; + GET_IOFOG_PACKAGE_CANDIDATE_VERSION = "yum --showduplicates list | grep " + PACKAGE_NAME + DEV + "| awk '{print $2}' | sed -n \\$p\\"; UPDATE_PACKAGE_REPOSITORY = "yum update"; GET_PACKAGE_MANAGER_LOCK_FILE_CONTENT = "cat /var/run/yum.pid"; } else { @@ -87,6 +91,11 @@ private static String getFogInstalledVersion() { return parseVersionResult(resultSet); } + private static String getIofogPackageDevVersion(){ + CommandShellResultSet, List> resultSet = CommandShellExecutor.executeCommand(GET_IOFOG_PACKAGE_DEV_VERSION); + return parseVersionResult(resultSet); + } + private static String getFogCandidateVersion() { CommandShellResultSet, List> resultSet = CommandShellExecutor.executeCommand(GET_IOFOG_PACKAGE_CANDIDATE_VERSION); return parseVersionResult(resultSet); @@ -117,8 +126,6 @@ private static String parseVersionResult(CommandShellResultSet, Lis * */ static void changeVersion(JsonObject actionData) { - LoggingService.logInfo(MODULE_NAME, "trying to change version action"); - if (SystemUtils.IS_OS_WINDOWS) { return; // TODO implement } diff --git a/iofog-agent-packaging-rpm/usr/share/iofog-agent/rollback.sh b/iofog-agent-packaging-rpm/usr/share/iofog-agent/rollback.sh index aca01cff..313a6bc0 100644 --- a/iofog-agent-packaging-rpm/usr/share/iofog-agent/rollback.sh +++ b/iofog-agent-packaging-rpm/usr/share/iofog-agent/rollback.sh @@ -8,16 +8,17 @@ cd /var/backups/iofog-agent iofog-agent deprovision service iofog-agent stop -yum remove iofog-agent -y +iofogpackage=$(grep ver prev_version_data | awk '{print $3}') +yum remove iofog-agent$iofogpackage -y iofogversion=$(grep ver prev_version_data | awk '{print $2}') -yum install iofog-agent-$iofogversion -y +yum install iofog-agent$iofogpackage-$iofogversion -y rm -rf /etc/iofog-agent/ -tar -xvzf config_backup.tar.gz -P -C / +tar -xvzf config_backup$iofogpackage.tar.gz -P -C / rm -rf /var/backups/iofog-agent/prev_version_data -rm -rf /var/backups/iofog-agent/config_backup.tar.gz +rm -rf /var/backups/iofog-agent/config_backup$iofogpackage.tar.gz starttimestamp=$(date +%s) service iofog-agent start diff --git a/iofog-agent-packaging-rpm/usr/share/iofog-agent/upgrade.sh b/iofog-agent-packaging-rpm/usr/share/iofog-agent/upgrade.sh index 7e7a13d4..f04f14dc 100644 --- a/iofog-agent-packaging-rpm/usr/share/iofog-agent/upgrade.sh +++ b/iofog-agent-packaging-rpm/usr/share/iofog-agent/upgrade.sh @@ -3,18 +3,19 @@ provisionkey=$1 timeout=${2:-60} -cd /var/backups/iofog-agent -tar -cvzf config_backup.tar.gz -P /etc/iofog-agent +iofogversion=$(yum list installed | grep iofog | awk '{print $2}') +iofogpackage=$(yum list installed | grep iofog | awk '{print $1}' | sed -e 's/iofog-agent\(.*\).noarch/\1/') -iofogversion=$(yum list iofog-agent | grep iofog | awk '{print $2}' | sed -n 1p) +cd /var/backups/iofog-agent +tar -cvzf config_backup$iofogpackage.tar.gz -P /etc/iofog-agent -printf 'ver: '$iofogversion > prev_version_data +printf 'ver: %s %s' $iofogversion $iofogpackage > prev_version_data iofog-agent deprovision service iofog-agent stop yum check-update -yum update iofog-agent -y +yum update iofog-agent$iofogpackage -y starttimestamp=$(date +%s) service iofog-agent start diff --git a/iofog-agent-packaging/usr/share/iofog-agent/rollback.sh b/iofog-agent-packaging/usr/share/iofog-agent/rollback.sh index 851ced4c..84cc3c30 100644 --- a/iofog-agent-packaging/usr/share/iofog-agent/rollback.sh +++ b/iofog-agent-packaging/usr/share/iofog-agent/rollback.sh @@ -8,16 +8,17 @@ cd /var/backups/iofog-agent iofog-agent deprovision service iofog-agent stop -apt-get purge --auto-remove iofog-agent -y +iofogpackage=$(grep ver prev_version_data | awk '{print $3}') +apt-get purge --auto-remove iofog-agent$iofogpackage -y iofogversion=$(grep ver prev_version_data | awk '{print $2}') -apt-get install iofog-agent=$iofogversion -y +apt-get install iofog-agent$iofogpackage=$iofogversion -y rm -rf /etc/iofog-agent/ -tar -xvzf config_backup.tar.gz -P -C / +tar -xvzf config_backup$iofogpackage.tar.gz -P -C / rm -rf /var/backups/iofog-agent/prev_version_data -rm -rf /var/backups/iofog-agent/config_backup.tar.gz +rm -rf /var/backups/iofog-agent/config_backup$iofogpackage.tar.gz starttimestamp=$(date +%s) service iofog-agent start diff --git a/iofog-agent-packaging/usr/share/iofog-agent/upgrade.sh b/iofog-agent-packaging/usr/share/iofog-agent/upgrade.sh index 2b11b66a..2f8bcc01 100644 --- a/iofog-agent-packaging/usr/share/iofog-agent/upgrade.sh +++ b/iofog-agent-packaging/usr/share/iofog-agent/upgrade.sh @@ -3,18 +3,19 @@ provisionkey=$1 timeout=${2:-60} -cd /var/backups/iofog-agent -tar -cvzf config_backup.tar.gz -P /etc/iofog-agent +iofogpackage=$(apt-cache policy iofog-agent iofog-agent-dev | grep -A1 ^iofog | awk '$2 ~ /^[0-9]/ {print a}{a=$0}' | sed -e 's/iofog-agent\(.*\):/\1/') +iofogversion=$(apt-cache policy iofog-agent$iofogpackage | grep Installed | awk --posix '{ if ($2 ~ /^[0-9]/) print $2}') -iofogversion=$(apt-cache policy iofog-agent | grep Installed | awk '{print $2}') +cd /var/backups/iofog-agent +tar -cvzf config_backup$iofogpackage.tar.gz -P /etc/iofog-agent -printf 'ver: '$iofogversion > prev_version_data +printf 'ver: %s %s' $iofogversion $iofogpackage > prev_version_data iofog-agent deprovision service iofog-agent stop apt-get update -apt-get install --only-upgrade iofog-agent -y +apt-get install --only-upgrade iofog-agent$iofogpackage -y starttimestamp=$(date +%s) service iofog-agent start diff --git a/iofog_version_controller/src/org/eclipse/iofog_version_controller/command_line/util/CommandShellExecutor.java b/iofog_version_controller/src/org/eclipse/iofog_version_controller/command_line/util/CommandShellExecutor.java index b14a7498..0543a0b9 100755 --- a/iofog_version_controller/src/org/eclipse/iofog_version_controller/command_line/util/CommandShellExecutor.java +++ b/iofog_version_controller/src/org/eclipse/iofog_version_controller/command_line/util/CommandShellExecutor.java @@ -29,7 +29,7 @@ */ public class CommandShellExecutor { private static final String MODULE_NAME = "CommandShellExecutor"; - private static final String CMD = "/bin/sh"; + private static final String CMD = "/bin/bash"; private static final String CMD_WIN = "powershell"; public static CommandShellResultSet, List> executeScript(String... args) { diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 00000000..8e97dd89 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +PASSWORD=$1 +USER=$2 +IP=$3 + +sshpass -p ${PASSWORD} ssh -o StrictHostKeyChecking=no ${USER}@${IP} "service iofog-agent stop sudo apt-get install --only-upgrade -y iofog-agent${DEV}" +if [ "$TRAVIS_BRANCH" == "develop" ]; then + sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no daemon/target/iofog-agent-daemon-jar-with-dependencies.jar ${USER}@${IP}:/usr/bin/iofog-agentd.jar; + sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no client/target/iofog-agent-client-jar-with-dependencies.jar ${USER}@${IP}:/usr/bin/iofog-agent.jar; + sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no iofog_version_controller/target/iofog-version-controller-jar-with-dependencies.jar ${USER}@${IP}:/usr/bin/iofog-agentvc.jar; +fi +sshpass -p ${PASSWORD} ssh -o StrictHostKeyChecking=no ${USER}@${IP} "service iofog-agent start" diff --git a/scripts/packaging.sh b/scripts/packaging.sh new file mode 100644 index 00000000..b1fe02c9 --- /dev/null +++ b/scripts/packaging.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +PUSH_YANK_LIST="$(bash ${DIR}/pushyank.sh)" + +sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP \ + "rm -rf /iofog-agent-packaging-rpm/*; rm -rf /iofog-agent-packaging/*;" +sshpass -p $STAGE_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no -r iofog-agent-packaging-rpm/* \ + $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/ +sshpass -p $STAGE_MACHINE_PASSWORD scp -r iofog-agent-packaging/* $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/ +sshpass -p $STAGE_MACHINE_PASSWORD scp client/target/iofog-agent-client-jar-with-dependencies.jar \ + $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agent.jar +sshpass -p $STAGE_MACHINE_PASSWORD scp daemon/target/iofog-agent-daemon-jar-with-dependencies.jar \ + $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agentd.jar +sshpass -p $STAGE_MACHINE_PASSWORD scp client/target/iofog-agent-client-jar-with-dependencies.jar \ + $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agent.jar +sshpass -p $STAGE_MACHINE_PASSWORD scp daemon/target/iofog-agent-daemon-jar-with-dependencies.jar \ + $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agentd.jar +sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP \ + "${PUSH_YANK_LIST}" diff --git a/scripts/pushyank.sh b/scripts/pushyank.sh new file mode 100644 index 00000000..666e9b58 --- /dev/null +++ b/scripts/pushyank.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +RETURN_STRING="cd /iofog-agent-packaging; fpm -s dir -t deb -n \"iofog-agent${DEV}\" -v $VERSION + -a all --deb-no-default-config-files --after-install debian.sh --after-remove + remove.sh --before-upgrade upgrade.sh --after-upgrade debian.sh etc usr;" + +declare -a UBUNTU_VERS=("precise" "trusty" "utopic" "vivid" "wily" "xenial" "bionic") #Support ubuntu versions +declare -a DEBIAN_VERS=("wheezy" "jessie" "stretch" "buster") #Also appplies to Raspbian, See related for loop +declare -a FEDORA_VERS=("22" "23" "24") #Supported Fedora Versions +declare -a REDHAT_VERS=("6" "7") #Supported Redhat versions + + +for version in ${UBUNTU_VERS[@]} +do + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/ubuntu/${version} iofog-agent${DEV}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/ubuntu/${version} iofog-agent${DEV}_${VERSION}_all.deb;" +done + +for version in "${DEBIAN_VERS[@]}" +do + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/debian/${version} iofog-agent${DEV}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/debian/${version} iofog-agent${DEV}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/raspbian/${version} iofog-agent${DEV}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/raspbian/${version} iofog-agent${DEV}_${VERSION}_all.deb;" +done + +RETURN_STRING="$RETURN_STRING cd /iofog-agent-packaging-rpm; +fpm -s dir -t rpm -n \"iofog-agent${DEV}\" -v $VERSION -a all --rpm-os 'linux' --after-install +rpm.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade +rpm.sh etc usr;" + +for version in ${FEDORA_VERS[@]} +do + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/fedora/${version} iofog-agent${DEV}-${VERSION}-1.noarch.rpm;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/fedora/${version} iofog-agent${DEV}-${VERSION}-1.noarch.rpm;" +done + +for version in ${REDHAT_VERS[@]} +do + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/el/${version} iofog-agent${DEV}-${VERSION}-1.noarch.rpm;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/el/${version} iofog-agent${DEV}-${VERSION}-1.noarch.rpm;" +done + +echo $RETURN_STRING From 1e4db621ebbe6b8bebca5a794dd6ea7073716ad6 Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Thu, 7 Feb 2019 22:19:33 +0300 Subject: [PATCH 07/21] Release 1.0.12 (#205) * Release merge (#175) * fixed default controller url (#116) * 1.0.1 (#118) * fixed default controller url * 1.0.1 version * EWC-292 fixed iofog-agent info controller status when access token is expired/invalid * build for dev env added * fix travis * renaming client (#120) * renaming client * 1.0.2 * adding dev packages * invalid error message during provision (#122) * invalid error message during provision * invalid error message during provision * update build packages * Epankou/feature microservice removal ewc 306 (#123) * invalid error message during provision * invalid error message during provision * microservice removal * microservice removal EWC-306 * microservice removal EWC-306 * microservice removal EWC-306 * microservice removal EWC-306 * microservice removal EWC-306 * EWC-336 added default device scan frequency value & update error message * EWC-335 fixed config logging parameters validation (#125) * EWC-335 fixed config logging parameters validation * additional warning messages * microservice update fix (#126) * WIP: EWC-345 add notifications (#127) * add notifications to channel * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * 1.0.3 version (#129) * EWC-366 now deprovision works if agent hasn't connection to controller (#132) * EWC-359 controller status renaming ok -> online (#133) * Update HornetQ version * Fix `isolated_docker_container` configuration * EWC-375 config switcher * cleanup * EWC-375 config switcher import fix * EWC-375 fixed help for iofog-agent client * updating config switcher * iofog agent os group fix * version 1.0.4 (#139) * remove preprod env * Update "HttpMime" version (#142) * update version to 1.0.5 (#143) * update version to 1.0.5 * update version to 1.0.5 (#146) * fix(config): validation for watchdog config param only on and off now available Closes EWC-407 * Dbusel/feature ewc 398 auto release (#148) * test GH release automation * edit build condition to build * edit travis file to enable build * fix syntax error in build file * enable release on all branches to test * fix allowing deploy stage * fix tag name * add autorelease for master branch * fix(bug) fixed log disk size validation (EWC-335) (#149) * fix(bug) fixed log disk size validation (EWC-335) * cleanup * fix(bug) fixed certificate exception message (EWC-402) (#150) * fix(bug) stopping agent process while reinstalling iofog-agent (EWC-405) (#151) * fix(bug) stopping agent process while reinstalling iofog-agent (EWC-405) * iofog-agent > iofog-agentd process in order to avoid install process of iofog-agent package * fix(bug) fixed iofog-agent controller connection status (EWC-415) * add build stage for release branch (#154) * fix build for release branch (#155) * add build stage for release branch * rename build stage for master branch * Pre-release 1.0.6 (#159) * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * 1.0.7 Release * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * EWC-410 version placeholder * EWC-414 watchdog feature fix * bug(core) fixed strace request (#162) * EWC-421 strace feature bug * EWC-421 strace feature fix * Bug(fix) message bug: concurrent usage of session object which isn't thread safe (EWC-433) * bug(fix) fixed help logs measurement (EWC-431) (#166) * bug(fix) microservice removal: networking microservice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * version 1.0.7 * Release 1.0.8 (#173) * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * EWC-410 version placeholder * EWC-414 watchdog feature fix * bug(core) fixed strace request (#162) * EWC-421 strace feature bug * EWC-421 strace feature fix * Bug(fix) message bug: concurrent usage of session object which isn't thread safe (EWC-433) * bug(fix) fixed help logs measurement (EWC-431) (#166) * bug(fix) microservice removal: networking microservice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * version 1.0.7 * Epankou/bug routes update ewc 374 (#171) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * version 1.0.8 (#172) * Release merge (#184) * fixed default controller url (#116) * 1.0.1 (#118) * fixed default controller url * 1.0.1 version * EWC-292 fixed iofog-agent info controller status when access token is expired/invalid * build for dev env added * fix travis * renaming client (#120) * renaming client * 1.0.2 * adding dev packages * invalid error message during provision (#122) * invalid error message during provision * invalid error message during provision * update build packages * Epankou/feature microservice removal ewc 306 (#123) * invalid error message during provision * invalid error message during provision * microservice removal * microservice removal EWC-306 * microservice removal EWC-306 * microservice removal EWC-306 * microservice removal EWC-306 * microservice removal EWC-306 * EWC-336 added default device scan frequency value & update error message * EWC-335 fixed config logging parameters validation (#125) * EWC-335 fixed config logging parameters validation * additional warning messages * microservice update fix (#126) * WIP: EWC-345 add notifications (#127) * add notifications to channel * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * 1.0.3 version (#129) * EWC-366 now deprovision works if agent hasn't connection to controller (#132) * EWC-359 controller status renaming ok -> online (#133) * Update HornetQ version * Fix `isolated_docker_container` configuration * EWC-375 config switcher * cleanup * EWC-375 config switcher import fix * EWC-375 fixed help for iofog-agent client * updating config switcher * iofog agent os group fix * version 1.0.4 (#139) * remove preprod env * Update "HttpMime" version (#142) * update version to 1.0.5 (#143) * update version to 1.0.5 * update version to 1.0.5 (#146) * fix(config): validation for watchdog config param only on and off now available Closes EWC-407 * Dbusel/feature ewc 398 auto release (#148) * test GH release automation * edit build condition to build * edit travis file to enable build * fix syntax error in build file * enable release on all branches to test * fix allowing deploy stage * fix tag name * add autorelease for master branch * fix(bug) fixed log disk size validation (EWC-335) (#149) * fix(bug) fixed log disk size validation (EWC-335) * cleanup * fix(bug) fixed certificate exception message (EWC-402) (#150) * fix(bug) stopping agent process while reinstalling iofog-agent (EWC-405) (#151) * fix(bug) stopping agent process while reinstalling iofog-agent (EWC-405) * iofog-agent > iofog-agentd process in order to avoid install process of iofog-agent package * fix(bug) fixed iofog-agent controller connection status (EWC-415) * add build stage for release branch (#154) * fix build for release branch (#155) * add build stage for release branch * rename build stage for master branch * Pre-release 1.0.6 (#159) * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * 1.0.7 Release * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * EWC-410 version placeholder * EWC-414 watchdog feature fix * bug(core) fixed strace request (#162) * EWC-421 strace feature bug * EWC-421 strace feature fix * Bug(fix) message bug: concurrent usage of session object which isn't thread safe (EWC-433) * bug(fix) fixed help logs measurement (EWC-431) (#166) * bug(fix) microservice removal: networking microservice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * version 1.0.7 * Release 1.0.8 (#173) * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * EWC-410 version placeholder * EWC-414 watchdog feature fix * bug(core) fixed strace request (#162) * EWC-421 strace feature bug * EWC-421 strace feature fix * Bug(fix) message bug: concurrent usage of session object which isn't thread safe (EWC-433) * bug(fix) fixed help logs measurement (EWC-431) (#166) * bug(fix) microservice removal: networking microservice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * version 1.0.7 * Epankou/bug routes update ewc 374 (#171) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * version 1.0.8 (#172) * Release merge (#180) * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * EWC-410 version placeholder * EWC-414 watchdog feature fix * bug(core) fixed strace request (#162) * EWC-421 strace feature bug * EWC-421 strace feature fix * Bug(fix) message bug: concurrent usage of session object which isn't thread safe (EWC-433) * bug(fix) fixed help logs measurement (EWC-431) (#166) * bug(fix) microservice removal: networking microservice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * version 1.0.7 * Epankou/bug routes update ewc 374 (#171) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * version 1.0.8 (#172) * update package before build on prod env * Epankou/bug mic removal sync ewc 374 (#174) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Epankou/bug strace get pid ewc 421 (#176) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) strace: fixed method getpid (EWC-421) * Epankou/bug strace kill orphaned processes ewc 421 (#177) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) strace: fixed method getpid (EWC-421) * Bug(fix) strace: fixed method getpid (EWC-421) * Bug(fix) strace: added method to kill orphaned processes (EWC-421) * Bug(fix) strace: added method to kill orphaned processes (EWC-421) * Upgrade/rollback issue (#178) * update upgrade script * update backup directory name * update rollback script * update upgrade script * update rollback script * Update upgrade.sh * version 1.0.9 (#179) * Merge release (#181) * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * EWC-410 version placeholder * EWC-414 watchdog feature fix * bug(core) fixed strace request (#162) * EWC-421 strace feature bug * EWC-421 strace feature fix * Bug(fix) message bug: concurrent usage of session object which isn't thread safe (EWC-433) * bug(fix) fixed help logs measurement (EWC-431) (#166) * bug(fix) microservice removal: networking microservice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * version 1.0.7 * Epankou/bug routes update ewc 374 (#171) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * version 1.0.8 (#172) * update package before build on prod env * Epankou/bug mic removal sync ewc 374 (#174) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Epankou/bug strace get pid ewc 421 (#176) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) strace: fixed method getpid (EWC-421) * Epankou/bug strace kill orphaned processes ewc 421 (#177) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) strace: fixed method getpid (EWC-421) * Bug(fix) strace: fixed method getpid (EWC-421) * Bug(fix) strace: added method to kill orphaned processes (EWC-421) * Bug(fix) strace: added method to kill orphaned processes (EWC-421) * Upgrade/rollback issue (#178) * update upgrade script * update backup directory name * update rollback script * update upgrade script * update rollback script * Update upgrade.sh * version 1.0.9 (#179) * Update .travis.yml * merge release (#182) * add build stage for release branch * rename build stage for master branch * remove additional mvn build on stages * feat(core) version placeholder (EWC-410) * bug(fix) updated docker url validation (EWC-412) (#157) * version 1.0.6 * EWC-410 version placeholder * EWC-414 watchdog feature fix * bug(core) fixed strace request (#162) * EWC-421 strace feature bug * EWC-421 strace feature fix * Bug(fix) message bug: concurrent usage of session object which isn't thread safe (EWC-433) * bug(fix) fixed help logs measurement (EWC-431) (#166) * bug(fix) microservice removal: networking microservice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * version 1.0.7 * Epankou/bug routes update ewc 374 (#171) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * version 1.0.8 (#172) * update package before build on prod env * Epankou/bug mic removal sync ewc 374 (#174) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Epankou/bug strace get pid ewc 421 (#176) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) strace: fixed method getpid (EWC-421) * Epankou/bug strace kill orphaned processes ewc 421 (#177) * Bug(fix) microservice removal: networking microsrevice isn't removed (EWC-424) * Bug(fix) microservice removal: removed extra host mapping (EWC-424) * Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424) * Bug(fix) route update: added missing method for route update (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) mic removal update: added synchronization (EWC-374) * Bug(fix) strace: fixed method getpid (EWC-421) * Bug(fix) strace: fixed method getpid (EWC-421) * Bug(fix) strace: added method to kill orphaned processes (EWC-421) * Bug(fix) strace: added method to kill orphaned processes (EWC-421) * Upgrade/rollback issue (#178) * update upgrade script * update backup directory name * update rollback script * update upgrade script * update rollback script * Update upgrade.sh * version 1.0.9 (#179) * Update .travis.yml * Update .travis.yml * release 1.0.10 * bug(fix) diagnostic thread sleep time fix (ENG-313) (#194) * updating DSN for Sentry crash reporting (#192) * Release 1.0.11 (#197) * 1.0.12 pre prerelease * 1.0.12 pre prerelease * 1.0.12 pre prerelease * 1.0.12 pre prerelease * Update deploy.sh * Update deploy.sh * Release 1.0.12 (#202) * Master -> Develop merge (#198) * feat(tracking) tracking (ENG-260) * fix removing docker containers * fix removing docker containers * feat(tracking): Tracking (#199) fix message format for microservies Closes: ENG-260 * Travis CI improvements + dev packages (#193) * Create pushyunk.sh * Create release.sh * Create prerelease.sh * Create deploy.sh * Delete prerelease.sh * Update and rename release.sh to packaging.sh * Update .travis.yml * test packaging * try to fix permission deny * Update packaging.sh * Update packaging.sh * Update pushyunk.sh * Update packaging.sh * Update packaging.sh * Update .travis.yml * Update packaging.sh * Rename pushyunk.sh to pushyank.sh * Update pushyank.sh * update rpm package name * Update pushyank.sh * Update deploy.sh * Update packaging.sh * Update .travis.yml * Update deploy.sh * Update deploy.sh * Update .travis.yml * add upgrade/rollback option for dev packages * add upgrade/rollback option for dev packages * fix upgrade/rollback fields for controller * fix upgrade script * fix to execute bash scripts * Update .travis.yml * Update deploy.sh * 1.0.12 pre prerelease * 1.0.12 pre prerelease * 1.0.12 pre prerelease * 1.0.12 pre prerelease * Update deploy.sh * Update deploy.sh * hot fix release packaging * hot fix adding version control jar to package --- .travis.yml | 2 +- client/pom.xml | 2 +- daemon/pom.xml | 2 +- iofog_version_controller/pom.xml | 2 +- pom.xml | 2 +- scripts/deploy.sh | 2 +- scripts/packaging.sh | 23 +++++++++-------------- 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index e0cdfdea..56c833c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ jobs: - sudo apt-get install sshpass xml-twig-tools script: - export VERSION=`xml_grep --cond='project/version' pom.xml --text_only` - - ./scripts/packaging.sh + - bash scripts/packaging.sh before_deploy: - git config --global user.name "${GH_USERNAME}"; - git config credential.helper "store --file=.git/credentials"; diff --git a/client/pom.xml b/client/pom.xml index 44f4b580..24d3225a 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -16,7 +16,7 @@ org.eclipse iofog-agent - 1.0.11 + 1.0.12 ../pom.xml diff --git a/daemon/pom.xml b/daemon/pom.xml index 81a82987..6958e2e0 100644 --- a/daemon/pom.xml +++ b/daemon/pom.xml @@ -16,7 +16,7 @@ org.eclipse iofog-agent - 1.0.11 + 1.0.12 ../pom.xml diff --git a/iofog_version_controller/pom.xml b/iofog_version_controller/pom.xml index c9650016..f5dfc0ea 100644 --- a/iofog_version_controller/pom.xml +++ b/iofog_version_controller/pom.xml @@ -16,7 +16,7 @@ iofog-agent org.eclipse - 1.0.11 + 1.0.12 4.0.0 diff --git a/pom.xml b/pom.xml index 197ef635..5b1c1544 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 4.0.0 org.eclipse iofog-agent - 1.0.11 + 1.0.12 iofog-agent pom diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 8e97dd89..7ebf734f 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -4,7 +4,7 @@ PASSWORD=$1 USER=$2 IP=$3 -sshpass -p ${PASSWORD} ssh -o StrictHostKeyChecking=no ${USER}@${IP} "service iofog-agent stop sudo apt-get install --only-upgrade -y iofog-agent${DEV}" +sshpass -p ${PASSWORD} ssh -o StrictHostKeyChecking=no ${USER}@${IP} "service iofog-agent stop; sudo apt-get update; sudo apt-get install --only-upgrade -y iofog-agent${DEV}" if [ "$TRAVIS_BRANCH" == "develop" ]; then sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no daemon/target/iofog-agent-daemon-jar-with-dependencies.jar ${USER}@${IP}:/usr/bin/iofog-agentd.jar; sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no client/target/iofog-agent-client-jar-with-dependencies.jar ${USER}@${IP}:/usr/bin/iofog-agent.jar; diff --git a/scripts/packaging.sh b/scripts/packaging.sh index b1fe02c9..3880fb35 100644 --- a/scripts/packaging.sh +++ b/scripts/packaging.sh @@ -3,18 +3,13 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" PUSH_YANK_LIST="$(bash ${DIR}/pushyank.sh)" -sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP \ - "rm -rf /iofog-agent-packaging-rpm/*; rm -rf /iofog-agent-packaging/*;" -sshpass -p $STAGE_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no -r iofog-agent-packaging-rpm/* \ - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/ +sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP "rm -rf /iofog-agent-packaging-rpm/*; rm -rf /iofog-agent-packaging/*;" +sshpass -p $STAGE_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no -r iofog-agent-packaging-rpm/* $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/ sshpass -p $STAGE_MACHINE_PASSWORD scp -r iofog-agent-packaging/* $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/ -sshpass -p $STAGE_MACHINE_PASSWORD scp client/target/iofog-agent-client-jar-with-dependencies.jar \ - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agent.jar -sshpass -p $STAGE_MACHINE_PASSWORD scp daemon/target/iofog-agent-daemon-jar-with-dependencies.jar \ - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agentd.jar -sshpass -p $STAGE_MACHINE_PASSWORD scp client/target/iofog-agent-client-jar-with-dependencies.jar \ - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agent.jar -sshpass -p $STAGE_MACHINE_PASSWORD scp daemon/target/iofog-agent-daemon-jar-with-dependencies.jar \ - $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agentd.jar -sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP \ - "${PUSH_YANK_LIST}" +sshpass -p $STAGE_MACHINE_PASSWORD scp client/target/iofog-agent-client-jar-with-dependencies.jar $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agent.jar +sshpass -p $STAGE_MACHINE_PASSWORD scp daemon/target/iofog-agent-daemon-jar-with-dependencies.jar $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agentd.jar +sshpass -p $STAGE_MACHINE_PASSWORD scp iofog_version_controller/target/iofog-version-controller-jar-with-dependencies.jar $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging/usr/bin/iofog-agentvc.jar +sshpass -p $STAGE_MACHINE_PASSWORD scp client/target/iofog-agent-client-jar-with-dependencies.jar $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agent.jar +sshpass -p $STAGE_MACHINE_PASSWORD scp daemon/target/iofog-agent-daemon-jar-with-dependencies.jar $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agentd.jar +sshpass -p $STAGE_MACHINE_PASSWORD scp iofog_version_controller/target/iofog-version-controller-jar-with-dependencies.jar $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP:/iofog-agent-packaging-rpm/usr/bin/iofog-agentvc.jar +sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP "${PUSH_YANK_LIST}" From 2571e6b650b4daa4eb30854a5a2e720225a09087 Mon Sep 17 00:00:00 2001 From: Ian Date: Tue, 12 Feb 2019 14:56:18 -0800 Subject: [PATCH 08/21] Just adding badges to the ReadMe,just to give some more insight to someone glancing at it quickly --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 711ca197..16967a7c 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,24 @@ ioFog is a service that runs constantly in the background on a Linux machine. It There should be an ioFog code base for every processing platform that becomes part of the I/O compute fog. Network connectivity, process invocation, thread management, and other details of an ioFog will vary from platform to platform. The same ioFog principles apply to every version, but the implementation of the principles should match the native languages and structures best suited for the platform. +### Status + +![](https://img.shields.io/github/release/iofog/agent.svg?style=flat) +[![Build Status](https://travis-ci.org/ioFog/Agent.svg)](https://travis-ci.org/ioFog/Agent) + +![](https://img.shields.io/github/repo-size/iofog/agent.svg?style=flat) +![](https://img.shields.io/github/last-commit/iofog/agent.svg?style=flat) +![](https://img.shields.io/github/contributors/iofog/agent.svg?style=flat) +![](https://img.shields.io/github/issues/iofog/agent.svg?style=flat) + +![Supports amd64 Architecture][amd64-shield] +![Supports aarch64 Architecture][arm64-shield] +![Supports armhf Architecture][arm-shield] + +[arm64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg +[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg +[arm-shield]: https://img.shields.io/badge/armhf-yes-green.svg + ### Principles of an ioFog Agent: * Never go down From 60aafe270eb04c12d8218122c4fb106956e199fe Mon Sep 17 00:00:00 2001 From: Saeid Rezaei Baghbidi Date: Wed, 13 Feb 2019 05:00:32 -0800 Subject: [PATCH 09/21] Adding `microservicesCount` to `microservices were updated` tracking event (#207) --- daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java b/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java index 5ccb98f1..0d2d11ae 100644 --- a/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java +++ b/daemon/src/org/eclipse/iofog/tracking/TrackingInfoUtils.java @@ -46,6 +46,7 @@ public static JsonObject getConfigUpdateInfo(String option, String newValue) { public static JsonObject getMicroservicesInfo(JsonArray microservices) { JsonObject info = Json.createObjectBuilder() .add("microservices", microservices) + .add("microservicesCount", microservices == null ? 0 : microservices.size()) .build(); return info; } From 1d3b0095429c03d78e94a5c2aa29f954274f6449 Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Thu, 14 Feb 2019 12:46:05 +0300 Subject: [PATCH 10/21] [skip ci] update package names --- scripts/pushyank.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/pushyank.sh b/scripts/pushyank.sh index 666e9b58..a0183e25 100644 --- a/scripts/pushyank.sh +++ b/scripts/pushyank.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -RETURN_STRING="cd /iofog-agent-packaging; fpm -s dir -t deb -n \"iofog-agent${DEV}\" -v $VERSION +RETURN_STRING="cd /iofog-agent-packaging; fpm -s dir -t deb -n \"iofog-agent${ID}\" -v $VERSION -a all --deb-no-default-config-files --after-install debian.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade debian.sh etc usr;" @@ -12,33 +12,33 @@ declare -a REDHAT_VERS=("6" "7") #Supported Redhat versions for version in ${UBUNTU_VERS[@]} do - RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/ubuntu/${version} iofog-agent${DEV}_${VERSION}_all.deb;" - RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/ubuntu/${version} iofog-agent${DEV}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/ubuntu/${version} iofog-agent${ID}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/ubuntu/${version} iofog-agent${ID}_${VERSION}_all.deb;" done for version in "${DEBIAN_VERS[@]}" do - RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/debian/${version} iofog-agent${DEV}_${VERSION}_all.deb;" - RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/debian/${version} iofog-agent${DEV}_${VERSION}_all.deb;" - RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/raspbian/${version} iofog-agent${DEV}_${VERSION}_all.deb;" - RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/raspbian/${version} iofog-agent${DEV}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/debian/${version} iofog-agent${ID}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/debian/${version} iofog-agent${ID}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/raspbian/${version} iofog-agent${ID}_${VERSION}_all.deb;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/raspbian/${version} iofog-agent${ID}_${VERSION}_all.deb;" done RETURN_STRING="$RETURN_STRING cd /iofog-agent-packaging-rpm; -fpm -s dir -t rpm -n \"iofog-agent${DEV}\" -v $VERSION -a all --rpm-os 'linux' --after-install +fpm -s dir -t rpm -n \"iofog-agent${ID}\" -v $VERSION -a all --rpm-os 'linux' --after-install rpm.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade rpm.sh etc usr;" for version in ${FEDORA_VERS[@]} do - RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/fedora/${version} iofog-agent${DEV}-${VERSION}-1.noarch.rpm;" - RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/fedora/${version} iofog-agent${DEV}-${VERSION}-1.noarch.rpm;" + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/fedora/${version} iofog-agent${ID}-${VERSION}-1.noarch.rpm;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/fedora/${version} iofog-agent${ID}-${VERSION}-1.noarch.rpm;" done for version in ${REDHAT_VERS[@]} do - RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/el/${version} iofog-agent${DEV}-${VERSION}-1.noarch.rpm;" - RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/el/${version} iofog-agent${DEV}-${VERSION}-1.noarch.rpm;" + RETURN_STRING="${RETURN_STRING} package_cloud yank iofog/iofog-agent/el/${version} iofog-agent${ID}-${VERSION}-1.noarch.rpm;" + RETURN_STRING="${RETURN_STRING} package_cloud push iofog/iofog-agent/el/${version} iofog-agent${ID}-${VERSION}-1.noarch.rpm;" done echo $RETURN_STRING From 2bb37c72409f08c6a9a3ad43fde48c85d61df83c Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Thu, 14 Feb 2019 12:48:05 +0300 Subject: [PATCH 11/21] [skip ci] update deploy to dev evn --- scripts/deploy.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 7ebf734f..016dda29 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -4,10 +4,4 @@ PASSWORD=$1 USER=$2 IP=$3 -sshpass -p ${PASSWORD} ssh -o StrictHostKeyChecking=no ${USER}@${IP} "service iofog-agent stop; sudo apt-get update; sudo apt-get install --only-upgrade -y iofog-agent${DEV}" -if [ "$TRAVIS_BRANCH" == "develop" ]; then - sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no daemon/target/iofog-agent-daemon-jar-with-dependencies.jar ${USER}@${IP}:/usr/bin/iofog-agentd.jar; - sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no client/target/iofog-agent-client-jar-with-dependencies.jar ${USER}@${IP}:/usr/bin/iofog-agent.jar; - sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no iofog_version_controller/target/iofog-version-controller-jar-with-dependencies.jar ${USER}@${IP}:/usr/bin/iofog-agentvc.jar; -fi -sshpass -p ${PASSWORD} ssh -o StrictHostKeyChecking=no ${USER}@${IP} "service iofog-agent start" +sshpass -p ${PASSWORD} ssh -o StrictHostKeyChecking=no ${USER}@${IP} "service iofog-agent stop; sudo apt-get update; sudo apt-get install --only-upgrade -y iofog-agent${ID}; service iofog-agent start" From fc2dbb8385765927530e58783bf8d6134090babf Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Thu, 14 Feb 2019 12:51:36 +0300 Subject: [PATCH 12/21] Update .travis.yml --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 56c833c6..fb6bedd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,13 +29,16 @@ jobs: before_install: - sudo apt-get install sshpass xml-twig-tools script: + - export VERSION=`xml_grep --cond='project/version' pom.xml --text_only` + - export ID=-prerelease + - bash scripts/packaging.sh - bash scripts/deploy.sh $DEV_MACHINE_PASSWORD $DEV_MACHINE_USERNAME $DEV_MACHINE_IP - stage: pre_release before_install: - sudo apt-get install sshpass xml-twig-tools script: - export VERSION=`xml_grep --cond='project/version' pom.xml --text_only` - - export DEV=-dev + - export ID=-prerelease - bash scripts/packaging.sh - bash scripts/deploy.sh $PREPROD_MACHINE_PASSWORD $PREPROD_MACHINE_USERNAME $PREPROD_MACHINE_IP - stage: release From cf820ac8386f7162f3e4d5f1371e5c9f0f557c11 Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Thu, 14 Feb 2019 12:55:02 +0300 Subject: [PATCH 13/21] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fb6bedd3..c7e3abaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ jobs: - sudo apt-get install sshpass xml-twig-tools script: - export VERSION=`xml_grep --cond='project/version' pom.xml --text_only` - - export ID=-prerelease + - export ID=-dev - bash scripts/packaging.sh - bash scripts/deploy.sh $DEV_MACHINE_PASSWORD $DEV_MACHINE_USERNAME $DEV_MACHINE_IP - stage: pre_release From 763245bc0f31dfd252c4608e6193f760aa21d6d2 Mon Sep 17 00:00:00 2001 From: Railag Date: Mon, 18 Feb 2019 16:01:45 +0300 Subject: [PATCH 14/21] bug(fix) updating some Sentry events (error -> warning) (#208) --- .../org/eclipse/iofog/field_agent/FieldAgent.java | 12 ++++++------ .../org/eclipse/iofog/message_bus/MessageBus.java | 10 +++++----- .../ResourceConsumptionManager.java | 2 +- .../src/org/eclipse/iofog/supervisor/Supervisor.java | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java b/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java index 94c41555..33b58c01 100644 --- a/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java +++ b/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java @@ -180,9 +180,9 @@ private boolean notProvisioned() { connected = isControllerConnected(false); if (!connected) continue; - logInfo("controller connection verified"); + logInfo("Controller connection verified"); - logInfo("sending IOFog status..."); + logInfo("Sending ioFog status..."); orchestrator.request("status", RequestType.PUT, null, status); onPostStatusSuccess(); } catch (CertificateException | SSLHandshakeException e) { @@ -243,7 +243,7 @@ private void verificationFailed(Exception e) { connected = false; if (!notProvisioned()) { StatusReporter.setFieldAgentStatus().setControllerStatus(ControllerStatus.BROKEN_CERTIFICATE); - logError("controller certificate verification failed", e); + logWarning("controller certificate verification failed"); } StatusReporter.setFieldAgentStatus().setControllerVerified(false); } @@ -340,7 +340,7 @@ private void deleteNode() { try { orchestrator.request("delete-node", RequestType.DELETE, null, null); } catch (Exception e) { - logInfo("can't send delete node command"); + logInfo("Can't send delete node command"); } deProvision(false); } @@ -500,7 +500,7 @@ private JsonArray loadMicroservicesJsonFile() { * @param fromFile - load from file */ private List loadMicroservices(boolean fromFile) { - logInfo("loading microservices..."); + logInfo("Loading microservices..."); if (notProvisioned() || !isControllerConnected(fromFile)) { return new ArrayList<>(); } @@ -724,7 +724,7 @@ private void saveFile(JsonArray data, String filename) { * gets IOFog instance configuration from IOFog controller */ private void getFogConfig() { - logInfo("get fog config"); + logInfo("Get ioFog config"); if (notProvisioned() || !isControllerConnected(false)) { return; } diff --git a/daemon/src/org/eclipse/iofog/message_bus/MessageBus.java b/daemon/src/org/eclipse/iofog/message_bus/MessageBus.java index 9f787f40..1229e208 100644 --- a/daemon/src/org/eclipse/iofog/message_bus/MessageBus.java +++ b/daemon/src/org/eclipse/iofog/message_bus/MessageBus.java @@ -124,8 +124,8 @@ private void init() { try { messageBusServer.createProducer(publisher); } catch (Exception e) { - LoggingService.logError(MODULE_NAME + "(" + publisher + ")", - "unable to start publisher module --> " + e.getMessage(), e); + LoggingService.logWarning(MODULE_NAME + "(" + publisher + ")", + "unable to start publisher module --> " + e.getMessage()); } publishers.put(publisher, new MessagePublisher(publisher, route, messageBusServer.getProducer(publisher))); @@ -204,7 +204,7 @@ private void init() { publishers.put(publisher, new MessagePublisher(publisher, route, messageBusServer.getProducer(publisher))); logInfo("Producer module restarted"); } catch (Exception e) { - logError("Unable to restart producer module for " + publisher + " --> " + e.getMessage(), e); + logWarning("Unable to restart producer module for " + publisher + " --> " + e.getMessage()); } } } @@ -317,9 +317,9 @@ public void start() { try { messageBusServer.stopServer(); } catch (Exception exp) { - logError(exp.getMessage(), exp); + logWarning(exp.getMessage()); } - logError("Unable to start message bus server --> " + e.getMessage(), e); + logWarning("Unable to start message bus server --> " + e.getMessage()); StatusReporter.setSupervisorStatus().setModuleStatus(MESSAGE_BUS, STOPPED); } diff --git a/daemon/src/org/eclipse/iofog/resource_consumption_manager/ResourceConsumptionManager.java b/daemon/src/org/eclipse/iofog/resource_consumption_manager/ResourceConsumptionManager.java index ac883365..66efd874 100644 --- a/daemon/src/org/eclipse/iofog/resource_consumption_manager/ResourceConsumptionManager.java +++ b/daemon/src/org/eclipse/iofog/resource_consumption_manager/ResourceConsumptionManager.java @@ -75,7 +75,7 @@ public static ResourceConsumptionManager getInstance() { try { Thread.sleep(Configuration.getGetUsageDataFreqSeconds() * 1000); - logInfo("get usage data"); + logInfo("Get usage data"); float memoryUsage = getMemoryUsage(); float cpuUsage = getCpuUsage(); diff --git a/daemon/src/org/eclipse/iofog/supervisor/Supervisor.java b/daemon/src/org/eclipse/iofog/supervisor/Supervisor.java index a17684b6..1bfc167f 100644 --- a/daemon/src/org/eclipse/iofog/supervisor/Supervisor.java +++ b/daemon/src/org/eclipse/iofog/supervisor/Supervisor.java @@ -99,7 +99,7 @@ public void start() throws Exception { scheduler.scheduleAtFixedRate(checkLocalApiStatus, 0, 10, SECONDS); StatusReporter.setSupervisorStatus().setDaemonStatus(RUNNING); - logInfo("started"); + logInfo("Started"); Tracker.getInstance().handleEvent(TrackingEventType.START, TrackingInfoUtils.getStartTrackingInfo()); operationDuration(); From e48c164402a090523a95eea5ffea7a8d5bb57537 Mon Sep 17 00:00:00 2001 From: Railag Date: Mon, 18 Feb 2019 18:02:45 +0300 Subject: [PATCH 15/21] bug(fix) removing iofabric host from Agent (ENG-558) (#209) --- daemon/src/org/eclipse/iofog/process_manager/DockerUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/src/org/eclipse/iofog/process_manager/DockerUtil.java b/daemon/src/org/eclipse/iofog/process_manager/DockerUtil.java index dcdd01c2..d6e45024 100755 --- a/daemon/src/org/eclipse/iofog/process_manager/DockerUtil.java +++ b/daemon/src/org/eclipse/iofog/process_manager/DockerUtil.java @@ -472,7 +472,7 @@ public String createContainer(Microservice microservice, String host) throws Not volumeBindings.add(new Bind(volumeMapping.getHostDestination(), volume, accessMode)); }); } - String[] extraHosts = {"iofabric:" + host, "iofog:" + host}; + String[] extraHosts = {"iofog:" + host}; Map containerLogConfig = new HashMap<>(); int logFiles = 1; From 51d3e7233084ce1e3329ffdc1c19d4feb5853127 Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Wed, 20 Feb 2019 13:58:00 +0300 Subject: [PATCH 16/21] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5b1c1544..66e86367 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 4.0.0 org.eclipse iofog-agent - 1.0.12 + 1.0.13 iofog-agent pom From 679e0f9d993757f006949de184cd447a9e42c537 Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Wed, 20 Feb 2019 13:58:19 +0300 Subject: [PATCH 17/21] Update pom.xml --- client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pom.xml b/client/pom.xml index 24d3225a..0f29e3e5 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -16,7 +16,7 @@ org.eclipse iofog-agent - 1.0.12 + 1.0.13 ../pom.xml From ae43d440eae36f692e108c43a6a31828d52bca8e Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Wed, 20 Feb 2019 13:58:37 +0300 Subject: [PATCH 18/21] Update pom.xml --- daemon/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/pom.xml b/daemon/pom.xml index 6958e2e0..ff0f1af1 100644 --- a/daemon/pom.xml +++ b/daemon/pom.xml @@ -16,7 +16,7 @@ org.eclipse iofog-agent - 1.0.12 + 1.0.13 ../pom.xml From 038fb0da2c1fb3d5c99e76f8f8ec29155431be0e Mon Sep 17 00:00:00 2001 From: dbusel <10116634+dbusel@users.noreply.github.com> Date: Wed, 20 Feb 2019 13:59:00 +0300 Subject: [PATCH 19/21] Update pom.xml --- iofog_version_controller/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iofog_version_controller/pom.xml b/iofog_version_controller/pom.xml index f5dfc0ea..3e830435 100644 --- a/iofog_version_controller/pom.xml +++ b/iofog_version_controller/pom.xml @@ -16,7 +16,7 @@ iofog-agent org.eclipse - 1.0.12 + 1.0.13 4.0.0 From 48332a7a79973d9d94916cb0116d91eef0c3b03c Mon Sep 17 00:00:00 2001 From: Railag Date: Mon, 25 Feb 2019 13:55:19 +0300 Subject: [PATCH 20/21] Fixing registries with private repos (#213) * feat(core) local REST API access token between client and daemon (ENG-738) (#210) * feat(core) local REST API access token between client and daemon (ENG-738) * cleanup * bug(fix) fixing private registries (ENG-745) (#211) * bug(fix) added security scan plugin & updated vulnerable libraries (ENG-691) (#212) --- client/src/org/eclipse/iofog/Client.java | 54 ++++++++++++++----- daemon/pom.xml | 26 ++++++--- daemon/src/org/eclipse/iofog/Daemon.java | 8 +-- .../eclipse/iofog/field_agent/FieldAgent.java | 4 +- .../local_api/CommandLineApiHandler.java | 26 +++++++++ .../iofog/microservice/Microservice.java | 40 +++++++------- .../microservice/MicroserviceManager.java | 4 +- .../eclipse/iofog/microservice/Registry.java | 18 +++++-- .../process_manager/ContainerManager.java | 8 +-- .../process_manager/ProcessManagerStatus.java | 6 +-- .../org/eclipse/iofog/utils/Constants.java | 1 + iofog-agent-packaging-rpm/rpm.sh | 2 + iofog-agent-packaging/debian.sh | 2 + 13 files changed, 141 insertions(+), 58 deletions(-) diff --git a/client/src/org/eclipse/iofog/Client.java b/client/src/org/eclipse/iofog/Client.java index 8679901c..10b5e0d5 100644 --- a/client/src/org/eclipse/iofog/Client.java +++ b/client/src/org/eclipse/iofog/Client.java @@ -24,8 +24,18 @@ public class Client { private static final String PROPERTIES_FILE_PATH = "cmd_messages.properties"; + private static final String LOCAL_API_ENDPOINT = "http://localhost:54321/v2/commandline"; + private static final String WINDOWS_IOFOG_PATH = System.getenv("IOFOG_PATH") != null ? + System.getenv("IOFOG_PATH") : "./"; + private static final String SNAP_COMMON = System.getenv("SNAP_COMMON") != null ? + System.getenv("SNAP_COMMON") : ""; + private static final String CONFIG_DIR = isWindows() ? + WINDOWS_IOFOG_PATH : SNAP_COMMON + "/etc/iofog-agent/"; + private static final String LOCAL_API_TOKEN_PATH = CONFIG_DIR + "local-api"; + private static final Properties cmdProperties; + static { cmdProperties = new Properties(); try (InputStream in = Client.class.getResourceAsStream(PROPERTIES_FILE_PATH)) { @@ -46,7 +56,7 @@ private static String getVersion() { */ private static boolean isAnotherInstanceRunning() { try { - URL url = new URL("http://localhost:54321/v2/commandline"); + URL url = new URL(LOCAL_API_ENDPOINT); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.getResponseCode(); @@ -59,7 +69,7 @@ private static boolean isAnotherInstanceRunning() { /** * send command-line parameters to ioFog daemon - * + * * @param args - parameters * */ @@ -71,21 +81,20 @@ private static boolean sendCommandlineParameters(String... args) { } params = new StringBuilder(params.toString().trim() + "\"}"); byte[] postData = params.toString().trim().getBytes(StandardCharsets.UTF_8); - - URL url = new URL("http://localhost:54321/v2/commandline"); + + String accessToken = fetchAccessToken(); + + URL url = new URL(LOCAL_API_ENDPOINT); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); + conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Accept", "text/plain"); conn.setRequestProperty("Content-Length", Integer.toString(postData.length)); + conn.setRequestProperty("Authorization", accessToken); conn.setDoOutput(true); try(DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { wr.write(postData); } - - if (conn.getResponseCode() != 200) { - return false; - } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); @@ -96,17 +105,29 @@ private static boolean sendCommandlineParameters(String... args) { } conn.disconnect(); - + System.out.println(result.toString().replace("\\n", "\n")); - return true; + + return conn.getResponseCode() == 200; } catch (Exception e) { return false; } } + private static String fetchAccessToken() { + String line = ""; + try (BufferedReader reader = new BufferedReader(new FileReader(LOCAL_API_TOKEN_PATH))) { + line = reader.readLine(); + } catch (IOException e) { + System.out.println("Local API access token is missing, try to re-install Agent."); + } + + return line; + } + /** * returns help - * + * * @return String */ private static String showHelp() { @@ -205,7 +226,7 @@ public static void main(String[] args) throws ParseException { System.out.println("Enter \"service iofog-agent stop\""); break; case "start": - System.out.println("iofog is already running."); + System.out.println("ioFog Agent is already running."); break; default: sendCommandlineParameters(args); @@ -228,9 +249,14 @@ public static void main(String[] args) throws ParseException { System.out.println("Enter \"service iofog-agent start\""); break; default: - System.out.println("iofog is not running."); + System.out.println("ioFog Agent is not running."); } } } + private static boolean isWindows() { + String osName = System.getProperty("os.name"); + return osName != null && osName.startsWith("Windows"); + } + } \ No newline at end of file diff --git a/daemon/pom.xml b/daemon/pom.xml index ff0f1af1..59a30701 100644 --- a/daemon/pom.xml +++ b/daemon/pom.xml @@ -36,7 +36,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.3 + 3.8.0 1.8 1.8 @@ -67,7 +67,7 @@ maven-resources-plugin - 2.4.3 + 3.1.0 copy-resources @@ -87,6 +87,18 @@ + + org.owasp + dependency-check-maven + 5.0.0-M1 + + + + check + + + + @@ -103,7 +115,7 @@ io.netty netty-all - 4.0.34.Final + 4.1.33.Final org.hornetq @@ -123,22 +135,22 @@ com.jcraft jsch - 0.1.54 + 0.1.55 com.fasterxml.jackson.core jackson-databind - 2.9.5 + 2.9.8 org.apache.httpcomponents httpmime - 4.4 + 4.5.7 io.sentry sentry - 1.7.16 + 1.7.21 diff --git a/daemon/src/org/eclipse/iofog/Daemon.java b/daemon/src/org/eclipse/iofog/Daemon.java index 6b0a6041..5bb84a58 100644 --- a/daemon/src/org/eclipse/iofog/Daemon.java +++ b/daemon/src/org/eclipse/iofog/Daemon.java @@ -29,6 +29,8 @@ public class Daemon { private static final String MODULE_NAME = "MAIN_DAEMON"; + private static final String LOCAL_API_ENDPOINT = "http://localhost:54321/v2/commandline"; + /** * check if another instance of iofog is running * @@ -37,7 +39,7 @@ public class Daemon { private static boolean isAnotherInstanceRunning() { try { - URL url = new URL("http://localhost:54321/v2/commandline"); + URL url = new URL(LOCAL_API_ENDPOINT); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.getResponseCode(); @@ -67,7 +69,7 @@ private static boolean sendCommandlineParameters(String... args) { params = new StringBuilder(params.toString().trim() + "\"}"); byte[] postData = params.toString().trim().getBytes(UTF_8); - URL url = new URL("http://localhost:54321/v2/commandline"); + URL url = new URL(LOCAL_API_ENDPOINT); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); @@ -164,7 +166,7 @@ public static void main(String[] args) throws ParseException { if (isAnotherInstanceRunning()) { if (args[0].equals("start")) { - System.out.println("iofog is already running."); + System.out.println("ioFog Agent is already running."); } else if (args[0].equals("stop")) { sendCommandlineParameters(args); } diff --git a/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java b/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java index 33b58c01..54f07970 100644 --- a/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java +++ b/daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java @@ -31,7 +31,6 @@ import org.eclipse.iofog.tracking.Tracker; import org.eclipse.iofog.tracking.TrackingEventType; import org.eclipse.iofog.tracking.TrackingInfoUtils; -import org.eclipse.iofog.utils.Constants; import org.eclipse.iofog.utils.Orchestrator; import org.eclipse.iofog.utils.configuration.Configuration; import org.eclipse.iofog.utils.logging.LoggingService; @@ -434,6 +433,7 @@ private void loadRegistries(boolean fromFile) { for (int i = 0; i < registriesList.size(); i++) { JsonObject registry = registriesList.getJsonObject(i); Registry.RegistryBuilder registryBuilder = new Registry.RegistryBuilder() + .setId(registry.getInt("id")) .setUrl(registry.getString("url")) .setIsPublic(registry.getBoolean("isPublic", false)); if (!registry.getBoolean("isPublic", false)) { @@ -547,7 +547,7 @@ private Function containerJsonObjectToMicroserviceFunc microservice.setConfig(jsonObj.getString("config")); microservice.setRebuild(jsonObj.getBoolean("rebuild")); microservice.setRootHostAccess(jsonObj.getBoolean("rootHostAccess")); - microservice.setRegistry(jsonObj.getString("registryUrl")); + microservice.setRegistryId(jsonObj.getInt("registryId")); microservice.setLogSize(jsonObj.getJsonNumber("logSize").longValue()); microservice.setDelete(jsonObj.getBoolean("delete")); microservice.setDeleteWithCleanup(jsonObj.getBoolean("deleteWithCleanup")); diff --git a/daemon/src/org/eclipse/iofog/local_api/CommandLineApiHandler.java b/daemon/src/org/eclipse/iofog/local_api/CommandLineApiHandler.java index 196c5bbe..6d849cb1 100644 --- a/daemon/src/org/eclipse/iofog/local_api/CommandLineApiHandler.java +++ b/daemon/src/org/eclipse/iofog/local_api/CommandLineApiHandler.java @@ -21,6 +21,9 @@ import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonReader; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; import java.io.StringReader; import java.util.concurrent.Callable; @@ -28,6 +31,7 @@ import static io.netty.handler.codec.http.HttpResponseStatus.OK; import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.iofog.utils.Constants.LOCAL_API_TOKEN_PATH; public class CommandLineApiHandler implements Callable { private static final String MODULE_NAME = "Local API"; @@ -61,6 +65,17 @@ public FullHttpResponse call() throws Exception { return new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.BAD_REQUEST, outputBuffer); } + final String validAccessToken = fetchAccessToken(); + final String accessToken = headers.get(HttpHeaderNames.AUTHORIZATION, ""); + final boolean emptyAccessToken = TextUtils.isEmpty(accessToken); + if (emptyAccessToken || !(headers.get(HttpHeaderNames.AUTHORIZATION).equalsIgnoreCase(validAccessToken))) { + String errorMsg = " Incorrect access token "; + if (!emptyAccessToken) + LoggingService.logWarning(MODULE_NAME, errorMsg); + outputBuffer.writeBytes(errorMsg.getBytes(UTF_8)); + return new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.UNAUTHORIZED, outputBuffer); + } + try { String msgString = new String(content, UTF_8); JsonReader reader = Json.createReader(new StringReader(msgString)); @@ -81,4 +96,15 @@ public FullHttpResponse call() throws Exception { } } + private String fetchAccessToken() { + String line = ""; + try (BufferedReader reader = new BufferedReader(new FileReader(LOCAL_API_TOKEN_PATH))) { + line = reader.readLine(); + } catch (IOException e) { + System.out.println("Local API access token is missing, try to re-install Agent."); + } + + return line; + } + } diff --git a/daemon/src/org/eclipse/iofog/microservice/Microservice.java b/daemon/src/org/eclipse/iofog/microservice/Microservice.java index f4360f9a..2999d9b2 100644 --- a/daemon/src/org/eclipse/iofog/microservice/Microservice.java +++ b/daemon/src/org/eclipse/iofog/microservice/Microservice.java @@ -28,7 +28,7 @@ public class Microservice { private String config; private List routes; private String containerId; - private String registry; + private int registryId; private String containerIpAddress; private boolean rebuild; private boolean rootHostAccess; @@ -61,12 +61,12 @@ public void setContainerIpAddress(String containerIpAddress) { this.containerIpAddress = containerIpAddress; } - public String getRegistry() { - return registry; + public int getRegistryId() { + return registryId; } - public void setRegistry(String registry) { - this.registry = registry; + public void setRegistryId(int registryId) { + this.registryId = registryId; } public String getContainerId() { @@ -125,13 +125,13 @@ public void setVolumeMappings(List volumeMappings) { this.volumeMappings = volumeMappings; } - public synchronized boolean isUpdating() { - return isUpdating; - } + public synchronized boolean isUpdating() { + return isUpdating; + } - public synchronized void setUpdating(boolean updating) { - isUpdating = updating; - } + public synchronized void setUpdating(boolean updating) { + isUpdating = updating; + } public boolean isDelete() { return delete; @@ -150,17 +150,17 @@ public void setDeleteWithCleanup(boolean deleteWithCleanUp) { } @Override - public boolean equals(Object e) { + public boolean equals(Object e) { if (this == e) return true; if (e == null || getClass() != e.getClass()) return false; - Microservice microservice = (Microservice) e; - return this.microserviceUuid.equals(microservice.getMicroserviceUuid()); - } - - @Override - public int hashCode() { - return microserviceUuid.hashCode(); - } + Microservice microservice = (Microservice) e; + return this.microserviceUuid.equals(microservice.getMicroserviceUuid()); + } + + @Override + public int hashCode() { + return microserviceUuid.hashCode(); + } public List getRoutes() { return routes; diff --git a/daemon/src/org/eclipse/iofog/microservice/MicroserviceManager.java b/daemon/src/org/eclipse/iofog/microservice/MicroserviceManager.java index 9bb2d0a3..2336ecdf 100644 --- a/daemon/src/org/eclipse/iofog/microservice/MicroserviceManager.java +++ b/daemon/src/org/eclipse/iofog/microservice/MicroserviceManager.java @@ -69,10 +69,10 @@ public List getRegistries() { } } - public Registry getRegistry(String name) { + public Registry getRegistry(int id) { synchronized (MicroserviceManager.class) { for (Registry registry : registries) { - if (registry.getUrl().equalsIgnoreCase(name)) + if (registry.getId() == id) return registry; } return null; diff --git a/daemon/src/org/eclipse/iofog/microservice/Registry.java b/daemon/src/org/eclipse/iofog/microservice/Registry.java index 425c1f2a..d3cc1a1d 100644 --- a/daemon/src/org/eclipse/iofog/microservice/Registry.java +++ b/daemon/src/org/eclipse/iofog/microservice/Registry.java @@ -21,6 +21,7 @@ * */ public class Registry { + private final int id; private final String url; private final boolean isPublic; private final boolean secure; @@ -30,8 +31,9 @@ public class Registry { private final String password; private final String userEmail; - private Registry(final String url, final boolean isPublic, final boolean secure, final String certificate, final boolean requiresCertificate, + private Registry(final int id, final String url, final boolean isPublic, final boolean secure, final String certificate, final boolean requiresCertificate, final String userName, final String password, final String userEmail) { + this.id = id; this.url = url; this.isPublic = isPublic; this.secure = secure; @@ -42,6 +44,10 @@ private Registry(final String url, final boolean isPublic, final boolean secure, this.userEmail = userEmail; } + public int getId() { + return id; + } + public String getUrl() { return url; } @@ -82,7 +88,7 @@ public boolean equals(Object o) { Registry registry = (Registry) o; if (isPublic != registry.isPublic) return false; - return url.equals(registry.url); + return id == registry.id; } @Override @@ -91,6 +97,7 @@ public int hashCode() { } public static class RegistryBuilder { + private int id; private String url; private boolean isPublic; private boolean secure; @@ -100,6 +107,11 @@ public static class RegistryBuilder { private String password; private String userEmail; + public RegistryBuilder setId(int id) { + this.id = id; + return this; + } + public RegistryBuilder setUrl(String url) { this.url = url; return this; @@ -141,7 +153,7 @@ public RegistryBuilder setUserEmail(String userEmail) { } public Registry build() { - return new Registry(url, isPublic, secure, certificate, requiresCertificate, userName, password, userEmail); + return new Registry(id, url, isPublic, secure, certificate, requiresCertificate, userName, password, userEmail); } } } diff --git a/daemon/src/org/eclipse/iofog/process_manager/ContainerManager.java b/daemon/src/org/eclipse/iofog/process_manager/ContainerManager.java index 5c4e52e8..8994a708 100644 --- a/daemon/src/org/eclipse/iofog/process_manager/ContainerManager.java +++ b/daemon/src/org/eclipse/iofog/process_manager/ContainerManager.java @@ -56,9 +56,9 @@ private void addContainer(Microservice microservice) throws Exception { private Registry getRegistry(Microservice microservice) throws Exception { Registry registry; - registry = microserviceManager.getRegistry(microservice.getRegistry()); + registry = microserviceManager.getRegistry(microservice.getRegistryId()); if (registry == null) { - throw new Exception(String.format("registry is not valid \"%s\"", microservice.getRegistry())); + throw new Exception(String.format("registry is not valid \"%d\"", microservice.getRegistryId())); } return registry; } @@ -77,8 +77,8 @@ private void updateContainer(Microservice microservice, boolean withCleanUp) thr } private void createContainer(Microservice microservice) throws Exception { - if (!microservice.getRegistry().equals("from_cache")){ - Registry registry = getRegistry(microservice); + Registry registry = getRegistry(microservice); + if (registry.getUrl().equals("from_cache")){ LoggingService.logInfo(MODULE_NAME, "pulling \"" + microservice.getImageName() + "\" from registry"); docker.pullImage(microservice.getImageName(), registry); LoggingService.logInfo(MODULE_NAME, String.format("\"%s\" pulled", microservice.getImageName())); diff --git a/daemon/src/org/eclipse/iofog/process_manager/ProcessManagerStatus.java b/daemon/src/org/eclipse/iofog/process_manager/ProcessManagerStatus.java index d00ac132..44ed6824 100644 --- a/daemon/src/org/eclipse/iofog/process_manager/ProcessManagerStatus.java +++ b/daemon/src/org/eclipse/iofog/process_manager/ProcessManagerStatus.java @@ -31,7 +31,7 @@ public class ProcessManagerStatus { private int runningMicroservicesCount; private final Map microservicesStatus; - private final Map registriesStatus; + private final Map registriesStatus; public ProcessManagerStatus() { microservicesStatus = new HashMap<>(); @@ -75,7 +75,7 @@ public String getJsonRegistriesStatus() { JsonArrayBuilder arrayBuilder = Json.createArrayBuilder(); registriesStatus.forEach((key, value) -> { JsonObjectBuilder objectBuilder = Json.createObjectBuilder() - .add("url", key) + .add("id", key) .add("linkStatus", value.toString()); arrayBuilder.add(objectBuilder); @@ -117,7 +117,7 @@ public int getRegistriesCount() { return MicroserviceManager.getInstance().getRegistries().size(); } - public Map getRegistriesStatus() { + public Map getRegistriesStatus() { return registriesStatus; } diff --git a/daemon/src/org/eclipse/iofog/utils/Constants.java b/daemon/src/org/eclipse/iofog/utils/Constants.java index 30ac817f..72e5a3bc 100755 --- a/daemon/src/org/eclipse/iofog/utils/Constants.java +++ b/daemon/src/org/eclipse/iofog/utils/Constants.java @@ -97,6 +97,7 @@ public String fullValue() { SNAP_COMMON + "./var/run/iofog-agent" : SNAP_COMMON + "/var/run/iofog-agent"; private static final String CONFIG_DIR = SystemUtils.IS_OS_WINDOWS ? WINDOWS_IOFOG_PATH : SNAP_COMMON + "/etc/iofog-agent/"; + public static final String LOCAL_API_TOKEN_PATH = CONFIG_DIR + "local-api"; public static final String DEFAULT_CONFIG_PATH = CONFIG_DIR + "config.xml"; public static final String DEVELOPMENT_CONFIG_PATH = CONFIG_DIR + "config-development.xml"; public static final String PRODUCTION_CONFIG_PATH = CONFIG_DIR + "config-production.xml"; diff --git a/iofog-agent-packaging-rpm/rpm.sh b/iofog-agent-packaging-rpm/rpm.sh index 1d39a724..71337731 100644 --- a/iofog-agent-packaging-rpm/rpm.sh +++ b/iofog-agent-packaging-rpm/rpm.sh @@ -53,6 +53,8 @@ else fi #echo "Check for config.xml" + /etc/iofog-agent/local-api + mkdir -p /var/backups/iofog-agent mkdir -p /var/log/iofog-agent mkdir -p /var/lib/iofog-agent diff --git a/iofog-agent-packaging/debian.sh b/iofog-agent-packaging/debian.sh index 6a8c36b2..d668bdbc 100644 --- a/iofog-agent-packaging/debian.sh +++ b/iofog-agent-packaging/debian.sh @@ -50,6 +50,8 @@ else fi echo "Check for cert.crt" + /etc/iofog-agent/local-api + mkdir -p /var/backups/iofog-agent mkdir -p /var/log/iofog-agent mkdir -p /var/lib/iofog-agent From e73ef855602010f4922fda55ced39f3f22055fec Mon Sep 17 00:00:00 2001 From: Railag Date: Tue, 26 Feb 2019 14:02:51 +0300 Subject: [PATCH 21/21] Hotfix for registries (#215) --- .../org/eclipse/iofog/process_manager/ContainerManager.java | 2 +- .../org/eclipse/iofog/utils/configuration/Configuration.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/daemon/src/org/eclipse/iofog/process_manager/ContainerManager.java b/daemon/src/org/eclipse/iofog/process_manager/ContainerManager.java index 8994a708..84801de1 100644 --- a/daemon/src/org/eclipse/iofog/process_manager/ContainerManager.java +++ b/daemon/src/org/eclipse/iofog/process_manager/ContainerManager.java @@ -78,7 +78,7 @@ private void updateContainer(Microservice microservice, boolean withCleanUp) thr private void createContainer(Microservice microservice) throws Exception { Registry registry = getRegistry(microservice); - if (registry.getUrl().equals("from_cache")){ + if (!registry.getUrl().equals("from_cache")){ LoggingService.logInfo(MODULE_NAME, "pulling \"" + microservice.getImageName() + "\" from registry"); docker.pullImage(microservice.getImageName(), registry); LoggingService.logInfo(MODULE_NAME, String.format("\"%s\" pulled", microservice.getImageName())); diff --git a/daemon/src/org/eclipse/iofog/utils/configuration/Configuration.java b/daemon/src/org/eclipse/iofog/utils/configuration/Configuration.java index 367e9264..c3a7e6af 100644 --- a/daemon/src/org/eclipse/iofog/utils/configuration/Configuration.java +++ b/daemon/src/org/eclipse/iofog/utils/configuration/Configuration.java @@ -1088,7 +1088,8 @@ public static void setupSupervisor() { Supervisor supervisor = new Supervisor(); supervisor.start(); } catch (Exception exp) { - LoggingService.logWarning(MODULE_NAME, exp.getMessage()); + LoggingService.logWarning(MODULE_NAME, "Error while starting supervisor: " + + exp.getMessage()); } } } \ No newline at end of file