-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
new-app: verify if API has required resources enabled #20020
new-app: verify if API has required resources enabled #20020
Conversation
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.
one nit on the text and lgtm.
pkg/oc/cli/cmd/newapp.go
Outdated
} | ||
|
||
if len(missingResources) > 0 { | ||
return fmt.Errorf("Missing required resources: %v", strings.Join(missingResources, `, `)) |
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.
"API server is missing required resources: "
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.
Hmmm... I'm not sure I want this to fail entirely. Why just not create the BC, the oc new-app
is still useful without builds, and in a build-disabled cluster you're making it entirely unusable, yet I can still create an app, just without the build, as in oc new-app openshift/hello-openshift
should still create the DC, IS and SVC for me. I don't see any reason that would fail me with information that BC is missing, even if I don't care about 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.
maybe. If new-app generated a buildconfig, we definitely want this to fail, we don't want to create some, but not all, of the resources. Creating a DC when the BC that generates the image the DC deploys, doesn't exist, would be bad.
But if you're actually just using new-app to create a DC (oc new-app centos/mysql-56-centos7
, or oc new-app -f sometemplatewithoutaBC.yaml
) I suppose it's fair to allow that to proceed.
So I think the ideal solution would iterate the objects we are going to attempt to create, ensure those types all exist in the api server, and if not, abort indicating which resources that new-app wanted to create, were not available in the api server (abort before creating any resources).
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.
Yup, that last sentence is exactly what I'd expect to happen. The current approach fails always, but like Ben said oc new-app centos/mysql-56-centos7
should work.
/cc @openshift/cli-review |
pkg/oc/cli/cmd/newapp.go
Outdated
} | ||
} | ||
|
||
requiredResources := []string{"BuildConfig", "ImageStream"} |
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.
based on this our objects are "native" and not namespaced CRD-style Kinds?
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 actually have both the legacy apis and the grouped apis. This should probably check to see if either exists, in case we eventually remove the legacy api.
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.
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.
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.
Thanks, I will mark the PR as [WIP] for now and address the comments when I'm back from PTO next week.
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.
What does "no legacy in the cli" mean? In this case we're simply checking what the api server supports, we're not using these apis to call the server.
pkg/oc/cli/cmd/newapp.go
Outdated
} | ||
|
||
if len(missingResources) > 0 { | ||
return fmt.Errorf("Missing required resources: %v", strings.Join(missingResources, `, `)) |
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.
Hmmm... I'm not sure I want this to fail entirely. Why just not create the BC, the oc new-app
is still useful without builds, and in a build-disabled cluster you're making it entirely unusable, yet I can still create an app, just without the build, as in oc new-app openshift/hello-openshift
should still create the DC, IS and SVC for me. I don't see any reason that would fail me with information that BC is missing, even if I don't care about one.
@soltysh, @bparees, @adambkaplan I would like to try to obtain a list/map of required resources (the code is in a second commit c0ab188), but I suppose iterating over the origin/pkg/oc/cli/cmd/newapp.go Lines 171 to 174 in c0ab188
this appears to only yeild Should I rather type-switch on the items like it is done here and care only about missing origin/pkg/oc/cli/cmd/newapp.go Lines 400 to 406 in c0ab188
|
i'd say that's an acceptable path of least resistance at this point. |
Hold with any actions until after the rebase, there will be some significant changes in the apimachinery that will change some bits of your code. |
EDIT: I spent so much time writing below that I missed @soltysh comment. Thanks and will wait! @bparees, @adambkaplan trying to wrap my head around the comment regarding CRD and this entire issue. Please correct the following, I will try to summarize my understanding here
@mfojtik shouldn't this rather go to release-3.9 only given #19070 removed the ability to disable Builds? |
in that case, is it even worth having this? Post 3.9 releases don't have the Rebased, pushed changes as last 'WIP' commit for review. If this is indeed what we would like to have, I will squash all commits into one |
c0ab188
to
3ed3e06
Compare
can't we attempt to look up the kind/convert it from unstructured? |
We do, check HasResource in kubectl's run how this is handled. |
@soltysh but isn't this assuming origin/pkg/oc/cli/cmd/newapp.go Lines 349 to 353 in c0ab188
|
@wozniakjan we should be setting those with the current state of oc. If it does not lemme know, I might end up looking into myself. |
@soltysh added few debug statements wozniakjan#4 and rebased on current master
So I still think it doesn't populate |
See wozniakjan#4 (comment) for my answer |
878012b
to
6832a9c
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.
one message nit and lgtm.
pkg/oc/cli/cmd/newapp.go
Outdated
} | ||
|
||
if len(missingResources) > 0 { | ||
return fmt.Errorf("Missing declared resources: %v", strings.Join(missingResources, `, `)) |
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.
"API server is missing declared resources:"
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.
corrected, thanks!
6832a9c
to
aad0a92
Compare
/retest
|
/approve @soltysh lgty? |
aad0a92
to
996a2fe
Compare
/test gcp |
1 similar comment
/test gcp |
@wozniakjan appears to be merge conflicted again :( |
996a2fe
to
3011e56
Compare
@bparees thanks, you are faster than our merge bot :) |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bparees, wozniakjan 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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
@wozniakjan: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
/retest Please review the full test history for this PR and help us cut down flakes. |
|
||
func checkResources(discoveryClient discovery.DiscoveryInterface, items []runtime.Object) error { | ||
resources, err := discoveryClient.ServerResources() | ||
if 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.
@wozniakjan @soltysh I got here because this particular line didn't tolerate partial discovery. All CLI commands should tolerate partial discovery and only fail if they cannot retrieve sufficient information. There may be cases where all of discovery must match, but this isn't one of them.
As an overall experience with I'm reverting this because it's leading to behavioral problems in our CLI. |
new revert PR: #20781 |
fixes #20002 by checking the
kind
of each resourcenow it fails very early, produces following output if builds are disabled
ptal @openshift/sig-developer-experience, @mfojtik