Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make project-clone work in a temporary directory; copy files at end #700

Merged
merged 1 commit into from
Dec 16, 2021

Conversation

amisevsk
Copy link
Collaborator

@amisevsk amisevsk commented Dec 6, 2021

What does this PR do?

In order to avoid issues where the project-clone container is killed during its initial run, leaving repos in a half-configured state, do all operations in a temporary directory and copy repos to their expected locations at the very end.

What issues does this PR fix or reference?

Closes #699

Is it tested? How?

Can be tested using the image quay.io/amisevsk/project-clone:atomic-clone (e.g. in the relevant RELATED_IMAGE env var or by setting PROJECT_CLONE_IMG when installing DWO). To test both git and zip type projects, use the devfile

cat <<EOF | kubectl apply -f - 
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: theia-next
spec:
  started: true
  template:
    projects:
      - name: web-nodejs-sample
        git:
          remotes:
            origin: "https://github.com/che-samples/web-nodejs-sample.git"
      - name: devworkspace-operator-zip
        zip:
          location: https://github.com/devfile/devworkspace-operator/archive/refs/heads/main.zip
    components:
      - name: theia
        plugin:
          uri: https://che-plugin-registry-main.surge.sh/v3/plugins/eclipse/che-theia/next/devfile.yaml
          components:
            - name: theia-ide
              container:
                env:
                  - name: THEIA_HOST
                    value: 0.0.0.0
EOF

and check that

  1. Projects are setup successfully
  2. Project-clone does nothing when the workspace is restarted
  3. No temp directories or files are present in $PROJECTS_ROOT
  4. (If you can figure out how) kill project clone while it's preparing projects and make sure the subsequent run behaves as above

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
    • v8-devworkspace-operator-e2e: DevWorkspace e2e test
    • v8-che-happy-path: Happy path for verification integration with Che

@openshift-ci
Copy link

openshift-ci bot commented Dec 8, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amisevsk, JPinkney

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@amisevsk
Copy link
Collaborator Author

amisevsk commented Dec 8, 2021

/test v8-devworkspace-operator-e2e

@amisevsk
Copy link
Collaborator Author

amisevsk commented Dec 8, 2021

Validation is failing as os.MkDirTemp was only added in Go 1.16 :(

@amisevsk
Copy link
Collaborator Author

amisevsk commented Dec 8, 2021

Blocked by #705

@openshift-ci
Copy link

openshift-ci bot commented Dec 16, 2021

New changes are detected. LGTM label has been removed.

@openshift-ci openshift-ci bot removed the lgtm label Dec 16, 2021
To avoid issues where the project-clone container is killed while
cloning (and thus leaving repos in an inconsistent state), do all
actions to a temporary directory and move files into their expected
location only as a last step. This should allow projects to be cloned
correctly if the project-clone container is killed early in execution.

Signed-off-by: Angel Misevski <[email protected]>
@amisevsk
Copy link
Collaborator Author

/test v8-devworkspace-operator-e2e

@amisevsk amisevsk merged commit 340dc75 into devfile:main Dec 16, 2021
@amisevsk amisevsk deleted the atomic-project-clone branch December 16, 2021 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If project-clone container is killed while cloning, repos are left in inconsistent state
3 participants