-
Notifications
You must be signed in to change notification settings - Fork 244
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
Deploy, Events without devfile/adapters #5460
Deploy, Events without devfile/adapters #5460
Conversation
✔️ Deploy Preview for odo-docusaurus-preview ready! 🔨 Explore the source changes: 9f5923c 🔍 Inspect the deploy log: https://app.netlify.com/sites/odo-docusaurus-preview/deploys/6215e4aea703960007ca20d0 😎 Browse the preview: https://deploy-preview-5460--odo-docusaurus-preview.netlify.app |
d5e9f17
to
51dacab
Compare
231ceb6
to
f867c10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed only pkg/libdevfile/
yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only reviewed pkg/component/component.go
.
@@ -503,3 +509,87 @@ func setLinksServiceNames(client kclient.ClientInterface, linkedSecrets []Secret | |||
} | |||
return nil | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Among all the packages we have created the client interface for at business layer, component
package has not been modified so far. Does it make sense to do it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component one is the more complex to refactor. I'll need to sleep before ;) Joke aside, no, it will deserve PR all to itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to need some sleep myself to form a mental picture of odo's code architecture. You're changing it fast (not complaining, complimenting), and it's tough to keep up at times. 😅
@feloy maybe it's just me, but an example devfile that could be used to test the changes here by stepping through the code would be helpful because the PR is overall about refactoring and introducing a different (new?) code architecture. Do you know of a devfile I can use right away? Preferably a complete devfile, and not something in bits and pieces. |
I've used this one to test the events: https://github.com/redhat-developer/odo/blob/main/tests/examples/source/devfiles/nodejs/devfile-with-valid-events.yaml |
pkg/libdevfile/command.go
Outdated
type command interface { | ||
CheckValidity() error | ||
Execute(handler Handler) error | ||
UnExecute() error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is no longer needed it seems. I remember adding it to implement undeploy, but since Execute
of undeployHandler handles the undeployment part, we can remove this method, IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, good catch
pkg/libdevfile/command.go
Outdated
cmd = newExecCommand(devfileObj, devfileCmd) | ||
} | ||
|
||
if err := cmd.CheckValidity(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err := cmd.CheckValidity(); err != nil { | |
if err = cmd.CheckValidity(); err != nil { |
pkg/component/exec_handler.go
Outdated
} | ||
|
||
func getCmdline(command v1alpha2.Command) []string { | ||
exe := command.Exec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you can get rid off this variable?
} | ||
return foundGroupCmd, nil | ||
} | ||
return groupCmds[0], nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns the command even if it might not be default. I assume we consider that if only one command is present, take it as default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's assumed (it is explained in the comment of the function).
pkg/libdevfile/command_apply.go
Outdated
return fmt.Errorf("component %q does not exists", o.command.Apply.Component) | ||
} | ||
|
||
if len(devfileComponents) != 1 { | ||
return fmt.Errorf("more than one component with the same name, should not happen") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on adding error structs for these errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these, thanks
The tests pass, so approving it, and the code looks good for now. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: valaparthvi 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 |
86536d5
to
9f5923c
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
/lgtm |
* Execute devfile command * Undeploy * cleanup devfile/adapters * refactor * Move GetOnePod to component package * Move DoesComponentExist and Log from devfile/adapter to component package * Exec without devfile/adapters * Move Delete from devfile/adapters to component * Remove old Deploy code * review * Add tests for issue 5454 * Review
What type of PR is this:
/kind cleanup
What does this PR do / why we need it:
This PR rewrites the part of the devfile/adapters package used to execute commands, for the moment Deploy and Events commands, but can be completed to support other Commands (Build, Run, Test).
The content of the libdevfile package only cares about the devfile structure, and calls methods of the received handler to run the odo specific work. This way, devfile and odo code are clearly separated. The target is to include this code into the
devfile/library
, if devfile team agrees.It also includes some convenient functions to create Command and Components of specific types (mostly convenient for writing tests).
The commands using this implementation:
odo deploy
andodo delete --deploy
commands.odo push
andodo delete
commands parts dealing with postStart and preStop events.It also moves some methods from the devfile/adapters package to the pkg/component package, as these methods are 100% component related and not devfile related.
Which issue(s) this PR fixes:
partially #5298
Fixes #5454
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer:
Refer #5460 (comment) if you want to have the devfiles used for testing while working on the code for this PR.