From 3ed3ed6c21c5db8b48233975e9259a6b43fea311 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jul 2020 15:23:45 +0300 Subject: [PATCH 1/4] Bump mysql-connector-java from 8.0.12 to 8.0.16 (#17310) Bumps [mysql-connector-java](https://github.com/mysql/mysql-connector-j) from 8.0.12 to 8.0.16. - [Release notes](https://github.com/mysql/mysql-connector-j/releases) - [Changelog](https://github.com/mysql/mysql-connector-j/blob/release/8.0/CHANGES) - [Commits](https://github.com/mysql/mysql-connector-j/compare/8.0.12...8.0.16) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ff1eb4f10d0..93c22544f7f 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ 2.0 4.11 4.11 - 8.0.12 + 8.0.16 4.1.0 4.0.7 3.8.1 From 313872f060c001a5e61fce609d5ada61c3e52cb1 Mon Sep 17 00:00:00 2001 From: Florent Benoit Date: Wed, 1 Jul 2020 10:54:00 +0200 Subject: [PATCH 2/4] fix(github-alert): Fix minimist issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 minimist vulnerability found in …/e2e/package-lock.json 22 days ago Remediation Upgrade minimist to version 0.2.1 or later. For example: "dependencies": { "minimist": ">=0.2.1" } Change-Id: I2a627a836dcf981c0b8359434ea4c026a1728f27 Signed-off-by: Florent Benoit --- tests/e2e/package-lock.json | 49 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/tests/e2e/package-lock.json b/tests/e2e/package-lock.json index beb8da2bb2e..658a9332681 100644 --- a/tests/e2e/package-lock.json +++ b/tests/e2e/package-lock.json @@ -266,6 +266,12 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "dev": true + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -599,15 +605,15 @@ "dev": true }, "extract-zip": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", - "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", + "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", "dev": true, "requires": { - "concat-stream": "1.6.2", - "debug": "2.6.9", - "mkdirp": "0.5.1", - "yauzl": "2.4.1" + "concat-stream": "^1.6.2", + "debug": "^2.6.9", + "mkdirp": "^0.5.4", + "yauzl": "^2.10.0" } }, "fast-glob": { @@ -634,9 +640,9 @@ } }, "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", "dev": true, "requires": { "pend": "~1.2.0" @@ -1067,18 +1073,18 @@ } }, "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" } }, "mocha": { @@ -1829,12 +1835,13 @@ } }, "yauzl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", "dev": true, "requires": { - "fd-slicer": "~1.0.1" + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" } }, "yn": { From bf671af628bac1b9c6f8f2eb43cede552030f0ea Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Tue, 7 Jul 2020 14:46:26 +0300 Subject: [PATCH 3/4] Fix error when multiple K8s/os components have mountSources:true --- .../KubernetesEnvironmentProvisioner.java | 15 +++++++++ .../kubernetes/environment/PodMerger.java | 5 +++ .../KubernetesEnvironmentProvisionerTest.java | 32 +++++++++++++++++++ .../kubernetes/environment/PodMergerTest.java | 26 +++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/KubernetesEnvironmentProvisioner.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/KubernetesEnvironmentProvisioner.java index 19e2084fcbb..a6daaa47379 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/KubernetesEnvironmentProvisioner.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/KubernetesEnvironmentProvisioner.java @@ -13,12 +13,14 @@ import static java.lang.String.format; import static java.util.Collections.emptyMap; +import static org.eclipse.che.api.workspace.shared.Constants.PROJECTS_VOLUME_NAME; import static org.eclipse.che.workspace.infrastructure.kubernetes.devfile.KubernetesDevfileBindings.ALLOWED_ENVIRONMENT_TYPE_UPGRADES_KEY_NAME; import static org.eclipse.che.workspace.infrastructure.kubernetes.devfile.KubernetesDevfileBindings.KUBERNETES_BASED_ENVIRONMENTS_KEY_NAME; import com.google.common.annotations.VisibleForTesting; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesListBuilder; +import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; import io.fabric8.kubernetes.client.KubernetesClientException; import io.fabric8.kubernetes.client.utils.Serialization; import java.util.HashSet; @@ -119,12 +121,25 @@ public void provision( // workspace already has k8s/OS recipe // it is needed to merge existing recipe objects with component's ones List envObjects = unmarshalObjects(envRecipe); + mergeProjectsPVC(envObjects, componentObjects); envObjects.addAll(componentObjects); + checkItemsHasUniqueKindToName(envObjects); envRecipe.setContent(asYaml(envObjects)); } } + private void mergeProjectsPVC(List envObjects, List componentObjects) { + componentObjects.removeIf( + co -> + co instanceof PersistentVolumeClaim + && co.getMetadata().getName().equals(PROJECTS_VOLUME_NAME) + && envObjects + .stream() + .filter(envObject -> envObject instanceof PersistentVolumeClaim) + .anyMatch(pvc -> pvc.equals(co))); + } + private List unmarshalObjects(RecipeImpl k8sRecipe) throws DevfileException { if (!k8sBasedEnvTypes.contains(k8sRecipe.getType())) { String allowedEnvTypes = String.join(" or ", k8sBasedEnvTypes); diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/environment/PodMerger.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/environment/PodMerger.java index 55758167650..3602882c278 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/environment/PodMerger.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/environment/PodMerger.java @@ -12,6 +12,7 @@ package org.eclipse.che.workspace.infrastructure.kubernetes.environment; import static java.lang.String.format; +import static org.eclipse.che.api.workspace.shared.Constants.PROJECTS_VOLUME_NAME; import static org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.putAnnotations; import static org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.putLabels; @@ -104,6 +105,10 @@ public Deployment merge(List podsData) throws ValidationException { for (Volume volume : podData.getSpec().getVolumes()) { if (!volumes.add(volume.getName())) { + if (volume.getName().equals(PROJECTS_VOLUME_NAME)) { + // project volume already added, can be skipped + continue; + } throw new ValidationException( format( "Pods have to have volumes with unique names but there are multiple `%s` volumes", diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/KubernetesEnvironmentProvisionerTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/KubernetesEnvironmentProvisionerTest.java index a4d144bceb6..dc306d6412d 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/KubernetesEnvironmentProvisionerTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/KubernetesEnvironmentProvisionerTest.java @@ -14,8 +14,11 @@ import static io.fabric8.kubernetes.client.utils.Serialization.unmarshal; import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonList; import static org.eclipse.che.api.workspace.server.devfile.Constants.KUBERNETES_COMPONENT_TYPE; +import static org.eclipse.che.api.workspace.shared.Constants.PROJECTS_VOLUME_NAME; import static org.eclipse.che.workspace.infrastructure.kubernetes.devfile.KubernetesEnvironmentProvisioner.YAML_CONTENT_TYPE; +import static org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.newPVC; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doReturn; import static org.testng.Assert.assertEquals; @@ -25,10 +28,12 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesList; import io.fabric8.kubernetes.api.model.KubernetesListBuilder; +import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.ServiceBuilder; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; +import io.fabric8.kubernetes.client.utils.Serialization; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -274,6 +279,33 @@ public void shouldThrowExceptionIfDifferentComponentsHaveObjectsWithTheSameKindA workspaceConfig, KubernetesEnvironment.TYPE, componentsObject, emptyMap()); } + @Test + public void shouldMergeProjectPVCIntoOne() throws Exception { + // given + PersistentVolumeClaim volumeClaim = newPVC(PROJECTS_VOLUME_NAME, "ReadWriteMany", "1Gb"); + workspaceConfig.setDefaultEnv("default"); + RecipeImpl existingRecipe = + new RecipeImpl("kubernetes", YAML_CONTENT_TYPE, Serialization.asYaml(volumeClaim), null); + doReturn(singletonList(volumeClaim)).when(k8sRecipeParser).parse(anyString()); + + workspaceConfig + .getEnvironments() + .put("default", new EnvironmentImpl(existingRecipe, emptyMap())); + + // try add same claim one more time (like another component adds it) + List componentsObject = new ArrayList<>(); + componentsObject.add(volumeClaim); + + // when + k8sEnvProvisioner.provision( + workspaceConfig, KubernetesEnvironment.TYPE, componentsObject, emptyMap()); + + // we still have only one PVC + EnvironmentImpl resultEnv = + workspaceConfig.getEnvironments().get(workspaceConfig.getDefaultEnv()); + assertEquals(toK8SList(resultEnv.getRecipe().getContent()).getItems().size(), 1); + } + @Test( expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/environment/PodMergerTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/environment/PodMergerTest.java index 76eb2130f5f..9e8bce9b62a 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/environment/PodMergerTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/environment/PodMergerTest.java @@ -11,6 +11,7 @@ */ package org.eclipse.che.workspace.infrastructure.kubernetes.environment; +import static org.eclipse.che.api.workspace.shared.Constants.PROJECTS_VOLUME_NAME; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertTrue; @@ -212,6 +213,31 @@ public void shouldThrownAnExceptionIfVolumeNameCollisionHappened() throws Except podMerger.merge(Arrays.asList(podData1, podData2)); } + @Test + public void shouldMergeProjectVolumesWithoutException() throws Exception { + // given + PodSpec podSpec1 = + new PodSpecBuilder() + .withVolumes(new VolumeBuilder().withName(PROJECTS_VOLUME_NAME).build()) + .build(); + podSpec1.setAdditionalProperty("add1", 1L); + PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); + + PodSpec podSpec2 = + new PodSpecBuilder() + .withVolumes(new VolumeBuilder().withName(PROJECTS_VOLUME_NAME).build()) + .build(); + podSpec2.setAdditionalProperty("add2", 2L); + PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); + + // when + Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); + + // then + PodTemplateSpec podTemplate = merged.getSpec().getTemplate(); + assertEquals(podTemplate.getSpec().getVolumes().size(), 1); + } + @Test public void shouldNotAddImagePullPolicyTwice() throws Exception { // given From 7c93f5646283fc85aab989d7ba7e6e8f80931565 Mon Sep 17 00:00:00 2001 From: Igor Ohrimenko Date: Tue, 7 Jul 2020 22:32:08 +0300 Subject: [PATCH 4/4] Rework the "Terminal.getText" method for avoiding tests failures (#17344) * Update the 'Terminal.getText' method Signed-off-by: Ihor Okhrimenko * Revert "Throw an error if workspace is not stopped in given time. (#17281)" This reverts commit 3d60fde24984287a4e9a6cdaa72ce2cb99e9b2cd. Signed-off-by: Dmytro Nochevnov Co-authored-by: Dmytro Nochevnov --- tests/e2e/pageobjects/ide/Ide.ts | 8 +++++++- tests/e2e/pageobjects/ide/Terminal.ts | 18 +++++++++++++++++- tests/e2e/utils/workspace/TestWorkspaceUtil.ts | 3 --- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/e2e/pageobjects/ide/Ide.ts b/tests/e2e/pageobjects/ide/Ide.ts index f221ba27e75..42175f96605 100644 --- a/tests/e2e/pageobjects/ide/Ide.ts +++ b/tests/e2e/pageobjects/ide/Ide.ts @@ -137,7 +137,13 @@ export class Ide { const mainIdeParts: Array = [By.css(Ide.TOP_MENU_PANEL_CSS), By.css(Ide.LEFT_CONTENT_PANEL_CSS), By.id(Ide.EXPLORER_BUTTON_ID)]; for (const idePartLocator of mainIdeParts) { - await this.driverHelper.waitVisibility(idePartLocator, timeout); + try { + await this.driverHelper.waitVisibility(idePartLocator, timeout); + } catch (err) { + if (err instanceof error.NoSuchWindowError) { + await this.driverHelper.waitVisibility(idePartLocator, timeout); + } + } } } diff --git a/tests/e2e/pageobjects/ide/Terminal.ts b/tests/e2e/pageobjects/ide/Terminal.ts index 7b432691f01..1fe96663748 100644 --- a/tests/e2e/pageobjects/ide/Terminal.ts +++ b/tests/e2e/pageobjects/ide/Terminal.ts @@ -132,6 +132,21 @@ export class Terminal { } private async getTerminalIndex(terminalTitle: string): Promise { + for (let i: number = 0; i < 10; i++) { + try { + return await this.searchTerminalIndex(terminalTitle); + } catch (err) { + if (!(err instanceof error.NoSuchElementError)) { + throw err; + } + + } + } + + throw new error.NoSuchElementError(`The terminal with title '${terminalTitle}' has not been found.`); + } + + private async searchTerminalIndex(terminalTitle: string): Promise { const terminalTabTitleXpathLocator: string = `//div[@id='theia-bottom-content-panel']` + `//li[contains(@id, 'shell-tab-terminal') or contains(@id, 'shell-tab-plugin')]` + `//div[@class='p-TabBar-tabLabel']`; @@ -152,8 +167,9 @@ export class Terminal { terminalTitles.push(currentTerminalTitle); } - throw new error.WebDriverError(`The terminal with title '${terminalTitle}' has not been found.\n` + + throw new error.NoSuchElementError(`The terminal with title '${terminalTitle}' has not been found.\n` + `List of the tabs:\n${terminalTitles}`); + } private getTerminalEditorInteractionEditorLocator(terminalIndex: number): By { diff --git a/tests/e2e/utils/workspace/TestWorkspaceUtil.ts b/tests/e2e/utils/workspace/TestWorkspaceUtil.ts index 5e6e3038e8d..17c226804db 100644 --- a/tests/e2e/utils/workspace/TestWorkspaceUtil.ts +++ b/tests/e2e/utils/workspace/TestWorkspaceUtil.ts @@ -164,9 +164,6 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil { } await this.driverHelper.wait(TestConstants.TS_SELENIUM_DEFAULT_POLLING); } - const wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl); - let waitTime = TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS * TestConstants.TS_SELENIUM_DEFAULT_POLLING; - throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Currnet status is: ${wsStatus.data.status}`); } catch (err) { console.log(`Stopping workspace failed. URL used: ${stopWorkspaceApiUrl}`); throw err;