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
fd47b6d4
Commit
fd47b6d4
authored
Sep 19, 2016
by
m1093782566
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change petset replicas type from int to int32
Change-Id: I0b8c30083e4a221421de46d9d4dcb21b1f5bb36f
parent
46c00995
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
28 deletions
+33
-28
types.generated.go
pkg/apis/apps/types.generated.go
+4
-4
types.go
pkg/apis/apps/types.go
+2
-2
conversion.go
pkg/apis/apps/v1alpha1/conversion.go
+3
-3
zz_generated.conversion.go
pkg/apis/apps/v1alpha1/zz_generated.conversion.go
+8
-4
fakes.go
pkg/controller/petset/fakes.go
+1
-1
iterator.go
pkg/controller/petset/iterator.go
+1
-1
pet_set_test.go
pkg/controller/petset/pet_set_test.go
+2
-2
pet_set_utils.go
pkg/controller/petset/pet_set_utils.go
+2
-2
scale.go
pkg/kubectl/scale.go
+1
-1
petset.go
test/e2e/petset.go
+9
-8
No files found.
pkg/apis/apps/types.generated.go
View file @
fd47b6d4
...
...
@@ -639,7 +639,7 @@ func (x *PetSetSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
if
r
.
TryDecodeAsNil
()
{
x
.
Replicas
=
0
}
else
{
x
.
Replicas
=
int
(
r
.
DecodeInt
(
codecSelferBitsize1234
))
x
.
Replicas
=
int
32
(
r
.
DecodeInt
(
32
))
}
case
"selector"
:
if
r
.
TryDecodeAsNil
()
{
...
...
@@ -711,7 +711,7 @@ func (x *PetSetSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if
r
.
TryDecodeAsNil
()
{
x
.
Replicas
=
0
}
else
{
x
.
Replicas
=
int
(
r
.
DecodeInt
(
codecSelferBitsize1234
))
x
.
Replicas
=
int
32
(
r
.
DecodeInt
(
32
))
}
yyj59
++
if
yyhl59
{
...
...
@@ -977,7 +977,7 @@ func (x *PetSetStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
if
r
.
TryDecodeAsNil
()
{
x
.
Replicas
=
0
}
else
{
x
.
Replicas
=
int
(
r
.
DecodeInt
(
codecSelferBitsize1234
))
x
.
Replicas
=
int
32
(
r
.
DecodeInt
(
32
))
}
default
:
z
.
DecStructFieldNotFound
(
-
1
,
yys79
)
...
...
@@ -1033,7 +1033,7 @@ func (x *PetSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if
r
.
TryDecodeAsNil
()
{
x
.
Replicas
=
0
}
else
{
x
.
Replicas
=
int
(
r
.
DecodeInt
(
codecSelferBitsize1234
))
x
.
Replicas
=
int
32
(
r
.
DecodeInt
(
32
))
}
for
{
yyj83
++
...
...
pkg/apis/apps/types.go
View file @
fd47b6d4
...
...
@@ -49,7 +49,7 @@ type PetSetSpec struct {
// same Template, but individual replicas also have a consistent identity.
// If unspecified, defaults to 1.
// TODO: Consider a rename of this field.
Replicas
int
`json:"replicas,omitempty"`
Replicas
int
32
`json:"replicas,omitempty"`
// Selector is a label query over pods that should match the replica count.
// If empty, defaulted to labels on the pod template.
...
...
@@ -85,7 +85,7 @@ type PetSetStatus struct {
ObservedGeneration
*
int64
`json:"observedGeneration,omitempty"`
// Replicas is the number of actual replicas.
Replicas
int
`json:"replicas"`
Replicas
int
32
`json:"replicas"`
}
// PetSetList is a collection of PetSets.
...
...
pkg/apis/apps/v1alpha1/conversion.go
View file @
fd47b6d4
...
...
@@ -28,7 +28,7 @@ import (
)
func
addConversionFuncs
(
scheme
*
runtime
.
Scheme
)
error
{
// Add non-generated conversion functions to handle the *int32 -> int
// Add non-generated conversion functions to handle the *int32 -> int
32
// conversion. A pointer is useful in the versioned type so we can default
// it, but a plain int32 is more convenient in the internal type. These
// functions are the same as the autogenerated ones in every other way.
...
...
@@ -54,7 +54,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
func
Convert_v1alpha1_PetSetSpec_To_apps_PetSetSpec
(
in
*
PetSetSpec
,
out
*
apps
.
PetSetSpec
,
s
conversion
.
Scope
)
error
{
if
in
.
Replicas
!=
nil
{
out
.
Replicas
=
int
(
*
in
.
Replicas
)
out
.
Replicas
=
*
in
.
Replicas
}
if
in
.
Selector
!=
nil
{
in
,
out
:=
&
in
.
Selector
,
&
out
.
Selector
...
...
@@ -85,7 +85,7 @@ func Convert_v1alpha1_PetSetSpec_To_apps_PetSetSpec(in *PetSetSpec, out *apps.Pe
func
Convert_apps_PetSetSpec_To_v1alpha1_PetSetSpec
(
in
*
apps
.
PetSetSpec
,
out
*
PetSetSpec
,
s
conversion
.
Scope
)
error
{
out
.
Replicas
=
new
(
int32
)
*
out
.
Replicas
=
in
t32
(
in
.
Replicas
)
*
out
.
Replicas
=
in
.
Replicas
if
in
.
Selector
!=
nil
{
in
,
out
:=
&
in
.
Selector
,
&
out
.
Selector
*
out
=
new
(
unversioned
.
LabelSelector
)
...
...
pkg/apis/apps/v1alpha1/zz_generated.conversion.go
View file @
fd47b6d4
...
...
@@ -141,7 +141,9 @@ func Convert_apps_PetSetList_To_v1alpha1_PetSetList(in *apps.PetSetList, out *Pe
}
func
autoConvert_v1alpha1_PetSetSpec_To_apps_PetSetSpec
(
in
*
PetSetSpec
,
out
*
apps
.
PetSetSpec
,
s
conversion
.
Scope
)
error
{
// WARNING: in.Replicas requires manual conversion: inconvertible types (*int32 vs int)
if
err
:=
api
.
Convert_Pointer_int32_To_int32
(
&
in
.
Replicas
,
&
out
.
Replicas
,
s
);
err
!=
nil
{
return
err
}
out
.
Selector
=
in
.
Selector
if
err
:=
v1
.
Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec
(
&
in
.
Template
,
&
out
.
Template
,
s
);
err
!=
nil
{
return
err
...
...
@@ -163,7 +165,9 @@ func autoConvert_v1alpha1_PetSetSpec_To_apps_PetSetSpec(in *PetSetSpec, out *app
}
func
autoConvert_apps_PetSetSpec_To_v1alpha1_PetSetSpec
(
in
*
apps
.
PetSetSpec
,
out
*
PetSetSpec
,
s
conversion
.
Scope
)
error
{
// WARNING: in.Replicas requires manual conversion: inconvertible types (int vs *int32)
if
err
:=
api
.
Convert_int32_To_Pointer_int32
(
&
in
.
Replicas
,
&
out
.
Replicas
,
s
);
err
!=
nil
{
return
err
}
out
.
Selector
=
in
.
Selector
if
err
:=
v1
.
Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec
(
&
in
.
Template
,
&
out
.
Template
,
s
);
err
!=
nil
{
return
err
...
...
@@ -186,7 +190,7 @@ func autoConvert_apps_PetSetSpec_To_v1alpha1_PetSetSpec(in *apps.PetSetSpec, out
func
autoConvert_v1alpha1_PetSetStatus_To_apps_PetSetStatus
(
in
*
PetSetStatus
,
out
*
apps
.
PetSetStatus
,
s
conversion
.
Scope
)
error
{
out
.
ObservedGeneration
=
in
.
ObservedGeneration
out
.
Replicas
=
in
t
(
in
.
Replicas
)
out
.
Replicas
=
in
.
Replicas
return
nil
}
...
...
@@ -196,7 +200,7 @@ func Convert_v1alpha1_PetSetStatus_To_apps_PetSetStatus(in *PetSetStatus, out *a
func
autoConvert_apps_PetSetStatus_To_v1alpha1_PetSetStatus
(
in
*
apps
.
PetSetStatus
,
out
*
PetSetStatus
,
s
conversion
.
Scope
)
error
{
out
.
ObservedGeneration
=
in
.
ObservedGeneration
out
.
Replicas
=
in
t32
(
in
.
Replicas
)
out
.
Replicas
=
in
.
Replicas
return
nil
}
...
...
pkg/controller/petset/fakes.go
View file @
fd47b6d4
...
...
@@ -84,7 +84,7 @@ func newPetSetWithVolumes(replicas int, name string, petMounts []api.VolumeMount
Selector
:
&
unversioned
.
LabelSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
Replicas
:
replicas
,
Replicas
:
int32
(
replicas
)
,
Template
:
api
.
PodTemplateSpec
{
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
...
...
pkg/controller/petset/iterator.go
View file @
fd47b6d4
...
...
@@ -111,7 +111,7 @@ type petSetIterator struct {
// errs is a list because we always want the iterator to drain.
errs
[]
error
// petCount is the number of pets iterated over.
petCount
int
petCount
int
32
}
// Next returns true for as long as there are elements in the underlying queue.
...
...
pkg/controller/petset/pet_set_test.go
View file @
fd47b6d4
...
...
@@ -88,7 +88,7 @@ func scalePetSet(t *testing.T, ps *apps.PetSet, psc *PetSetController, fc *fakeP
}
func
saturatePetSet
(
t
*
testing
.
T
,
ps
*
apps
.
PetSet
,
psc
*
PetSetController
,
fc
*
fakePetClient
)
{
err
:=
scalePetSet
(
t
,
ps
,
psc
,
fc
,
ps
.
Spec
.
Replicas
)
err
:=
scalePetSet
(
t
,
ps
,
psc
,
fc
,
int
(
ps
.
Spec
.
Replicas
)
)
if
err
!=
nil
{
t
.
Errorf
(
"Error scalePetSet: %v"
,
err
)
}
...
...
@@ -302,7 +302,7 @@ func (c *fakeApps) PetSets(namespace string) unversioned.PetSetInterface {
type
fakePetSetClient
struct
{
*
fake
.
FakePetSets
Namespace
string
replicas
int
replicas
int
32
}
func
(
f
*
fakePetSetClient
)
UpdateStatus
(
petSet
*
apps
.
PetSet
)
(
*
apps
.
PetSet
,
error
)
{
...
...
pkg/controller/petset/pet_set_utils.go
View file @
fd47b6d4
...
...
@@ -45,7 +45,7 @@ func (o overlappingPetSets) Less(i, j int) bool {
// updatePetCount attempts to update the Status.Replicas of the given PetSet, with a single GET/PUT retry.
func
updatePetCount
(
psClient
appsclientset
.
PetSetsGetter
,
ps
apps
.
PetSet
,
numPets
int
)
(
updateErr
error
)
{
if
ps
.
Status
.
Replicas
==
numPets
||
psClient
==
nil
{
if
ps
.
Status
.
Replicas
==
int32
(
numPets
)
||
psClient
==
nil
{
return
nil
}
var
getErr
error
...
...
@@ -53,7 +53,7 @@ func updatePetCount(psClient appsclientset.PetSetsGetter, ps apps.PetSet, numPet
glog
.
V
(
4
)
.
Infof
(
fmt
.
Sprintf
(
"Updating replica count for PetSet: %s/%s, "
,
ps
.
Namespace
,
ps
.
Name
)
+
fmt
.
Sprintf
(
"replicas %d->%d (need %d), "
,
ps
.
Status
.
Replicas
,
numPets
,
ps
.
Spec
.
Replicas
))
ps
.
Status
=
apps
.
PetSetStatus
{
Replicas
:
numPets
}
ps
.
Status
=
apps
.
PetSetStatus
{
Replicas
:
int32
(
numPets
)
}
_
,
updateErr
=
psClient
.
PetSets
(
ps
.
Namespace
)
.
UpdateStatus
(
ps
)
if
updateErr
==
nil
||
i
>=
statusUpdateRetries
{
return
updateErr
...
...
pkg/kubectl/scale.go
View file @
fd47b6d4
...
...
@@ -344,7 +344,7 @@ func (scaler *PetSetScaler) ScaleSimple(namespace, name string, preconditions *S
return
""
,
err
}
}
ps
.
Spec
.
Replicas
=
int
(
newSize
)
ps
.
Spec
.
Replicas
=
int
32
(
newSize
)
updatedPetSet
,
err
:=
scaler
.
c
.
PetSets
(
namespace
)
.
Update
(
ps
)
if
err
!=
nil
{
if
errors
.
IsConflict
(
err
)
{
...
...
test/e2e/petset.go
View file @
fd47b6d4
...
...
@@ -573,7 +573,8 @@ func (p *petSetTester) execInPets(ps *apps.PetSet, cmd string) error {
func
(
p
*
petSetTester
)
saturate
(
ps
*
apps
.
PetSet
)
{
// TODO: Watch events and check that creation timestamps don't overlap
for
i
:=
0
;
i
<
ps
.
Spec
.
Replicas
;
i
++
{
var
i
int32
for
i
=
0
;
i
<
ps
.
Spec
.
Replicas
;
i
++
{
framework
.
Logf
(
"Waiting for pet at index "
+
fmt
.
Sprintf
(
"%v"
,
i
+
1
)
+
" to enter Running"
)
p
.
waitForRunning
(
i
+
1
,
ps
)
framework
.
Logf
(
"Marking pet at index "
+
fmt
.
Sprintf
(
"%v"
,
i
)
+
" healthy"
)
...
...
@@ -593,7 +594,7 @@ func (p *petSetTester) deletePetAtIndex(index int, ps *apps.PetSet) {
}
}
func
(
p
*
petSetTester
)
scale
(
ps
*
apps
.
PetSet
,
count
int
)
error
{
func
(
p
*
petSetTester
)
scale
(
ps
*
apps
.
PetSet
,
count
int
32
)
error
{
name
:=
ps
.
Name
ns
:=
ps
.
Namespace
p
.
update
(
ns
,
name
,
func
(
ps
*
apps
.
PetSet
)
{
ps
.
Spec
.
Replicas
=
count
})
...
...
@@ -601,7 +602,7 @@ func (p *petSetTester) scale(ps *apps.PetSet, count int) error {
var
petList
*
api
.
PodList
pollErr
:=
wait
.
PollImmediate
(
petsetPoll
,
petsetTimeout
,
func
()
(
bool
,
error
)
{
petList
=
p
.
getPodList
(
ps
)
if
len
(
petList
.
Items
)
==
count
{
if
int32
(
len
(
petList
.
Items
)
)
==
count
{
return
true
,
nil
}
return
false
,
nil
...
...
@@ -665,15 +666,15 @@ func (p *petSetTester) confirmPetCount(count int, ps *apps.PetSet, timeout time.
}
}
func
(
p
*
petSetTester
)
waitForRunning
(
numPets
int
,
ps
*
apps
.
PetSet
)
{
func
(
p
*
petSetTester
)
waitForRunning
(
numPets
int
32
,
ps
*
apps
.
PetSet
)
{
pollErr
:=
wait
.
PollImmediate
(
petsetPoll
,
petsetTimeout
,
func
()
(
bool
,
error
)
{
podList
:=
p
.
getPodList
(
ps
)
if
len
(
podList
.
Items
)
<
numPets
{
if
int32
(
len
(
podList
.
Items
)
)
<
numPets
{
framework
.
Logf
(
"Found %d pets, waiting for %d"
,
len
(
podList
.
Items
),
numPets
)
return
false
,
nil
}
if
len
(
podList
.
Items
)
>
numPets
{
if
int32
(
len
(
podList
.
Items
)
)
>
numPets
{
return
false
,
fmt
.
Errorf
(
"Too many pods scheduled, expected %d got %d"
,
numPets
,
len
(
podList
.
Items
))
}
for
_
,
p
:=
range
podList
.
Items
{
...
...
@@ -712,7 +713,7 @@ func (p *petSetTester) setHealthy(ps *apps.PetSet) {
}
}
func
(
p
*
petSetTester
)
waitForStatus
(
ps
*
apps
.
PetSet
,
expectedReplicas
int
)
{
func
(
p
*
petSetTester
)
waitForStatus
(
ps
*
apps
.
PetSet
,
expectedReplicas
int
32
)
{
ns
,
name
:=
ps
.
Namespace
,
ps
.
Name
pollErr
:=
wait
.
PollImmediate
(
petsetPoll
,
petsetTimeout
,
func
()
(
bool
,
error
)
{
...
...
@@ -840,7 +841,7 @@ func newPVC(name string) api.PersistentVolumeClaim {
}
}
func
newPetSet
(
name
,
ns
,
governingSvcName
string
,
replicas
int
,
petMounts
[]
api
.
VolumeMount
,
podMounts
[]
api
.
VolumeMount
,
labels
map
[
string
]
string
)
*
apps
.
PetSet
{
func
newPetSet
(
name
,
ns
,
governingSvcName
string
,
replicas
int
32
,
petMounts
[]
api
.
VolumeMount
,
podMounts
[]
api
.
VolumeMount
,
labels
map
[
string
]
string
)
*
apps
.
PetSet
{
mounts
:=
append
(
petMounts
,
podMounts
...
)
claims
:=
[]
api
.
PersistentVolumeClaim
{}
for
_
,
m
:=
range
petMounts
{
...
...
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