Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
2f16e0ed
Unverified
Commit
2f16e0ed
authored
Jul 29, 2019
by
Taylor Thomas
Committed by
GitHub
Jul 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6092 from mumoshu/fix-failing-crd-update
fix: upgrade charts with CRD changes
parents
78c03fcb
ae52477f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
client.go
pkg/kube/client.go
+25
-10
wait.go
pkg/kube/wait.go
+1
-1
No files found.
pkg/kube/client.go
View file @
2f16e0ed
...
@@ -656,7 +656,7 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P
...
@@ -656,7 +656,7 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P
}
}
// Get a versioned object
// Get a versioned object
versionedObject
:=
asVersioned
(
target
)
versionedObject
,
err
:=
asVersioned
(
target
)
// Unstructured objects, such as CRDs, may not have an not registered error
// Unstructured objects, such as CRDs, may not have an not registered error
// returned from ConvertToVersion. Anything that's unstructured should
// returned from ConvertToVersion. Anything that's unstructured should
...
@@ -664,16 +664,25 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P
...
@@ -664,16 +664,25 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P
// on objects like CRDs.
// on objects like CRDs.
_
,
isUnstructured
:=
versionedObject
.
(
runtime
.
Unstructured
)
_
,
isUnstructured
:=
versionedObject
.
(
runtime
.
Unstructured
)
// On newer K8s versions, CRDs aren't unstructured but has this dedicated type
_
,
isCRD
:=
versionedObject
.
(
*
apiextv1beta1
.
CustomResourceDefinition
)
switch
{
switch
{
case
runtime
.
IsNotRegisteredError
(
err
),
isUnstructured
:
case
runtime
.
IsNotRegisteredError
(
err
),
isUnstructured
,
isCRD
:
// fall back to generic JSON merge patch
// fall back to generic JSON merge patch
patch
,
err
:=
jsonpatch
.
CreateMergePatch
(
oldData
,
newData
)
patch
,
err
:=
jsonpatch
.
CreateMergePatch
(
oldData
,
newData
)
return
patch
,
types
.
MergePatchType
,
err
if
err
!=
nil
{
return
nil
,
types
.
MergePatchType
,
fmt
.
Errorf
(
"failed to create merge patch: %v"
,
err
)
}
return
patch
,
types
.
MergePatchType
,
nil
case
err
!=
nil
:
case
err
!=
nil
:
return
nil
,
types
.
StrategicMergePatchType
,
fmt
.
Errorf
(
"failed to get versionedObject: %s"
,
err
)
return
nil
,
types
.
StrategicMergePatchType
,
fmt
.
Errorf
(
"failed to get versionedObject: %s"
,
err
)
default
:
default
:
patch
,
err
:=
strategicpatch
.
CreateTwoWayMergePatch
(
oldData
,
newData
,
versionedObject
)
patch
,
err
:=
strategicpatch
.
CreateTwoWayMergePatch
(
oldData
,
newData
,
versionedObject
)
return
patch
,
types
.
StrategicMergePatchType
,
err
if
err
!=
nil
{
return
nil
,
types
.
StrategicMergePatchType
,
fmt
.
Errorf
(
"failed to create two-way merge patch: %v"
,
err
)
}
return
patch
,
types
.
StrategicMergePatchType
,
nil
}
}
}
}
...
@@ -728,7 +737,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
...
@@ -728,7 +737,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
return
nil
return
nil
}
}
versioned
:=
asVersioned
(
target
)
versioned
:=
asVersioned
OrUnstructured
(
target
)
selector
,
ok
:=
getSelectorFromObject
(
versioned
)
selector
,
ok
:=
getSelectorFromObject
(
versioned
)
if
!
ok
{
if
!
ok
{
return
nil
return
nil
...
@@ -944,7 +953,7 @@ func (c *Client) getSelectRelationPod(info *resource.Info, objPods map[string][]
...
@@ -944,7 +953,7 @@ func (c *Client) getSelectRelationPod(info *resource.Info, objPods map[string][]
c
.
Log
(
"get relation pod of object: %s/%s/%s"
,
info
.
Namespace
,
info
.
Mapping
.
GroupVersionKind
.
Kind
,
info
.
Name
)
c
.
Log
(
"get relation pod of object: %s/%s/%s"
,
info
.
Namespace
,
info
.
Mapping
.
GroupVersionKind
.
Kind
,
info
.
Name
)
versioned
:=
asVersioned
(
info
)
versioned
:=
asVersioned
OrUnstructured
(
info
)
selector
,
ok
:=
getSelectorFromObject
(
versioned
)
selector
,
ok
:=
getSelectorFromObject
(
versioned
)
if
!
ok
{
if
!
ok
{
return
objPods
,
nil
return
objPods
,
nil
...
@@ -977,17 +986,23 @@ func isFoundPod(podItem []v1.Pod, pod v1.Pod) bool {
...
@@ -977,17 +986,23 @@ func isFoundPod(podItem []v1.Pod, pod v1.Pod) bool {
return
false
return
false
}
}
func
asVersioned
(
info
*
resource
.
Info
)
runtime
.
Object
{
func
asVersionedOrUnstructured
(
info
*
resource
.
Info
)
runtime
.
Object
{
obj
,
_
:=
asVersioned
(
info
)
return
obj
}
func
asVersioned
(
info
*
resource
.
Info
)
(
runtime
.
Object
,
error
)
{
converter
:=
runtime
.
ObjectConvertor
(
scheme
.
Scheme
)
converter
:=
runtime
.
ObjectConvertor
(
scheme
.
Scheme
)
groupVersioner
:=
runtime
.
GroupVersioner
(
schema
.
GroupVersions
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()))
groupVersioner
:=
runtime
.
GroupVersioner
(
schema
.
GroupVersions
(
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()))
if
info
.
Mapping
!=
nil
{
if
info
.
Mapping
!=
nil
{
groupVersioner
=
info
.
Mapping
.
GroupVersionKind
.
GroupVersion
()
groupVersioner
=
info
.
Mapping
.
GroupVersionKind
.
GroupVersion
()
}
}
if
obj
,
err
:=
converter
.
ConvertToVersion
(
info
.
Object
,
groupVersioner
);
err
==
nil
{
obj
,
err
:=
converter
.
ConvertToVersion
(
info
.
Object
,
groupVersioner
)
return
obj
if
err
!=
nil
{
return
info
.
Object
,
err
}
}
return
info
.
Object
return
obj
,
nil
}
}
func
asInternal
(
info
*
resource
.
Info
)
(
runtime
.
Object
,
error
)
{
func
asInternal
(
info
*
resource
.
Info
)
(
runtime
.
Object
,
error
)
{
...
...
pkg/kube/wait.go
View file @
2f16e0ed
...
@@ -53,7 +53,7 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
...
@@ -53,7 +53,7 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
pvc
:=
[]
v1
.
PersistentVolumeClaim
{}
pvc
:=
[]
v1
.
PersistentVolumeClaim
{}
deployments
:=
[]
deployment
{}
deployments
:=
[]
deployment
{}
for
_
,
v
:=
range
created
{
for
_
,
v
:=
range
created
{
switch
value
:=
asVersioned
(
v
)
.
(
type
)
{
switch
value
:=
asVersioned
OrUnstructured
(
v
)
.
(
type
)
{
case
*
v1
.
ReplicationController
:
case
*
v1
.
ReplicationController
:
list
,
err
:=
getPods
(
kcs
,
value
.
Namespace
,
value
.
Spec
.
Selector
)
list
,
err
:=
getPods
(
kcs
,
value
.
Namespace
,
value
.
Spec
.
Selector
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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