-
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
cli: remove usage of internal apps helpers from all CLI commands #20362
cli: remove usage of internal apps helpers from all CLI commands #20362
Conversation
pkg/apps/util/const.go
Outdated
|
||
// deploymentStatusReasonAnnotation represents the reason for deployment being in a given state | ||
// Used for specifying the reason for cancellation or failure of a deployment | ||
deploymentStatusReasonAnnotation = "openshift.io/deployment.status-reason" |
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.
@tnozicka note that this collection is used exclusively by util helpers and nothing else... i thinks we should not make it public but have helpers that allow to use them.
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'd make it public and moved it to library-go or somewhere so people can import it. The annotation is API-ish as that's part of the public facing status and an annotation just because we don't control the API for the upstream object.
i thinks we should not make it public but have helpers that allow to use them.
I thought we are trying to get rid of those one line helpers.
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.
Those are useful consts for someone writing an integration, making them private will just lead to code duplication
pkg/apps/util/deployment.go
Outdated
|
||
deploymentName := LatestDeploymentNameForConfig(config) | ||
|
||
podSpec := v1.PodSpec{} |
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.
err have to drop this
2c7c016
to
d8f94cb
Compare
@@ -86,6 +86,15 @@ func NewPerDeploymentConfigResolver(dataSet DataSet, keepComplete int, keepFaile | |||
} | |||
} | |||
|
|||
// ByMostRecent sorts deployments by most recently created. | |||
type ByMostRecent []*kapi.ReplicationController |
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 resolvers use this, I don't see a reason for this to live in apps util package... if resolvers want special sort, then lets make them define it here.
pkg/oc/cli/rollback/rollback.go
Outdated
kc kclientset.Interface | ||
|
||
appsClient appstypedclient.AppsV1Interface | ||
kubeClient kubernetes.Interface |
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.
@juanvallejo @deads2k there are some commands I had to switch to external client now to avoid local conversions
configName = appsinternalutil.DeploymentConfigNameFor(obj) | ||
case *appsapi.DeploymentConfig: | ||
configName = appsutil.DeploymentConfigNameFor(obj) | ||
case *appsv1.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.
@deads2k @juanvallejo can you confirm this will work? :-)
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 think you have to change the scheme in the resource builder in o.findResource
to be WithScheme(ocscheme.ReadingInternalScheme, ocscheme.ReadingInternalScheme.PrioritizedVersionsAllGroups()...)
, otherwise, you'll still be dealing with internal objects 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.
fixed, thanks!
*appsapitest.OkHPAForDeploymentConfig(config, 1, 3), | ||
}}, nil | ||
}) | ||
// TODO: re-enable when we switch describer to external client |
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.
every big win has some small looses :-)
@juanvallejo I can deal with this in a follow up PR, but I didn't want to groom this PR with switching the HPA to external as well (+300 lines of changes)
@@ -77,7 +82,7 @@ func describerMap(clientConfig *rest.Config, kclient kclientset.Interface, host | |||
if err != nil { | |||
glog.V(1).Info(err) | |||
} | |||
appsClient, err := appsclient.NewForConfig(clientConfig) | |||
appsClient, err := appstypedclient.NewForConfig(clientConfig) |
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.
@soltysh @juanvallejo i believe this is the holy grail path and we want to switch all describers to external at some point?
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.
hm, what about upstream describers? I believe some of those make use of the pkg/printers/internalversion
package.
Since we do not use the printers/internalversion package in kubectl to the extent that we used to (with humanreadable printing) due to the introduction of server-side printing, maybe the best path forward for describers would be something similar to server-side printing?
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.
@juanvallejo not super familiar with server side printing, but in general I think describers are not that generic and are very custom for some resources. I think for origin resources, as we continue moving forward with external clients and external types, we will likely convert our describers to external... I would expect that if kubectl is also taking the external path, they will do the same...
/cc @soltysh
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.
At least in the scope of this PR, does switching the describer func for deploymentconfigs affect the oc describe
command?
@@ -74,12 +75,6 @@ func DecodeDeploymentConfig(controller metav1.ObjectMetaAccessor) (*appsapi.Depl | |||
return config, nil | |||
} | |||
|
|||
// DeployerPodSelector returns a label Selector which can be used to find all |
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.
@deads2k you asked about number of remaining internal helpers... these are left overs (used by REST and controllers)... Note that not all if them are duplicated into pkg/apps/util
, some live sorely to make just controllers happy.
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.
@deads2k you asked about number of remaining internal helpers... these are left overs (used by REST and controllers)... Note that not all if them are duplicated into pkg/apps/util, some live sorely to make just controllers happy.
glad to see it moving in the right direction
e793ff9
to
d2430e1
Compare
/retest |
e2b8017
to
80f1367
Compare
pkg/oc/cli/rollback/rollback.go
Outdated
if o.kc == nil { | ||
return fmt.Errorf("kc must not be nil") | ||
if o.kubeClient == nil { | ||
return fmt.Errorf("kubeInternalClient must not be nil") | ||
} | ||
if o.getBuilder == nil { | ||
return fmt.Errorf("getBuilder must not be 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.
I don't think this validation check is necessary - we don't do it in any other commands
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.
yeah, when I saw it I thought it is weird... will remove that
80f1367
to
0f18c67
Compare
0f18c67
to
1ca8f04
Compare
/retest |
1 similar comment
/retest |
/retest |
1 similar comment
/retest |
@@ -54,7 +55,16 @@ func bold(v interface{}) string { | |||
return "\033[1m" + toString(v) + "\033[0m" | |||
} | |||
|
|||
func convertEnv(env []api.EnvVar) map[string]string { | |||
// DEPRECATED: | |||
func convertEnvInternal(env []api.EnvVar) map[string]string { |
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.
Is this still used by something? Do we need to keep it?
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.
not used, I can remove it in follow up if you're fine with that (don't want to mess with the queue now)
/refresh |
New changes are detected. LGTM label has been removed. |
2208e68
to
fc7d8d2
Compare
reapplying LGTM label, simple conflict fixed in oc rollout cancel. |
/retest |
2 similar comments
/retest |
/retest |
fc7d8d2
to
610fb48
Compare
New changes are detected. LGTM label has been removed. |
re-adding lgtm, simple conflict in describer |
This PR removes usage of
appsinternalutil
from all CLI commands, making the CLI not depend on the internal apps types./cc @juanvallejo
/cc @deads2k
/cc @tnozicka