Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
1105 Внедрение механизмов обеспечения безопасности цепочки поставки программных проектов
Legacy
scanned-projects
helm
Commits
d6dc3ded
Unverified
Commit
d6dc3ded
authored
7 years ago
by
Reinhard Nägele
Committed by
Matthew Fisher
7 years ago
Browse files
Options
Download
Patches
Plain Diff
Fix pod recreation
(cherry picked from commit
3d05da01
)
parent
db39e092
release-2.8
v2.8.2
v2.8.2-rc1
v2.8.1
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/kube/client.go
+28
-29
pkg/kube/client.go
with
28 additions
and
29 deletions
+28
-29
pkg/kube/client.go
+
28
−
29
View file @
d6dc3ded
...
...
@@ -428,40 +428,39 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
if
err
:=
target
.
Get
();
err
!=
nil
{
return
fmt
.
Errorf
(
"error trying to refresh resource information: %v"
,
err
)
}
return
nil
}
// send patch to server
helper
:=
resource
.
NewHelper
(
target
.
Client
,
target
.
Mapping
)
obj
,
err
:=
helper
.
Patch
(
target
.
Namespace
,
target
.
Name
,
patchType
,
patch
)
if
err
!=
nil
{
kind
:=
target
.
Mapping
.
GroupVersionKind
.
Kind
log
.
Printf
(
"Cannot patch %s: %q (%v)"
,
kind
,
target
.
Name
,
err
)
}
else
{
// send patch to server
helper
:=
resource
.
NewHelper
(
target
.
Client
,
target
.
Mapping
)
if
force
{
// Attempt to delete...
if
err
:=
deleteResource
(
c
,
target
);
err
!=
nil
{
obj
,
err
:=
helper
.
Patch
(
target
.
Namespace
,
target
.
Name
,
patchType
,
patch
)
if
err
!=
nil
{
kind
:=
target
.
Mapping
.
GroupVersionKind
.
Kind
log
.
Printf
(
"Cannot patch %s: %q (%v)"
,
kind
,
target
.
Name
,
err
)
if
force
{
// Attempt to delete...
if
err
:=
deleteResource
(
c
,
target
);
err
!=
nil
{
return
err
}
log
.
Printf
(
"Deleted %s: %q"
,
kind
,
target
.
Name
)
// ... and recreate
if
err
:=
createResource
(
target
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to recreate resource: %s"
,
err
)
}
log
.
Printf
(
"Created a new %s called %q
\n
"
,
kind
,
target
.
Name
)
// No need to refresh the target, as we recreated the resource based
// on it. In addition, it might not exist yet and a call to `Refresh`
// may fail.
}
else
{
log
.
Print
(
"Use --force to force recreation of the resource"
)
return
err
}
log
.
Printf
(
"Deleted %s: %q"
,
kind
,
target
.
Name
)
// ... and recreate
if
err
:=
createResource
(
target
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to recreate resource: %s"
,
err
)
}
log
.
Printf
(
"Created a new %s called %q
\n
"
,
kind
,
target
.
Name
)
// No need to refresh the target, as we recreated the resource based
// on it. In addition, it might not exist yet and a call to `Refresh`
// may fail.
}
else
{
log
.
Print
(
"Use --force to force recreation of the resource"
)
return
err
// When patch succeeds without needing to recreate, refresh target.
target
.
Refresh
(
obj
,
true
)
}
}
else
{
// When patch succeeds without needing to recreate, refresh target.
target
.
Refresh
(
obj
,
true
)
}
if
!
recreate
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets