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

Convert s2i components to devfile #3549

Merged
merged 19 commits into from
Jul 30, 2020

Conversation

adisky
Copy link
Contributor

@adisky adisky commented Jul 13, 2020

What type of PR is this?
/kind feature

What does does this PR do / why we need it:
Convert s2i local components to devfile.yaml

Which issue(s) this PR fixes:

fixes #3156

How to test changes / Special notes to the reviewer:

Now Convert this s2i component to devfile

  • $ odo preference set experimental true
  • $ odo utils convert-to-devfile (creates devfile.yaml, env.yaml)
  • $ odo push (deploys devfile component)
  • $ odo delete --s2i (deletes s2i component)

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Jul 13, 2020
@adisky adisky force-pushed the s2idevfile branch 2 times, most recently from 78d84d3 to 4ea1743 Compare July 13, 2020 11:53

// AddComponent adds component to devfile
func (d *Devfile200) AddComponent(component common.DevfileComponent) {
d.Components = append(d.Components, component)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we check for duplicates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, updating

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jul 14, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jul 14, 2020
@dharmit
Copy link
Member

dharmit commented Jul 15, 2020

Few observations/questions:

  • odo utils migrate-to-devfile command works without Experimental mode as well. But, and obviously, it doesn't push using the Devfile.
  • While not incorrect, the YAML generated by the command has metadata and schema info at the bottom unlike the top where we're used to seeing it. Should we make sure that it shows up at the top?
    commands:
    - exec:
        commandLine: /opt/odo/bin/s2i-setup && /opt/odo/bin/assemble-and-restart
        component: s2i-builder
        group:
          isDefault: true
          kind: build
        id: s2i-assemble
    - exec:
        commandLine: /opt/odo/bin/run
        component: s2i-builder
        group:
          isDefault: true
          kind: run
        id: s2i-run
    components:
    - container:
        endpoints:
        - configuration:
            public: true
          name: port-8080
          targetPort: 8080
        env:
        - name: ODO_S2I_SCRIPTS_URL
          value: /usr/libexec/s2i
        - name: ODO_S2I_SCRIPTS_PROTOCOL
          value: image://
        - name: ODO_S2I_SRC_BIN_PATH
          value: /tmp
        - name: ODO_S2I_DEPLOYMENT_DIR
          value: /opt/app-root/src
        - name: ODO_S2I_WORKING_DIR
          value: /opt/app-root/src
        - name: ODO_S2I_BUILDER_IMG
          value: rhscl/nodejs-12-rhel7
        - name: ODO_SRC_BACKUP_DIR
          value: /opt/app-root/src-backup
        - name: ODO_S2I_CONVERTED_DEVFILE
          value: "true"
        image: registry.redhat.io/rhscl/nodejs-10-rhel7:latest
        mountSources: true
        name: s2i-builder
        sourceMapping: /tmp/projects
    metadata:
      name: nodejs-nodejs-ex-qaxb
      version: 1.0.0
    schemaVersion: 2.0.0
  • Doing odo push doesn't delete the old pod, route and service from the cluster. (there could be more dangling objects but these are the ones I observed.) Should we delete them as a part of this PR or a different PR?

@adisky
Copy link
Contributor Author

adisky commented Jul 15, 2020

Few observations/questions:

  • odo utils migrate-to-devfile command works without Experimental mode as well. But, and obviously, it doesn't push using the Devfile.

I think it is not a problem, anyways we are taking out devfile from experimental mode

  • While not incorrect, the YAML generated by the command has metadata and schema info at the bottom unlike the top where we're used to seeing it. Should we make sure that it shows up at the top?
    commands:
    - exec:
        commandLine: /opt/odo/bin/s2i-setup && /opt/odo/bin/assemble-and-restart
        component: s2i-builder
        group:
          isDefault: true
          kind: build
        id: s2i-assemble
    - exec:
        commandLine: /opt/odo/bin/run
        component: s2i-builder
        group:
          isDefault: true
          kind: run
        id: s2i-run
    components:
    - container:
        endpoints:
        - configuration:
            public: true
          name: port-8080
          targetPort: 8080
        env:
        - name: ODO_S2I_SCRIPTS_URL
          value: /usr/libexec/s2i
        - name: ODO_S2I_SCRIPTS_PROTOCOL
          value: image://
        - name: ODO_S2I_SRC_BIN_PATH
          value: /tmp
        - name: ODO_S2I_DEPLOYMENT_DIR
          value: /opt/app-root/src
        - name: ODO_S2I_WORKING_DIR
          value: /opt/app-root/src
        - name: ODO_S2I_BUILDER_IMG
          value: rhscl/nodejs-12-rhel7
        - name: ODO_SRC_BACKUP_DIR
          value: /opt/app-root/src-backup
        - name: ODO_S2I_CONVERTED_DEVFILE
          value: "true"
        image: registry.redhat.io/rhscl/nodejs-10-rhel7:latest
        mountSources: true
        name: s2i-builder
        sourceMapping: /tmp/projects
    metadata:
      name: nodejs-nodejs-ex-qaxb
      version: 1.0.0
    schemaVersion: 2.0.0

I don't know how to preserve order for a generated yaml, would check about this.

  • Doing odo push doesn't delete the old pod, route and service from the cluster. (there could be more dangling objects but these are the ones I observed.) Should we delete them as a part of this PR or a different PR?

isn't it expected? I believe that if the new devfile component deployed successfully user then deletes the old one?
and odo push is not automatically doing this as with devfiles we use deployment and with s2i we use deployment config. So there is no update here it is creating a new component.

even if we want to delete it, it should ne be done with odo push. If we want that, odo utils migrate-to-devfile push the new one and deletes the old one.

@adisky
Copy link
Contributor Author

adisky commented Jul 15, 2020

@dharmit addressed your comments for ordering the yaml, now it is generating in order.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jul 18, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jul 20, 2020
return errors.Wrap(err, "Error in generating env.yaml")
}

// TODO: Delete the s2i component and deploy the devfile component.
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO found

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is just a note about the data we are unable to migrate.

Copy link
Contributor

@mik-dass mik-dass Jul 21, 2020

Choose a reason for hiding this comment

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

Please update with some reasoning and also the link to the issue if available.

Comment on lines 92 to 100
/* This data is yet to be converted

// Absolute path
sourcePath, _ := context.LocalConfigInfo.GetOSSourcePath()
minMemory := context.LocalConfigInfo.GetMinMemory()
minCPU := context.LocalConfigInfo.GetMinCPU()
maxCPU := context.LocalConfigInfo.GetMaxCPU()

*/
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like a TODO

Comment on lines 26 to 27
// TODO
// lables and annotations that are added on s2i components
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO found

if err != nil {
return err
}
log.Italic("devfile.yaml is available in current directory, run `odo push` to deploy devfile component and `odo delete` to delete s2i component.\n")
Copy link
Contributor

@mik-dass mik-dass Jul 21, 2020

Choose a reason for hiding this comment

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

won't running odo delete after push delete the devfile component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you have an s2i component in folder

  • cd my-s2i-component
  • run odo utils migrate-to-devfile (generates devfile.yaml, env.yaml)
  • odo push (since devfile has priority over s2i, devfile component would get deployed. s2i would is still exisiting)
  • odo delete(s2i has priority over for delete, so s2i would get deleted)
  • you have now running devfile component.

Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds confusing TBH. How about we suggest delete before push? Will that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, but what would happen when odo push for devfile gets failed and user lost the old s2i component as well?
in ideal migration strategy the when the new deployment gets successful then only the old one rolled back.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK 👍 Please add a comment regarding this.

// NewCmdMigrate implements the odo utils migrate-to-devfile command
func NewCmdMigrate(name, fullName string) *cobra.Command {
o := NewMigrateOptions()
migrateCmd := &cobra.Command{
Copy link
Contributor

Choose a reason for hiding this comment

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

please add some integration tests for this command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would update

@adisky
Copy link
Contributor Author

adisky commented Jul 21, 2020

@mik-dass what is the problem with TODO's in code? these are for future references like app label is still under development.

@mik-dass
Copy link
Contributor

mik-dass commented Jul 21, 2020

@mik-dass what is the problem with TODO's in code? these are for future references like app label is still under development.

Some of them are confusing as to why they are not a part of this PR. We should provide proper reasoning as to why they are not implemented in this PR. Links to known issues are even better. Without them, the PR review becomes confusing.

@adisky
Copy link
Contributor Author

adisky commented Jul 21, 2020

Some of them are confusing as to why they are not a part of this PR. We should provide proper reasoning as to why they are not implemented in this PR. Links to known issues are even better. According to me, it makes the PR review confusing.

yes correct, so you should give comment like please elaborate TODO, only TODO found would not make the author understand what reviewer wants to say.

@mik-dass
Copy link
Contributor

mik-dass commented Jul 21, 2020

yes correct, so you should give comment like please elaborate TODO, only TODO found would not make the author understand what reviewer wants to say.

That's how I have always started a conversation regarding the TODO as the details has not been provided and I end up assuming it to be personal notes for the future. He/she can always reply back in the review comment. Anyways, will keep this in mind next time.

@adisky
Copy link
Contributor Author

adisky commented Jul 21, 2020

as discussed with @kadel and feedback from @mik-dass, delete operation looks confusing here, we have decided to introduce a flag --s2i for odo delete. Marking it as WIP till i update the PR.

@adisky adisky changed the title Convert s2i components to devfile [WIP] Convert s2i components to devfile Jul 21, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jul 21, 2020
@adisky
Copy link
Contributor Author

adisky commented Jul 28, 2020

/retest

@kadel
Copy link
Member

kadel commented Jul 29, 2020

/retest

endpoint := common.Endpoint{
Name: fmt.Sprintf("port-%s", port[0]),
TargetPort: int32(portInt),
Configuration: &common.Configuration{
Copy link
Contributor

Choose a reason for hiding this comment

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

I think configuration was removed from the schema recently https://github.com/devfile/kubernetes-api/blob/master/schemas/devfile.json#L439

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Jul 29, 2020

@adisky: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/v4.2-integration-e2e f4eb04f link /test v4.2-integration-e2e
ci/prow/v4.3-integration-e2e f4eb04f link /test v4.3-integration-e2e

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@adisky
Copy link
Contributor Author

adisky commented Jul 30, 2020

/retest

Copy link
Contributor

@mik-dass mik-dass left a comment

Choose a reason for hiding this comment

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

Works for me
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jul 30, 2020
@openshift-merge-robot openshift-merge-robot merged commit 8b87f67 into redhat-developer:master Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert s2i components into devfile
7 participants