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
4c4623e5
Commit
4c4623e5
authored
Sep 19, 2016
by
Dawn Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix backward compatibility issue caused by promoting initcontainers from alpha to beta.
parent
3802a9ba
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
conversion.go
pkg/api/v1/conversion.go
+17
-0
types.go
pkg/api/v1/types.go
+7
-2
No files found.
pkg/api/v1/conversion.go
View file @
4c4623e5
...
@@ -414,14 +414,22 @@ func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult,
...
@@ -414,14 +414,22 @@ func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult,
return
err
return
err
}
}
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
out
.
Annotations
[
PodInitContainerStatusesBetaAnnotationKey
]
=
string
(
value
)
}
else
{
}
else
{
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesBetaAnnotationKey
)
}
}
return
nil
return
nil
}
}
func
Convert_v1_PodStatusResult_To_api_PodStatusResult
(
in
*
PodStatusResult
,
out
*
api
.
PodStatusResult
,
s
conversion
.
Scope
)
error
{
func
Convert_v1_PodStatusResult_To_api_PodStatusResult
(
in
*
PodStatusResult
,
out
*
api
.
PodStatusResult
,
s
conversion
.
Scope
)
error
{
// TODO: sometime after we move init container to stable, remove these conversions
// TODO: sometime after we move init container to stable, remove these conversions
// If there is a beta annotation, copy to alpha key.
// See commit log for PR #31026 for why we do this.
if
valueBeta
,
okBeta
:=
in
.
Annotations
[
PodInitContainerStatusesBetaAnnotationKey
];
okBeta
{
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
valueBeta
}
// Move the annotation to the internal repr. field
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
ok
{
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
ok
{
var
values
[]
ContainerStatus
var
values
[]
ContainerStatus
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
...
@@ -446,6 +454,7 @@ func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out
...
@@ -446,6 +454,7 @@ func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out
out
.
Annotations
[
k
]
=
v
out
.
Annotations
[
k
]
=
v
}
}
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesBetaAnnotationKey
)
}
}
return
nil
return
nil
}
}
...
@@ -575,6 +584,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
...
@@ -575,6 +584,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
delete
(
out
.
Annotations
,
PodInitContainersAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainersAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainersBetaAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainersBetaAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesBetaAnnotationKey
)
}
}
if
len
(
out
.
Spec
.
InitContainers
)
>
0
{
if
len
(
out
.
Spec
.
InitContainers
)
>
0
{
value
,
err
:=
json
.
Marshal
(
out
.
Spec
.
InitContainers
)
value
,
err
:=
json
.
Marshal
(
out
.
Spec
.
InitContainers
)
...
@@ -590,6 +600,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
...
@@ -590,6 +600,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
return
err
return
err
}
}
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
out
.
Annotations
[
PodInitContainerStatusesBetaAnnotationKey
]
=
string
(
value
)
}
}
// We need to reset certain fields for mirror pods from pre-v1.1 kubelet
// We need to reset certain fields for mirror pods from pre-v1.1 kubelet
...
@@ -627,6 +638,11 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
...
@@ -627,6 +638,11 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
// back to the caller.
// back to the caller.
in
.
Spec
.
InitContainers
=
values
in
.
Spec
.
InitContainers
=
values
}
}
// If there is a beta annotation, copy to alpha key.
// See commit log for PR #31026 for why we do this.
if
valueBeta
,
okBeta
:=
in
.
Annotations
[
PodInitContainerStatusesBetaAnnotationKey
];
okBeta
{
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
valueBeta
}
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
ok
{
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
ok
{
var
values
[]
ContainerStatus
var
values
[]
ContainerStatus
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
...
@@ -653,6 +669,7 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
...
@@ -653,6 +669,7 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
delete
(
out
.
Annotations
,
PodInitContainersAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainersAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainersBetaAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainersBetaAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesBetaAnnotationKey
)
}
}
return
nil
return
nil
}
}
...
...
pkg/api/v1/types.go
View file @
4c4623e5
...
@@ -1749,8 +1749,13 @@ const (
...
@@ -1749,8 +1749,13 @@ const (
PodInitContainersAnnotationKey
=
"pod.alpha.kubernetes.io/init-containers"
PodInitContainersAnnotationKey
=
"pod.alpha.kubernetes.io/init-containers"
// This annotation key will be used to contain an array of v1 JSON encoded
// This annotation key will be used to contain an array of v1 JSON encoded
// ContainerStatuses for init containers. The annotation will be placed into the internal
// ContainerStatuses for init containers. The annotation will be placed into the internal
// type and cleared.
// type and cleared. This key is only recognized by version >= 1.4.
PodInitContainerStatusesAnnotationKey
=
"pod.beta.kubernetes.io/init-container-statuses"
PodInitContainerStatusesBetaAnnotationKey
=
"pod.beta.kubernetes.io/init-container-statuses"
// This annotation key will be used to contain an array of v1 JSON encoded
// ContainerStatuses for init containers. The annotation will be placed into the internal
// type and cleared. This key is recognized by version >= 1.3. For version 1.4 code,
// this key will have its value copied to the beta key.
PodInitContainerStatusesAnnotationKey
=
"pod.alpha.kubernetes.io/init-container-statuses"
)
)
// PodSpec is a description of a pod.
// PodSpec is a description of a pod.
...
...
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