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

Display a warning that "odo dev" on Podman needs to be restarted if the Devfile is changed #6477

Conversation

rm3l
Copy link
Member

@rm3l rm3l commented Jan 9, 2023

What type of PR is this:
/area odo-on-podman

What does this PR do / why we need it:

Which issue(s) this PR fixes:
Fixes #6336

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

… when local changes are detected

The initial idea was to display such a warning only
when changes are detected in the Devfile,
which are not yet handled completely at this time.
But to take into account the manual synchronization case (where
there is no file watcher (and therefore no way to determine which
files have actually been modified)), a generic warning is being
displayed whenever the Podman-specific watch handler is called.
@netlify
Copy link

netlify bot commented Jan 9, 2023

Deploy Preview for odo-docusaurus-preview ready!

Name Link
🔨 Latest commit 82ace2f
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/63bd7d251908c30008e6ee8f
😎 Deploy Preview https://deploy-preview-6477--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.

@openshift-ci openshift-ci bot added the area/odo-on-podman Issues or PRs related to running odo against Podman label Jan 9, 2023
@rm3l rm3l added the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Jan 9, 2023
@odo-robot
Copy link

odo-robot bot commented Jan 9, 2023

OpenShift Tests on commit e2ef2d8 finished with errors.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jan 9, 2023

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

@odo-robot
Copy link

odo-robot bot commented Jan 9, 2023

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

@odo-robot
Copy link

odo-robot bot commented Jan 9, 2023

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

@odo-robot
Copy link

odo-robot bot commented Jan 9, 2023

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

@odo-robot
Copy link

odo-robot bot commented Jan 9, 2023

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

@@ -167,5 +168,8 @@ func (o *DevClient) watchHandler(ctx context.Context, pushParams adapters.PushPa
WatchFiles: watchParams.WatchFiles,
Variables: watchParams.Variables,
}

fmt.Fprintln(watchParams.Out)
log.Fwarning(watchParams.Out, "Changes to the Devfile not supported yet on Podman. Please restart 'odo dev' for such changes to be applied.\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be displayed every time, even if the user only modifies sources files.

I would instead add an else part to the if equality.Semantic.DeepEqual(o.deployedPod, pod) condition (in the reconcile.go file), and print the warning there

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, thanks for the pointer. Initially, I had changed the part that looks for changes in the Devfile watcher (in watch.go), but then I had an issue when manually sync'ing with --no-watch.
This looks like a better approach. I'll make the change - thanks.

Copy link
Member Author

@rm3l rm3l Jan 9, 2023

Choose a reason for hiding this comment

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

One thing I just noticed: if we display the warning as part of if !equality.Semantic.DeepEqual(o.deployedPod, pod), the problem is that this would work only if the changes in the Devfile affect the resulting Pod spec.

I noticed that if I only change for example the run command in the Devfile, the resulting Pod spec is still semantically the same as the previous one, so no warning is displayed. But, the changes were not taken into account (I think because we are still using the same Devfile Object from the context).

Copy link
Member Author

Choose a reason for hiding this comment

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

I am thinking of just re-parsing the Devfile when the watch handler is called and comparing it to the currently loaded one. And display the warning if there are any differences.
@feloy What do you think?

The Kubedev implementation actually re-parses the Devfile when the watch handler is called:

func (o *DevClient) regenerateComponentAdapterFromWatchParams(parameters watch.WatchParameters) (component.ComponentAdapter, error) {
devObj, err := devfile.ParseAndValidateFromFileWithVariables(location.DevfileLocation(""), parameters.Variables)
if err != nil {
return nil, err
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's a good solution IMO

…started when local changes are detected

Display a warning that "odo dev" on Podman might need to be restarted when the Devfile is modified
@odo-robot
Copy link

odo-robot bot commented Jan 9, 2023

OpenShift Tests on commit 3023bb8 finished successfully.
View logs: TXT HTML

@rm3l rm3l changed the title Display a warning that "odo dev" on Podman might need to be restarted if the Devfile is changed Display a warning that "odo dev" on Podman needs to be restarted if the Devfile is changed Jan 9, 2023
@rm3l rm3l closed this Jan 9, 2023
@rm3l rm3l reopened this Jan 9, 2023
Copy link
Contributor

@feloy feloy left a comment

Choose a reason for hiding this comment

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

Also, could you add a test to check that no warning is displayed when the Devfile is not changed?
As the code to read the original and new Devfiles is not in the same place, I'm afraid it could drift over time

tests/integration/cmd_dev_test.go Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Jan 10, 2023

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 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rm3l rm3l requested a review from feloy January 10, 2023 16:36
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jan 10, 2023
@feloy
Copy link
Contributor

feloy commented Jan 10, 2023

/override OpenShift-Integration-tests/OpenShift-Integration-tests
Flaky e2e test

@openshift-ci
Copy link

openshift-ci bot commented Jan 10, 2023

@feloy: Overrode contexts on behalf of feloy: OpenShift-Integration-tests/OpenShift-Integration-tests

In response to this:

/override OpenShift-Integration-tests/OpenShift-Integration-tests
Flaky e2e test

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-merge-robot openshift-merge-robot merged commit da9a9ef into redhat-developer:main Jan 10, 2023
@rm3l rm3l deleted the 6336-warn-users-that-odo-dev-needs-to-be-restarted-when-related-information-is-changed-in-devfile branch January 10, 2023 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/odo-on-podman Issues or PRs related to running odo against Podman 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.

Warn users that odo dev needs to be restarted when related information is changed in Devfile
3 participants