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
77024470
Commit
77024470
authored
Mar 16, 2017
by
Marcin Wielgus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix federated config map unit tests
parent
b617cabf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
19 deletions
+31
-19
configmap_controller.go
...g/federation-controller/configmap/configmap_controller.go
+19
-14
configmap_controller_test.go
...eration-controller/configmap/configmap_controller_test.go
+12
-5
No files found.
federation/pkg/federation-controller/configmap/configmap_controller.go
View file @
77024470
...
...
@@ -323,13 +323,18 @@ func (configmapcontroller *ConfigMapController) reconcileConfigMap(configmap typ
glog
.
V
(
8
)
.
Infof
(
"Skipping not federated config map: %s"
,
key
)
return
}
baseConfigMap
:=
baseConfigMapObj
.
(
*
apiv1
.
ConfigMap
)
obj
,
err
:=
api
.
Scheme
.
DeepCopy
(
baseConfigMapObj
)
configMap
,
ok
:=
obj
.
(
*
apiv1
.
ConfigMap
)
if
err
!=
nil
||
!
ok
{
glog
.
Errorf
(
"Error in retrieving obj from store: %v, %v"
,
ok
,
err
)
return
}
// Check if deletion has been requested.
if
baseC
onfigMap
.
DeletionTimestamp
!=
nil
{
if
err
:=
configmapcontroller
.
delete
(
baseC
onfigMap
);
err
!=
nil
{
if
c
onfigMap
.
DeletionTimestamp
!=
nil
{
if
err
:=
configmapcontroller
.
delete
(
c
onfigMap
);
err
!=
nil
{
glog
.
Errorf
(
"Failed to delete %s: %v"
,
configmap
,
err
)
configmapcontroller
.
eventRecorder
.
Eventf
(
baseC
onfigMap
,
api
.
EventTypeNormal
,
"DeleteFailed"
,
configmapcontroller
.
eventRecorder
.
Eventf
(
c
onfigMap
,
api
.
EventTypeNormal
,
"DeleteFailed"
,
"ConfigMap delete failed: %v"
,
err
)
configmapcontroller
.
deliverConfigMap
(
configmap
,
0
,
true
)
}
...
...
@@ -337,18 +342,18 @@ func (configmapcontroller *ConfigMapController) reconcileConfigMap(configmap typ
}
glog
.
V
(
3
)
.
Infof
(
"Ensuring delete object from underlying clusters finalizer for configmap: %s"
,
baseC
onfigMap
.
Name
)
c
onfigMap
.
Name
)
// Add the required finalizers before creating a configmap in underlying clusters.
updatedConfigMapObj
,
err
:=
configmapcontroller
.
deletionHelper
.
EnsureFinalizers
(
baseC
onfigMap
)
updatedConfigMapObj
,
err
:=
configmapcontroller
.
deletionHelper
.
EnsureFinalizers
(
c
onfigMap
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to ensure delete object from underlying clusters finalizer in configmap %s: %v"
,
baseC
onfigMap
.
Name
,
err
)
c
onfigMap
.
Name
,
err
)
configmapcontroller
.
deliverConfigMap
(
configmap
,
0
,
false
)
return
}
baseC
onfigMap
=
updatedConfigMapObj
.
(
*
apiv1
.
ConfigMap
)
c
onfigMap
=
updatedConfigMapObj
.
(
*
apiv1
.
ConfigMap
)
glog
.
V
(
3
)
.
Infof
(
"Syncing configmap %s in underlying clusters"
,
baseC
onfigMap
.
Name
)
glog
.
V
(
3
)
.
Infof
(
"Syncing configmap %s in underlying clusters"
,
c
onfigMap
.
Name
)
clusters
,
err
:=
configmapcontroller
.
configmapFederatedInformer
.
GetReadyClusters
()
if
err
!=
nil
{
...
...
@@ -368,12 +373,12 @@ func (configmapcontroller *ConfigMapController) reconcileConfigMap(configmap typ
// Do not modify data.
desiredConfigMap
:=
&
apiv1
.
ConfigMap
{
ObjectMeta
:
util
.
DeepCopyRelevantObjectMeta
(
baseC
onfigMap
.
ObjectMeta
),
Data
:
baseC
onfigMap
.
Data
,
ObjectMeta
:
util
.
DeepCopyRelevantObjectMeta
(
c
onfigMap
.
ObjectMeta
),
Data
:
c
onfigMap
.
Data
,
}
if
!
found
{
configmapcontroller
.
eventRecorder
.
Eventf
(
baseC
onfigMap
,
api
.
EventTypeNormal
,
"CreateInCluster"
,
configmapcontroller
.
eventRecorder
.
Eventf
(
c
onfigMap
,
api
.
EventTypeNormal
,
"CreateInCluster"
,
"Creating configmap in cluster %s"
,
cluster
.
Name
)
operations
=
append
(
operations
,
util
.
FederatedOperation
{
...
...
@@ -386,7 +391,7 @@ func (configmapcontroller *ConfigMapController) reconcileConfigMap(configmap typ
// Update existing configmap, if needed.
if
!
util
.
ConfigMapEquivalent
(
desiredConfigMap
,
clusterConfigMap
)
{
configmapcontroller
.
eventRecorder
.
Eventf
(
baseC
onfigMap
,
api
.
EventTypeNormal
,
"UpdateInCluster"
,
configmapcontroller
.
eventRecorder
.
Eventf
(
c
onfigMap
,
api
.
EventTypeNormal
,
"UpdateInCluster"
,
"Updating configmap in cluster %s"
,
cluster
.
Name
)
operations
=
append
(
operations
,
util
.
FederatedOperation
{
Type
:
util
.
OperationTypeUpdate
,
...
...
@@ -404,7 +409,7 @@ func (configmapcontroller *ConfigMapController) reconcileConfigMap(configmap typ
}
err
=
configmapcontroller
.
federatedUpdater
.
UpdateWithOnError
(
operations
,
configmapcontroller
.
updateTimeout
,
func
(
op
util
.
FederatedOperation
,
operror
error
)
{
configmapcontroller
.
eventRecorder
.
Eventf
(
baseC
onfigMap
,
api
.
EventTypeNormal
,
"UpdateInClusterFailed"
,
configmapcontroller
.
eventRecorder
.
Eventf
(
c
onfigMap
,
api
.
EventTypeNormal
,
"UpdateInClusterFailed"
,
"ConfigMap update in cluster %s failed: %v"
,
op
.
ClusterName
,
operror
)
})
...
...
federation/pkg/federation-controller/configmap/configmap_controller_test.go
View file @
77024470
...
...
@@ -143,11 +143,18 @@ func TestConfigMapController(t *testing.T) {
}
configmapWatch
.
Modify
(
configmap1
)
updatedConfigMap
=
GetConfigMapFromChan
(
cluster1UpdateChan
)
assert
.
NotNil
(
t
,
updatedConfigMap
)
assert
.
Equal
(
t
,
configmap1
.
Name
,
updatedConfigMap
.
Name
)
assert
.
Equal
(
t
,
configmap1
.
Namespace
,
updatedConfigMap
.
Namespace
)
assert
.
True
(
t
,
util
.
ConfigMapEquivalent
(
configmap1
,
updatedConfigMap
))
for
{
updatedConfigMap
:=
GetConfigMapFromChan
(
cluster1UpdateChan
)
assert
.
NotNil
(
t
,
updatedConfigMap
)
if
updatedConfigMap
==
nil
{
break
}
assert
.
Equal
(
t
,
configmap1
.
Name
,
updatedConfigMap
.
Name
)
assert
.
Equal
(
t
,
configmap1
.
Namespace
,
updatedConfigMap
.
Namespace
)
if
util
.
ConfigMapEquivalent
(
configmap1
,
updatedConfigMap
)
{
break
}
}
// Test add cluster
clusterWatch
.
Add
(
cluster2
)
...
...
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