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

Remove GitHub projects #439

Merged
merged 4 commits into from
May 13, 2021
Merged

Conversation

amisevsk
Copy link
Contributor

@amisevsk amisevsk commented Apr 26, 2021

What does this PR do?

Remove projects with type GitHub, since this duplicates Git-type projects.

I'm not sure this PR should be merged now, as GitHub projects were deprecated on Feb 19 but I think it makes sense to include this in the 2.1 milestone as the change will be required by the time v1alpha2 is set (since it's a k8s-incompatible change -- doing it later would require going to v1alpha3). As far as I know, no devfiles/DevWorkspaces use GitHub projects so no use cases should be broken.

What issues does this PR fix or reference?

Fixes #340

Is your PR tested? Consider putting some instruction how to test your changes

Fixed conversion tests to ignore GitHub projects.

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems tests needs to be adapted

schema_test.go:222: OVERALL FAIL : 34 of 291 tests failed.

but everything else LGTM

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

The full list of commands accepted by this bot can be found 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

@yangcao77
Copy link
Contributor

yangcao77 commented Apr 27, 2021

@amisevsk I have created a PR in your branch to fix the test failures, can you help review and merge if no issues with it: amisevsk#1

@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@amisevsk
Copy link
Contributor Author

amisevsk commented Apr 27, 2021

@yangcao77 ahh sorry, I missed this comment until right after I pushed 18525d4 and 6726b05!

I think I basically did the same thing as you :)

@amisevsk amisevsk requested a review from yangcao77 April 27, 2021 19:54
@@ -19,8 +19,6 @@ func convertProjectTo_v1alpha2(src *Project, dest *v1alpha2.Project) error {
switch {
case src.Git != nil:
sparseCheckoutDir = src.Git.SparseCheckoutDir
case src.Github != nil:
sparseCheckoutDir = src.Github.SparseCheckoutDir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since Github is duplicate of Git. Should we convert v1.Github to v2.Git, instead of ignoring it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this might be a good idea. My first impulse is to not do it since it would change the file on round trip (i.e. v1alpha1 (GitHub) -> v1alpha2 (Git) -> v1alpha1 (Git)), but my approach of ignoring the problem just changes the file in a different way.

On the other hand, if there's not a whole lot of value in it, it's a lot simpler to not bother. The way conversion is implemented (round trip through json) would mean we'd have to do something fancy to make it work.

Copy link
Contributor

@yangcao77 yangcao77 Apr 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emm. When you say "round trip conversion", did you mean how the conversion test is implemented?
I agree more extra work needs to be done if we want to test github->git conversion. however, the ConvertTo (

func (src *DevWorkspace) ConvertTo(destRaw conversion.Hub) error {
dest := destRaw.(*v1alpha2.DevWorkspace)
return convertDevWorkspaceTo_v1alpha2(src, dest)
}
) function is exposed, and can be called by consumer. so we probably should not simply ignore it.
what if we still convert v1alpha1 (GitHub) -> v1alpha2 (Git) in the actual conversion function, and just ignore Github case in the conversion test?

Copy link
Contributor Author

@amisevsk amisevsk Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way conversion is supposed to be implemented (from a k8s perspective) is that converting from version X to the hub version Y (v1alpha2 in our case) and back again should result in unmodified data. This is because internally, when you apply a v1alpha1 DevWorkspace to your cluster, kube will convert it to v1alpha2 and store that in etcd. This v1alpha2 spec is converted back to v1alpha1 when you request it from the cluster -- this is what the conversion tests are testing.

The way this is often done for removed/added fields is to serialize removed fields into a json annotation so that when you unconvert you get the same data, but IMO this is a very messy approach for a feature nobody is using (i.e. a bunch of work for no gain). We've done a similar thing for e.g. the vscode command types.

The additional work that would be required to implement GitHub -> Git conversion is due to the approach we take to conversion, where we take version X, serialize it to json, and then deserialize it to version Y (e.g. here). This was done since the main breaking change between v1alpha1 and v1alpha2 is moving component name, command id, etc. one level higher in the spec (i.e. .spec.components[].name vs .spec.components[].container.name, which makes the types not assignable and makes conversion-gen code nearly useless. By going through json, we can easily assign all fields shared between v1alpha1 and v1alpha2, but this doesn't work if the path is different (a GitHub project -- e.g. .projects[].github.remotes -- will deserialize to nil if you pass in a Git project).

I can definitely look into it, but I'm hesitant to introduce complexity in the conversion code to cover a case that (I think) will never actually be called in production.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if adding an attribute when convert Github -> Git would help in this situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally got around to this: 45b3cff

Please take a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The basic gist of the approach is

        v1alpha1             |     intermediate (v1alpha1)    |            v1alpha2              
-----------------------------|--------------------------------|--------------------------------
projects:                    |   projects:                    |   projects:                     
  - name: project            |     - name: project            |     - name: project   
    github:                  |       github:                  |                                 
      remotes:               |         remotes:               |                                 
        origin: my-url.com   |           origin: my-url.com   |                                 
                             |       git:                     |       git:                      
                             |         remotes:               |         remotes:                
                             |           origin: my-url.com   |           origin: my-url.com    

@amisevsk amisevsk force-pushed the remove-github-projects branch from 6726b05 to 9d476bc Compare May 11, 2021 02:12
@amisevsk amisevsk requested a review from yangcao77 May 11, 2021 18:48
Copy link
Contributor

@yangcao77 yangcao77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes looks good to me

@openshift-ci openshift-ci bot added the lgtm label May 12, 2021
@openshift-ci
Copy link

openshift-ci bot commented May 12, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: amisevsk, sleshchenko, yangcao77

The full list of commands accepted by this bot can be found 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 added 2 commits May 12, 2021 21:50
When converting a devfile in v1alpha1 that contains projects with type
Github, convert those projects to Git-type projects in v1alpha2 and
apply attribute 'conversion.api.devfile.io/converted-from=GitHub' to
them.

When converting from v1alpha2, convert Git-type projects with the above
attribute back to Github-type projects in v1alpha1.

Reenable testing conversion for Github-type projects in v1alpha1 now
that it is supported.

Signed-off-by: Angel Misevski <[email protected]>
@amisevsk amisevsk force-pushed the remove-github-projects branch from 6126fb6 to d2c5a8f Compare May 13, 2021 01:51
@openshift-ci
Copy link

openshift-ci bot commented May 13, 2021

New changes are detected. LGTM label has been removed.

@openshift-ci openshift-ci bot removed the lgtm label May 13, 2021
@amisevsk amisevsk merged commit 3ac0baa into devfile:main May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove devfile.projects[].github
4 participants