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
119ff39f
Commit
119ff39f
authored
Jan 17, 2016
by
Madhusudan.C.S
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement replica set controller.
parent
1dc6e88a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
0 deletions
+97
-0
doc.go
pkg/controller/replicaset/doc.go
+19
-0
replica_set.go
pkg/controller/replicaset/replica_set.go
+0
-0
replica_set_test.go
pkg/controller/replicaset/replica_set_test.go
+0
-0
replica_set_utils.go
pkg/controller/replicaset/replica_set_utils.go
+72
-0
replication_controller.go
pkg/controller/replication/replication_controller.go
+2
-0
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+2
-0
replication_controller_utils.go
pkg/controller/replication/replication_controller_utils.go
+2
-0
No files found.
pkg/controller/replicaset/doc.go
0 → 100644
View file @
119ff39f
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package replicaset contains logic for watching and synchronizing
// ReplicaSets.
package
replicaset
pkg/controller/replicaset/replica_set.go
0 → 100644
View file @
119ff39f
This diff is collapsed.
Click to expand it.
pkg/controller/replicaset/replica_set_test.go
0 → 100644
View file @
119ff39f
This diff is collapsed.
Click to expand it.
pkg/controller/replicaset/replica_set_utils.go
0 → 100644
View file @
119ff39f
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// If you make changes to this file, you should also make the corresponding change in ReplicationController.
package
replicaset
import
(
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/apis/extensions"
client
"k8s.io/kubernetes/pkg/client/unversioned"
)
// updateReplicaCount attempts to update the Status.Replicas of the given ReplicaSet, with a single GET/PUT retry.
func
updateReplicaCount
(
rsClient
client
.
ReplicaSetInterface
,
rs
extensions
.
ReplicaSet
,
numReplicas
int
)
(
updateErr
error
)
{
// This is the steady state. It happens when the ReplicaSet doesn't have any expectations, since
// we do a periodic relist every 30s. If the generations differ but the replicas are
// the same, a caller might've resized to the same replica count.
if
rs
.
Status
.
Replicas
==
numReplicas
&&
rs
.
Generation
==
rs
.
Status
.
ObservedGeneration
{
return
nil
}
// Save the generation number we acted on, otherwise we might wrongfully indicate
// that we've seen a spec update when we retry.
// TODO: This can clobber an update if we allow multiple agents to write to the
// same status.
generation
:=
rs
.
Generation
var
getErr
error
for
i
,
rs
:=
0
,
&
rs
;
;
i
++
{
glog
.
V
(
4
)
.
Infof
(
"Updating replica count for ReplicaSet: %v, %d->%d (need %d), sequence No: %v->%v"
,
rs
.
Name
,
rs
.
Status
.
Replicas
,
numReplicas
,
rs
.
Spec
.
Replicas
,
rs
.
Status
.
ObservedGeneration
,
generation
)
rs
.
Status
=
extensions
.
ReplicaSetStatus
{
Replicas
:
numReplicas
,
ObservedGeneration
:
generation
}
_
,
updateErr
=
rsClient
.
UpdateStatus
(
rs
)
if
updateErr
==
nil
||
i
>=
statusUpdateRetries
{
return
updateErr
}
// Update the ReplicaSet with the latest resource version for the next poll
if
rs
,
getErr
=
rsClient
.
Get
(
rs
.
Name
);
getErr
!=
nil
{
// If the GET fails we can't trust status.Replicas anymore. This error
// is bound to be more interesting than the update failure.
return
getErr
}
}
}
// overlappingReplicaSets sorts a list of ReplicaSets by creation timestamp, using their names as a tie breaker.
type
overlappingReplicaSets
[]
extensions
.
ReplicaSet
func
(
o
overlappingReplicaSets
)
Len
()
int
{
return
len
(
o
)
}
func
(
o
overlappingReplicaSets
)
Swap
(
i
,
j
int
)
{
o
[
i
],
o
[
j
]
=
o
[
j
],
o
[
i
]
}
func
(
o
overlappingReplicaSets
)
Less
(
i
,
j
int
)
bool
{
if
o
[
i
]
.
CreationTimestamp
.
Equal
(
o
[
j
]
.
CreationTimestamp
)
{
return
o
[
i
]
.
Name
<
o
[
j
]
.
Name
}
return
o
[
i
]
.
CreationTimestamp
.
Before
(
o
[
j
]
.
CreationTimestamp
)
}
pkg/controller/replication/replication_controller.go
View file @
119ff39f
...
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
...
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
// If you make changes to this file, you should also make the corresponding change in ReplicaSet.
package
replication
package
replication
import
(
import
(
...
...
pkg/controller/replication/replication_controller_test.go
View file @
119ff39f
...
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
...
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
// If you make changes to this file, you should also make the corresponding change in ReplicaSet.
package
replication
package
replication
import
(
import
(
...
...
pkg/controller/replication/replication_controller_utils.go
View file @
119ff39f
...
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
...
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
// If you make changes to this file, you should also make the corresponding change in ReplicaSet.
package
replication
package
replication
import
(
import
(
...
...
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