Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7cea7ccd
Commit
7cea7ccd
authored
May 31, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retry GetThirdPartyGroupVersions
parent
9e311757
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
factory.go
pkg/kubectl/cmd/util/factory.go
+13
-1
helpers.go
pkg/kubectl/cmd/util/helpers.go
+4
-0
No files found.
pkg/kubectl/cmd/util/factory.go
View file @
7cea7ccd
...
@@ -38,6 +38,7 @@ import (
...
@@ -38,6 +38,7 @@ import (
"k8s.io/kubernetes/federation/apis/federation"
"k8s.io/kubernetes/federation/apis/federation"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
apierrors
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/service"
"k8s.io/kubernetes/pkg/api/service"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
...
@@ -260,7 +261,18 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
...
@@ -260,7 +261,18 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
client
,
err
:=
clients
.
ClientForVersion
(
&
unversioned
.
GroupVersion
{
Version
:
"v1"
})
client
,
err
:=
clients
.
ClientForVersion
(
&
unversioned
.
GroupVersion
{
Version
:
"v1"
})
CheckErr
(
err
)
CheckErr
(
err
)
versions
,
gvks
,
err
:=
GetThirdPartyGroupVersions
(
client
.
Discovery
())
var
versions
[]
unversioned
.
GroupVersion
var
gvks
[]
unversioned
.
GroupVersionKind
retries
:=
3
for
i
:=
0
;
i
<
retries
;
i
++
{
versions
,
gvks
,
err
=
GetThirdPartyGroupVersions
(
client
.
Discovery
())
// Retry if we got a NotFound error, because user may delete
// a thirdparty group when the GetThirdPartyGroupVersions is
// running.
if
err
==
nil
||
!
apierrors
.
IsNotFound
(
err
)
{
break
}
}
CheckErr
(
err
)
CheckErr
(
err
)
if
len
(
versions
)
>
0
{
if
len
(
versions
)
>
0
{
priorityMapper
,
ok
:=
mapper
.
RESTMapper
.
(
meta
.
PriorityRESTMapper
)
priorityMapper
,
ok
:=
mapper
.
RESTMapper
.
(
meta
.
PriorityRESTMapper
)
...
...
pkg/kubectl/cmd/util/helpers.go
View file @
7cea7ccd
...
@@ -488,6 +488,10 @@ func ShouldRecord(cmd *cobra.Command, info *resource.Info) bool {
...
@@ -488,6 +488,10 @@ func ShouldRecord(cmd *cobra.Command, info *resource.Info) bool {
return
GetRecordFlag
(
cmd
)
||
ContainsChangeCause
(
info
)
return
GetRecordFlag
(
cmd
)
||
ContainsChangeCause
(
info
)
}
}
// GetThirdPartyGroupVersions returns the thirdparty "group/versions"s and
// resources supported by the server. A user may delete a thirdparty resource
// when this function is running, so this function may return a "NotFound" error
// due to the race.
func
GetThirdPartyGroupVersions
(
discovery
discovery
.
DiscoveryInterface
)
([]
unversioned
.
GroupVersion
,
[]
unversioned
.
GroupVersionKind
,
error
)
{
func
GetThirdPartyGroupVersions
(
discovery
discovery
.
DiscoveryInterface
)
([]
unversioned
.
GroupVersion
,
[]
unversioned
.
GroupVersionKind
,
error
)
{
result
:=
[]
unversioned
.
GroupVersion
{}
result
:=
[]
unversioned
.
GroupVersion
{}
gvks
:=
[]
unversioned
.
GroupVersionKind
{}
gvks
:=
[]
unversioned
.
GroupVersionKind
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment