-
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
List created components for devfile v2 #3505
List created components for devfile v2 #3505
Conversation
|
||
}) | ||
|
||
It("checks devfile and s2i components together", func() { |
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 is a fun one
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.
Minor changes.
For some reason there's an issue deploying however..
I used odo create nodejs --starter
~/openshift/stuff ⍉
▶ odo push
Validation
✓ Validating the devfile [44773ns]
Initialization
✓ Initializing the component [3s]
Creating Docker resources for component nodejs
✓ Pulling image registry.access.redhat.com/ubi8/nodejs-12:1-36 [16s]
✓ Starting container for registry.access.redhat.com/ubi8/nodejs-12:1-36 [1s]
Syncing to component nodejs
✓ Checking files for pushing [678074ns]
✓ Syncing files to the component [331ms]
Executing devfile commands for component nodejs
✓ Executing install command "npm install" [2s]
✓ Executing run command "npm start" [1s]
Pushing devfile component nodejs
✓ Changes successfully pushed to component
~/openshift/stuff
▶ odo list
Experimental mode is enabled, use at your own risk
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1591280]
goroutine 1 [running]:
github.com/openshift/odo/pkg/kclient.(*Client).ListDeployments(0x0, 0x1c59402, 0x3, 0x10, 0xc000a4b8c0, 0xc000787b00)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/pkg/kclient/deployments.go:50 +0xf0
github.com/openshift/odo/pkg/odo/cli/component.(*ListOptions).Run(0xc000050e00, 0x0, 0x0)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/pkg/odo/cli/component/list.go:169 +0x1578
github.com/openshift/odo/pkg/odo/genericclioptions.GenericRun(0x1f73640, 0xc000050e00, 0xc0000e6a00, 0x2fe0750, 0x0, 0x0)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/pkg/odo/genericclioptions/runnable.go:31 +0x13c
github.com/openshift/odo/pkg/odo/cli/component.NewCmdList.func1(0xc0000e6a00, 0x2fe0750, 0x0, 0x0)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/pkg/odo/cli/component/list.go:277 +0x5e
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).execute(0xc0000e6a00, 0x2fe0750, 0x0, 0x0, 0xc0000e6a00, 0x2fe0750)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:830 +0x2aa
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc00045e500, 0x1d6cc10, 0xc000529860, 0x1)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:914 +0x2fb
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).Execute(...)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:864
main.main()
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/cmd/odo/odo.go:67 +0x32a
pkg/kclient/deployments.go
Outdated
}) | ||
} | ||
|
||
func (c *Client) ListAllDeployments() (*appsv1.DeploymentList, 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.
Missing comments
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.
added
pkg/kclient/deployments.go
Outdated
@@ -42,6 +44,18 @@ func getDeploymentCondition(status appsv1.DeploymentStatus, condType appsv1.Depl | |||
return nil | |||
} | |||
|
|||
func (c *Client) ListDeployments(appName string) (*appsv1.DeploymentList, 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.
Missing comments
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.
done
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.
added
pkg/odo/cli/component/list.go
Outdated
if len(lo.pathFlag) != 0 { | ||
|
||
if experimental.IsExperimentalModeEnabled() { |
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.
Am I missing something or was this moved from somewhere else?
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.
component list didn't support experimental mode 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.
the --path flag support for experimental mode will be added as a follow up PR as the changes in this PR are already quite wide spread already
var dpl *appsv1.DeploymentList | ||
var err error | ||
|
||
// TODO: wrap this into a component list for docker support |
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.
left a TODO here by mistake?
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.
docker support marker for someone who would implement it
pkg/odo/cli/component/list.go
Outdated
components, err = component.List(lo.Client, lo.Application, lo.LocalConfigInfo) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to fetch components list") | ||
klog.V(4).Infof("the components are %+v", components) |
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.
maybe remove this debug before merging
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 was added by tomas like 8 months ago https://github.com/openshift/odo/blob/master/pkg/odo/cli/component/list.go#L143, I can remove this if you want
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.
removed
pkg/odo/cli/component/list.go
Outdated
if err != nil { | ||
return err | ||
return errors.Wrapf(err, "failed to fetch components list") |
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.
failed to fetch component list
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.
done
Tried again with the newest changes and I still get an issue: ~/openshift/foobar
▶ odo create nodejs --starter
Experimental mode is enabled, use at your own risk
Validation
✓ Checking devfile existence [76586ns]
✓ Checking devfile compatibility [1ms]
✓ Creating a devfile component from registry: DefaultDevfileRegistry [1ms]
✓ Validating devfile component [338458ns]
Please use `odo push` command to create the component with source deployed
~/openshift/foobar
▶ odo push
Validation
✓ Validating the devfile [21778ns]
Syncing to component nodejs
✓ Checking file changes for pushing [451061ns]
✓ Syncing files to the component [364ms]
Executing devfile commands for component nodejs
✓ Executing install command "npm install" [1s]
✓ Executing run command "npm start" [2s]
Pushing devfile component nodejs
✓ Changes successfully pushed to component
~/openshift/foobar
▶ odo list
Experimental mode is enabled, use at your own risk
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1591280]
goroutine 1 [running]:
github.com/openshift/odo/pkg/kclient.(*Client).ListDeployments(0x0, 0xc0007212d0, 0x3, 0x10, 0xc00066a720, 0xc0006d1100)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/pkg/kclient/deployments.go:50 +0xf0
github.com/openshift/odo/pkg/odo/cli/component.(*ListOptions).Run(0xc000051e40, 0x0, 0x0)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/pkg/odo/cli/component/list.go:169 +0x1578
github.com/openshift/odo/pkg/odo/genericclioptions.GenericRun(0x1f73640, 0xc000051e40, 0xc0002bc000, 0x2fe0750, 0x0, 0x0)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/pkg/odo/genericclioptions/runnable.go:31 +0x13c
github.com/openshift/odo/pkg/odo/cli/component.NewCmdList.func1(0xc0002bc000, 0x2fe0750, 0x0, 0x0)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/pkg/odo/cli/component/list.go:277 +0x5e
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).execute(0xc0002bc000, 0x2fe0750, 0x0, 0x0, 0xc0002bc000, 0x2fe0750)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:830 +0x2aa
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000136000, 0x1d6cc10, 0xc0004ff620, 0x1)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:914 +0x2fb
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).Execute(...)
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:864
main.main()
/home/wikus/syncthing/files/dev/go/src/github.com/openshift/odo/cmd/odo/odo.go:67 +0x32a
|
I followed the same approach
can you share any pre-steps you are performing? |
Tried again on a kuberenetes cluster -
|
@cdrage addressed all your comments |
/retest |
2 similar comments
/retest |
/retest |
b523541
to
66e0c7f
Compare
pkg/occlient/occlient.go
Outdated
list, err := c.discoveryClient.ServerResourcesForGroupVersion(groupVersion) | ||
if kerrors.IsNotFound(err) { | ||
return false, nil | ||
} else if err != nil { | ||
return false, err | ||
} | ||
|
||
for _, resources := range list.APIResources { |
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.
We can use isResourceSupported() for checking the existence of a resource.
pkg/odo/cli/component/list.go
Outdated
if util.CheckKubeConfigExist() { | ||
klog.V(4).Infof("New Context") | ||
lo.Context = genericclioptions.NewContext(cmd) | ||
} else { |
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.
Some comments 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.
done
pkg/odo/cli/component/list.go
Outdated
} | ||
|
||
lo.Client = genericclioptions.Client(cmd) | ||
dcSupport, err := lo.Client.IsDeploymentConfigSupported() |
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.
maybe assign to lo.hasDCSupport
directly 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.
done
pkg/odo/cli/component/list.go
Outdated
if len(lo.Application) != 0 && lo.allAppsFlag { | ||
klog.V(4).Infof("either --app and --all-apps both provided or provided --all-apps in a folder has app, use --all-apps anyway") | ||
} | ||
|
||
if experimental.IsExperimentalModeEnabled() { |
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.
maybe store the value somewhere and use 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.
done
pkg/odo/cli/component/list.go
Outdated
|
||
if experimental.IsExperimentalModeEnabled() { | ||
|
||
var dpl *appsv1.DeploymentList |
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.
something better than dpl
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.
done
pkg/odo/cli/component/list.go
Outdated
for _, comp := range dpl.Items { | ||
app := comp.Labels[applabels.ApplicationLabel] | ||
cmpType := comp.Labels[componentlabels.ComponentTypeLabel] | ||
revision := comp.Annotations["deployment.kubernetes.io/revision"] |
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.
do we need to display the revision?
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.
It allowed me to understand that my application was updated or not, does it reduce the UX?
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 seems s2i components don't have this column. Can we have the component STATE
instead?
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.
added
Context("push with listing the devfile component", func() { | ||
|
||
It("checks components in a specific app and all apps", func() { | ||
helper.Chdir(currentWorkingDirectory) |
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.
do we need to change directory?
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.
done, not changing the dir now
/retest |
66e0c7f
to
6a491b5
Compare
pkg/occlient/occlient.go
Outdated
const Group = "apps.openshift.io" | ||
const Version = "v1" | ||
|
||
return c.isResourceSupported(Group, Version, "DeploymentConfig") |
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 seems to panic for me, when run against a s2i component in experimental mode, as the client is nil
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1c29be0]
goroutine 1 [running]:
github.com/openshift/odo/pkg/occlient.(*Client).isResourceSupported(0x0, 0x24f97a2, 0x11, 0x24ea377, 0x2, 0x24f7688, 0x10, 0xc000261300, 0x0, 0x0)
/home/mrinaldas/go/src/github.com/openshift/odo/pkg/occlient/occlient.go:3341 +0xf0
github.com/openshift/odo/pkg/occlient.(*Client).IsDeploymentConfigSupported(0x0, 0x0, 0x0, 0x0)
/home/mrinaldas/go/src/github.com/openshift/odo/pkg/occlient/occlient.go:3295 +0x8c
github.com/openshift/odo/pkg/odo/cli/component.(*ListOptions).Complete(0xc0003ceac0, 0x24eafa4, 0x4, 0xc0006a3680, 0x39712d8, 0x0, 0x0, 0x0, 0x0)
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.
Even fails for devfile components.
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.
resolved, so we cannot create the Client
only if the resource exists as thats a catch 22 situation.
57ee711
to
a366be0
Compare
21ec6c8
to
71c34b4
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.
Code looks good! Thanks for the update @girishramnani but this LGTM.
/lgtm
/retest |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mik-dass 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 |
/lgtm |
/lgtm |
What type of PR is this?
/kind feature
What does does this PR do / why we need it:
support listing of components for devfilev2. The --path flag and json output would be added as a follow up.
Which issue(s) this PR fixes:
Fixes #2835
Fixes #3050
How to test changes / Special notes to the reviewer:
odo create nodejs
odo push
odo list
Created a follow up issue #3521 for stuff not covered by the issue story #2835