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
220cfdff
Commit
220cfdff
authored
Jan 24, 2017
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize secret manager to refresh secrets from apiserver cache
parent
82a5cab1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
2 deletions
+42
-2
BUILD
pkg/kubelet/secret/BUILD
+1
-0
secret_manager.go
pkg/kubelet/secret/secret_manager.go
+9
-1
BUILD
pkg/kubelet/util/BUILD
+5
-1
util.go
pkg/kubelet/util/util.go
+27
-0
No files found.
pkg/kubelet/secret/BUILD
View file @
220cfdff
...
@@ -32,6 +32,7 @@ go_library(
...
@@ -32,6 +32,7 @@ go_library(
deps = [
deps = [
"//pkg/api/v1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/kubelet/util:go_default_library",
"//pkg/storage/etcd:go_default_library",
"//pkg/storage/etcd:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
...
...
pkg/kubelet/secret/secret_manager.go
View file @
220cfdff
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/kubelet/util"
storageetcd
"k8s.io/kubernetes/pkg/storage/etcd"
storageetcd
"k8s.io/kubernetes/pkg/storage/etcd"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
...
@@ -169,7 +170,14 @@ func (s *secretStore) Get(namespace, name string) (*v1.Secret, error) {
...
@@ -169,7 +170,14 @@ func (s *secretStore) Get(namespace, name string) (*v1.Secret, error) {
data
.
Lock
()
data
.
Lock
()
defer
data
.
Unlock
()
defer
data
.
Unlock
()
if
data
.
err
!=
nil
||
!
s
.
clock
.
Now
()
.
Before
(
data
.
lastUpdateTime
.
Add
(
s
.
ttl
))
{
if
data
.
err
!=
nil
||
!
s
.
clock
.
Now
()
.
Before
(
data
.
lastUpdateTime
.
Add
(
s
.
ttl
))
{
secret
,
err
:=
s
.
kubeClient
.
Core
()
.
Secrets
(
namespace
)
.
Get
(
name
,
metav1
.
GetOptions
{})
opts
:=
metav1
.
GetOptions
{}
if
data
.
secret
!=
nil
&&
data
.
err
==
nil
{
// This is just a periodic refresh of a secret we successfully fetched previously.
// In this case, server data from apiserver cache to reduce the load on both
// etcd and apiserver (the cache is eventually consistent).
util
.
FromApiserverCache
(
&
opts
)
}
secret
,
err
:=
s
.
kubeClient
.
Core
()
.
Secrets
(
namespace
)
.
Get
(
name
,
opts
)
// Update state, unless we got error different than "not-found".
// Update state, unless we got error different than "not-found".
if
err
==
nil
||
apierrors
.
IsNotFound
(
err
)
{
if
err
==
nil
||
apierrors
.
IsNotFound
(
err
)
{
// Ignore the update to the older version of a secret.
// Ignore the update to the older version of a secret.
...
...
pkg/kubelet/util/BUILD
View file @
220cfdff
...
@@ -9,8 +9,12 @@ load(
...
@@ -9,8 +9,12 @@ load(
go_library(
go_library(
name = "go_default_library",
name = "go_default_library",
srcs = ["doc.go"],
srcs = [
"doc.go",
"util.go",
],
tags = ["automanaged"],
tags = ["automanaged"],
deps = ["//vendor:k8s.io/apimachinery/pkg/apis/meta/v1"],
)
)
filegroup(
filegroup(
...
...
pkg/kubelet/util/util.go
0 → 100644
View file @
220cfdff
/*
Copyright 2017 The Kubernetes Authors.
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
util
import
(
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
// FromApiserverCache modifies <opts> so that the GET request will
// be served from apiserver cache instead of from etcd.
func
FromApiserverCache
(
opts
*
metav1
.
GetOptions
)
{
opts
.
ResourceVersion
=
"0"
}
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