Browse Source

Merge branch 'belanger/add-ecr-push' into dev

Alexander Belanger 4 years ago
parent
commit
7ce77fdb4e

+ 24 - 0
.github/workflows/dev.yaml

@@ -86,3 +86,27 @@ jobs:
           aws eks --region ${{ secrets.AWS_REGION }} update-kubeconfig --name dev
             
           kubectl rollout restart deployment/provisioner
+  build-push-ecr:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v2.3.4
+    - name: Set Github tag
+      id: vars
+      run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+    - name: Configure AWS credentials
+      uses: aws-actions/configure-aws-credentials@v1
+      with:
+        aws-access-key-id: ${{ secrets.ECR_DEV_AWS_ACCESS_KEY_ID }}
+        aws-secret-access-key: ${{ secrets.ECR_DEV_AWS_ACCESS_SECRET_KEY }}
+        aws-region: us-east-2
+    - name: Login to ECR
+      id: login-ecr
+      run: |
+        aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 801172602658.dkr.ecr.us-east-2.amazonaws.com
+    - name: Build
+      run: |
+        DOCKER_BUILDKIT=1 docker build . -t 801172602658.dkr.ecr.us-east-2.amazonaws.com/porter:${{ steps.vars.outputs.sha_short }} -f ./ee/docker/provisioner.Dockerfile
+    - name: Push to ECR
+      run: |
+        docker push 801172602658.dkr.ecr.us-east-2.amazonaws.com/provisioner:${{ steps.vars.outputs.sha_short }}

+ 3 - 0
.github/workflows/prerelease.yaml

@@ -540,6 +540,9 @@ jobs:
           sed -i 's/uses: porter-dev\/porter-update-action.*/uses: porter-dev\/porter-update-action@${{ steps.tag_name.outputs.tag }}/g' porter_test_docker_production.yml
           sed -i 's/uses: porter-dev\/porter-cli-action.*/uses: porter-dev\/porter-cli-action@${{ steps.tag_name.outputs.tag }}/g' porter_test_docker_production.yml
 
+          sed -i 's/uses: porter-dev\/porter-update-action.*/uses: porter-dev\/porter-update-action@${{ steps.tag_name.outputs.tag }}/g' test_porter_cli.yml
+          sed -i 's/uses: porter-dev\/porter-cli-action.*/uses: porter-dev\/porter-cli-action@${{ steps.tag_name.outputs.tag }}/g' test_porter_cli.yml
+
           cd ../..
 
           git config user.name "Update Bot"

+ 3 - 2
api/server/handlers/release/update_image_batch.go

@@ -82,8 +82,9 @@ func (c *UpdateImageBatchHandler) ServeHTTP(w http.ResponseWriter, r *http.Reque
 
 			if err != nil {
 				mu.Lock()
-				errors = append(errors, err.Error())
+				errors = append(errors, fmt.Sprintf("Error for %s, index %d: %s", releases[index].Name, index, err.Error()))
 				mu.Unlock()
+				return
 			}
 
 			if rel.Chart.Name() == "job" {
@@ -105,7 +106,7 @@ func (c *UpdateImageBatchHandler) ServeHTTP(w http.ResponseWriter, r *http.Reque
 
 				if err != nil {
 					mu.Lock()
-					errors = append(errors, err.Error())
+					errors = append(errors, fmt.Sprintf("Error for %s, index %d: %s", releases[index].Name, index, err.Error()))
 					mu.Unlock()
 				}
 			}

+ 1 - 1
cli/cmd/portforward.go

@@ -140,7 +140,7 @@ func portForward(user *types.GetAuthenticatedUserResponse, client *api.Client, a
 			return err
 		}
 
-		pod = pods[podIdx]
+		pod = pods[podIdx-1]
 	} else {
 		pod = pods[0]
 	}

+ 1 - 1
dashboard/src/components/image-selector/ImageList.tsx

@@ -172,7 +172,7 @@ export default class ImageList extends Component<PropsType, StateType> {
           <Loading />
         </LoadingWrapper>
       );
-    } else if (error || !images) {
+    } else if (error || !Array.isArray(images)) {
       return <LoadingWrapper>Error loading repos</LoadingWrapper>;
     } else if (images.length === 0) {
       return <LoadingWrapper>No registries found.</LoadingWrapper>;

+ 0 - 1
dashboard/src/components/image-selector/ImageSelector.tsx

@@ -95,7 +95,6 @@ export default class ImageSelector extends Component<PropsType, StateType> {
         <img src={icon} />
         <Input
           disabled={this.props.disableImageSelect}
-          autoFocus={true}
           onClick={(e: any) => e.stopPropagation()}
           value={selectedImageUrl}
           onChange={(e: any) => {

+ 9 - 5
dashboard/src/components/image-selector/TagList.tsx

@@ -56,18 +56,22 @@ export default class TagList extends Component<PropsType, StateType> {
         }
       )
       .then((res) => {
+        let tags: any[] = res.data;
         // Sort if timestamp is available
         if (res.data.length > 0 && res.data[0].pushed_at) {
-          res.data.sort((a: any, b: any) => {
+          tags = tags.sort((a: any, b: any) => {
             let d1 = new Date(a.pushed_at);
             let d2 = new Date(b.pushed_at);
             return d2.getTime() - d1.getTime();
           });
         }
-        let tags = res.data.map((tag: any, i: number) => {
-          return tag.tag;
-        });
-        this.setState({ tags, loading: false });
+
+        const latestImageIndex = tags.findIndex((tag) => tag.tag === "latest");
+        if (latestImageIndex > -1) {
+          const [latestImage] = tags.splice(latestImageIndex, 1);
+          tags.unshift(latestImage);
+        }
+        this.setState({ tags: tags.map((tag) => tag.tag), loading: false });
       })
       .catch((err) => {
         console.log(err);

+ 8 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -24,6 +24,7 @@ import TitleSection from "components/TitleSection";
 import DeploymentType from "./DeploymentType";
 import IncidentsTab from "./incidents/IncidentsTab";
 import BuildSettingsTab from "./BuildSettingsTab";
+import { DisabledNamespacesForIncidents } from "./incidents/DisabledNamespaces";
 
 type Props = {
   namespace: string;
@@ -406,6 +407,9 @@ const ExpandedChart: React.FC<Props> = (props) => {
       case "metrics":
         return <MetricsSection currentChart={chart} />;
       case "incidents":
+        if (DisabledNamespacesForIncidents.includes(currentChart.namespace)) {
+          return null;
+        }
         return (
           <IncidentsTab
             releaseName={chart?.name}
@@ -506,7 +510,10 @@ const ExpandedChart: React.FC<Props> = (props) => {
     let rightTabOptions = [] as any[];
     let leftTabOptions = [] as any[];
     leftTabOptions.push({ label: "Status", value: "status" });
-    leftTabOptions.push({ label: "Incidents", value: "incidents" });
+
+    if (!DisabledNamespacesForIncidents.includes(currentChart.namespace)) {
+      leftTabOptions.push({ label: "Incidents", value: "incidents" });
+    }
 
     if (props.isMetricsInstalled) {
       leftTabOptions.push({ label: "Metrics", value: "metrics" });

+ 28 - 37
dashboard/src/main/home/cluster-dashboard/expanded-chart/SettingsSection.tsx

@@ -217,35 +217,33 @@ const SettingsSection: React.FC<PropsType> = ({
 
     return (
       <>
-        {!isDeployedFromGithub(currentChart) ? (
-          <>
-            <Heading>Source Settings</Heading>
-            <Helper>Specify an image tag to use.</Helper>
-            <ImageSelector
-              selectedTag={selectedTag}
-              selectedImageUrl={selectedImageUrl}
-              setSelectedImageUrl={(x: string) => setSelectedImageUrl(x)}
-              setSelectedTag={(x: string) => setSelectedTag(x)}
-              forceExpanded={true}
-              disableImageSelect={true}
-            />
-            {!loadingWebhookToken && (
-              <>
-                <Br />
-                <Br />
-                <Br />
-                <SaveButton
-                  clearPosition={true}
-                  statusPosition="right"
-                  text="Save Source Settings"
-                  status={saveValuesStatus}
-                  onClick={handleSubmit}
-                />
-              </>
-            )}
-            <Br />
-          </>
-        ) : null}
+        <>
+          <Heading>Source Settings</Heading>
+          <Helper>Specify an image tag to use.</Helper>
+          <ImageSelector
+            selectedTag={selectedTag}
+            selectedImageUrl={selectedImageUrl}
+            setSelectedImageUrl={(x: string) => setSelectedImageUrl(x)}
+            setSelectedTag={(x: string) => setSelectedTag(x)}
+            forceExpanded={true}
+            disableImageSelect={isDeployedFromGithub(currentChart)}
+          />
+          {!loadingWebhookToken && (
+            <>
+              <Br />
+              <Br />
+              <Br />
+              <SaveButton
+                clearPosition={true}
+                statusPosition="right"
+                text="Save Source Settings"
+                status={saveValuesStatus}
+                onClick={handleSubmit}
+              />
+            </>
+          )}
+          <Br />
+        </>
 
         <>
           <Heading>Redeploy Webhook</Heading>
@@ -287,15 +285,8 @@ const SettingsSection: React.FC<PropsType> = ({
     );
   };
 
-  const chartWasDeployedWithGithub = () => {
-    if (currentChart.git_action_config) {
-      return true;
-    }
-    return false;
-  };
-
   const canBeCloned = () => {
-    if (chartWasDeployedWithGithub()) {
+    if (isDeployedFromGithub(currentChart)) {
       return false;
     }
 

+ 9 - 0
dashboard/src/main/home/cluster-dashboard/expanded-chart/incidents/DisabledNamespaces.ts

@@ -0,0 +1,9 @@
+export const DisabledNamespacesForIncidents = [
+  "cert-manager",
+  "ingress-nginx",
+  "kube-node-lease",
+  "kube-public",
+  "kube-system",
+  "monitoring",
+  "porter-agent-system",
+];

+ 9 - 1
dashboard/src/main/home/modals/LoadEnvGroupModal.tsx

@@ -20,7 +20,7 @@ import {
 } from "components/porter-form/types";
 import Helper from "components/form-components/Helper";
 import DocsHelper from "components/DocsHelper";
-import { isObject } from "lodash";
+import { isEmpty, isObject } from "lodash";
 
 type PropsType = {
   namespace: string;
@@ -161,6 +161,14 @@ export default class LoadEnvGroupModal extends Component<PropsType, StateType> {
     if (!incoming) {
       return [];
     }
+
+    if (
+      !isObject(this.props.existingValues) ||
+      isEmpty(this.props.existingValues)
+    ) {
+      return [];
+    }
+
     // console.log(incoming, this.props.existingValues);
     return Object.entries(incoming)
       .filter(([key]) => this.props.existingValues[key])

+ 4 - 0
internal/registry/registry.go

@@ -690,6 +690,10 @@ func (r *Registry) listECRImages(repoName string, repo repository.Repository) ([
 		return nil, err
 	}
 
+	if len(resp.ImageIds) == 0 {
+		return []*ptypes.Image{}, nil
+	}
+
 	describeResp, err := svc.DescribeImages(&ecr.DescribeImagesInput{
 		RepositoryName: &repoName,
 		ImageIds:       resp.ImageIds,