odo icon indicating copy to clipboard operation
odo copied to clipboard

`odo dev` deletes remote resources not present in the Devfile

Open valaparthvi opened this issue 2 years ago • 14 comments

What type of PR is this: /kind bug /area dev

What does this PR do / why we need it: With this PR, odo dev now handles K8s component related changes to the Devfile. It will remove resources from the cluster that are not present in the local Devfile.

Which issue(s) this PR fixes:

Fixes #5943 Fixes #6101

PR acceptance criteria:

  • [ ] Unit test

  • [x] Integration test

  • [ ] Documentation

How to test changes / Special notes to the reviewer: 1.

odo init --devfile nodejs --name my-node-app --starter nodejs-starter
  1. Replace the devfile.yaml with content below.
devfile.yaml
commands:
- exec:
    commandLine: npm install
    component: runtime
    group:
      isDefault: true
      kind: build
    hotReloadCapable: false
    workingDir: ${PROJECT_SOURCE}
  id: install
- exec:
    commandLine: npm start
    component: runtime
    group:
      isDefault: true
      kind: run
    hotReloadCapable: false
    workingDir: ${PROJECT_SOURCE}
  id: run
- exec:
    commandLine: npm run debug
    component: runtime
    group:
      isDefault: true
      kind: debug
    hotReloadCapable: false
    workingDir: ${PROJECT_SOURCE}
  id: debug
- exec:
    commandLine: npm test
    component: runtime
    group:
      isDefault: true
      kind: test
    hotReloadCapable: false
    workingDir: ${PROJECT_SOURCE}
  id: test
components:
- container:
    args:
    - tail
    - -f
    - /dev/null
    dedicatedPod: false
    endpoints:
    - name: http-node
      secure: false
      targetPort: 3000
    image: registry.access.redhat.com/ubi8/nodejs-16:latest
    memoryLimit: 1024Mi
    mountSources: true
  name: runtime
- name: my-node-app-app-cluster-sample
  kubernetes:
    inlined: |
      apiVersion: servicebinding.io/v1beta1
      kind: ServiceBinding
      metadata:
        name: my-node-app-app-cluster-sample
      spec:
        workload:
          apiVersion: apps/v1
          kind: Deployment
          name: my-node-app-app
        service:
          apiVersion: postgresql.k8s.enterprisedb.io/v1
          kind: Cluster
          name: cluster-sample
- name: deploy-k8s-resource
  kubernetes:
    inlined: |
        kind: Deployment
        apiVersion: apps/v1
        metadata:
          name: my-component
        spec:
          replicas: 1
          selector:
            matchLabels:
              app: node-app
          template:
            metadata:
              labels:
                app: node-app
            spec:
              containers:
                - name: main
                  image: registry.access.redhat.com/ubi8/nodejs-12:1-36
                  resources:
                    limits:
                      memory: "128Mi"
                      cpu: "500m"
metadata:
  description: Stack with Node.js 16
  displayName: Node.js Runtime
  icon: https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg
  language: javascript
  name: my-node-app
  projectType: nodejs
  tags:
  - NodeJS
  - Express
  - ubi8
  version: 2.0.0
schemaVersion: 2.1.0
starterProjects:
- git:
    remotes:
      origin: https://github.com/odo-devfiles/nodejs-ex.git
  name: nodejs-starter
  1. After you run the command below, ensure that odo dev detects the change, and removes ServiceBinding.v1beta1.servicebinding.io from the cluster.
odo remove binding --name my-node-app-cluster-sample
  1. Remove the deployment K8s component from devfile.yaml, and ensure that odo dev detects it and removes it from the cluster.

valaparthvi avatar Oct 04 '22 07:10 valaparthvi

Deploy Preview for odo-docusaurus-preview ready!

Name Link
Latest commit 0afa07367a97e7e6a6eff3656c3ff563097cbc07
Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/637751ba84716300095d1d83
Deploy Preview https://deploy-preview-6189--odo-docusaurus-preview.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 04 '22 07:10 netlify[bot]

Unit Tests on commit 2b7f9d878fcbfa72a98ea2eda1568fd48a9dd0d9 finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Oct 04 '22 07:10 odo-robot[bot]

Validate Tests on commit 2b7f9d878fcbfa72a98ea2eda1568fd48a9dd0d9 finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Oct 04 '22 07:10 odo-robot[bot]

Windows Tests (OCP) on commit 2b7f9d878fcbfa72a98ea2eda1568fd48a9dd0d9 finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Oct 04 '22 07:10 odo-robot[bot]

Kubernetes Tests on commit 2b7f9d878fcbfa72a98ea2eda1568fd48a9dd0d9 finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Oct 04 '22 08:10 odo-robot[bot]

OpenShift Tests on commit 2b7f9d878fcbfa72a98ea2eda1568fd48a9dd0d9 finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Oct 04 '22 08:10 odo-robot[bot]

OCP failure seems flaky:
Summarizing 1 Failure:
  [FAIL] odo dev command tests port-forwarding for the component when devfile has single endpoint when running odo dev when modifying memoryLimit for container in Devfile [BeforeEach] should expose the endpoint on localhost
  Timed out after 180.000s.
  Expected
      <string>:  âš   Pod is Terminating
       ✗  Finished executing the application (command: devrun) [38s]
       âš   No pod exists
       âš   Pod is Pending
       ✓  Pod is Running
       •  Syncing files into the container  ...
      
 ✓  Syncing files into the container [586ms]
      cat: /opt/odo/.odo_cmd_devrun.pid: No such file or directory
       •  Building your application in container on cluster (command: devbuild)  ...
      
 ✓  Building your application in container on cluster (command: devbuild) [4s]
       •  Executing the application (command: devrun)  ...
      44
      0
      44
      0
       -  Forwarding from 127.0.0.1:40247 -> 3000
      
      
      ↪ Dev mode
       Keyboard Commands:
      [Ctrl+c] - Exit and delete resources from the cluster
           [p] - Manually apply local changes to the application on the cluster
      
  To satisfy at least one of these matchers: [%!s(*matchers.ContainSubstringMatcher=&{Pushing files... []}) %!s(*matchers.ContainSubstringMatcher=&{Updating Component... []})]
  In [BeforeEach] at: /go/odo_1/tests/helper/helper_run.go:53

valaparthvi avatar Oct 11 '22 13:10 valaparthvi

/retest

valaparthvi avatar Oct 12 '22 11:10 valaparthvi

/retest

valaparthvi avatar Oct 13 '22 06:10 valaparthvi

/retest Flaky test.

valaparthvi avatar Oct 13 '22 11:10 valaparthvi

/approve

feloy avatar Oct 17 '22 07:10 feloy

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feloy

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

openshift-ci[bot] avatar Oct 17 '22 07:10 openshift-ci[bot]

@rm3l I've attempted to implement parallel resource deletion, but I cannot say for sure if it is working as expected. I'll leave it to you to test the functionality.

Also, locally I am seeing the following error in my IDE

Cannot use '(*Adapter)(nil)' (type *Adapter) as the type ComponentAdapter Type does not implement 'ComponentAdapter' as some methods are missing: Push(parameters adapters.PushParameters, componentStatus *watch.ComponentStatus) error

Can you confirm if you too are seeing it ? I am using Go 1.18 locally.

valaparthvi avatar Oct 20 '22 10:10 valaparthvi

For parallel deletion, you can use WaitGroups: https://gobyexample.com/waitgroups

feloy avatar Oct 20 '22 11:10 feloy

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.4% 0.4% Duplication

sonarqubecloud[bot] avatar Oct 21 '22 07:10 sonarqubecloud[bot]

@valaparthvi: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v4.11-integration-e2e 0364cc8800d3e5d9c677bfed65a7eff0aad19b83 link true /test v4.11-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.

openshift-ci[bot] avatar Oct 21 '22 09:10 openshift-ci[bot]

@rm3l I've attempted to implement parallel resource deletion, but I cannot say for sure if it is working as expected. I'll leave it to you to test the functionality.

Also, locally I am seeing the following error in my IDE

Cannot use '(*Adapter)(nil)' (type *Adapter) as the type ComponentAdapter Type does not implement 'ComponentAdapter' as some methods are missing: Push(parameters adapters.PushParameters, componentStatus *watch.ComponentStatus) error

Can you confirm if you too are seeing it ? I am using Go 1.18 locally.

I didn't see this error. Are you still seeing it?

rm3l avatar Oct 21 '22 11:10 rm3l

@rm3l I've attempted to implement parallel resource deletion, but I cannot say for sure if it is working as expected. I'll leave it to you to test the functionality. Also, locally I am seeing the following error in my IDE

Cannot use '(*Adapter)(nil)' (type *Adapter) as the type ComponentAdapter Type does not implement 'ComponentAdapter' as some methods are missing: Push(parameters adapters.PushParameters, componentStatus *watch.ComponentStatus) error

Can you confirm if you too are seeing it ? I am using Go 1.18 locally.

I didn't see this error. Are you still seeing it?

Not on Go1.17

valaparthvi avatar Oct 21 '22 14:10 valaparthvi

NoCluster Tests on commit 2b7f9d878fcbfa72a98ea2eda1568fd48a9dd0d9 finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Nov 18 '22 09:11 odo-robot[bot]

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.4% 0.4% Duplication

sonarqubecloud[bot] avatar Nov 18 '22 17:11 sonarqubecloud[bot]

/test v4.11-integration-e2e

feloy avatar Nov 18 '22 18:11 feloy

/override ci/prow/v4.11-integration-e2e

feloy avatar Nov 18 '22 20:11 feloy

@feloy: Overrode contexts on behalf of feloy: ci/prow/v4.11-integration-e2e

In response to this:

/override ci/prow/v4.11-integration-e2e

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.

openshift-ci[bot] avatar Nov 18 '22 20:11 openshift-ci[bot]