mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
Merge pull request #112258 from Abirdcfly/atomicTypes
go1.19: change some atomic.Value to atomic.Bool
This commit is contained in:
commit
f8bb82c2ac
@ -36,11 +36,11 @@ type mutatingWebhookConfigurationManager struct {
|
|||||||
configuration *atomic.Value
|
configuration *atomic.Value
|
||||||
lister admissionregistrationlisters.MutatingWebhookConfigurationLister
|
lister admissionregistrationlisters.MutatingWebhookConfigurationLister
|
||||||
hasSynced func() bool
|
hasSynced func() bool
|
||||||
// initialConfigurationSynced stores a boolean value, which tracks if
|
// initialConfigurationSynced tracks if
|
||||||
// the existing webhook configs have been synced (honored) by the
|
// the existing webhook configs have been synced (honored) by the
|
||||||
// manager at startup-- the informer has synced and either has no items
|
// manager at startup-- the informer has synced and either has no items
|
||||||
// or has finished executing updateConfiguration() once.
|
// or has finished executing updateConfiguration() once.
|
||||||
initialConfigurationSynced *atomic.Value
|
initialConfigurationSynced *atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ generic.Source = &mutatingWebhookConfigurationManager{}
|
var _ generic.Source = &mutatingWebhookConfigurationManager{}
|
||||||
@ -51,7 +51,7 @@ func NewMutatingWebhookConfigurationManager(f informers.SharedInformerFactory) g
|
|||||||
configuration: &atomic.Value{},
|
configuration: &atomic.Value{},
|
||||||
lister: informer.Lister(),
|
lister: informer.Lister(),
|
||||||
hasSynced: informer.Informer().HasSynced,
|
hasSynced: informer.Informer().HasSynced,
|
||||||
initialConfigurationSynced: &atomic.Value{},
|
initialConfigurationSynced: &atomic.Bool{},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start with an empty list
|
// Start with an empty list
|
||||||
@ -80,7 +80,7 @@ func (m *mutatingWebhookConfigurationManager) HasSynced() bool {
|
|||||||
if !m.hasSynced() {
|
if !m.hasSynced() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if m.initialConfigurationSynced.Load().(bool) {
|
if m.initialConfigurationSynced.Load() {
|
||||||
// the informer has synced and configuration has been updated
|
// the informer has synced and configuration has been updated
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,11 @@ type validatingWebhookConfigurationManager struct {
|
|||||||
configuration *atomic.Value
|
configuration *atomic.Value
|
||||||
lister admissionregistrationlisters.ValidatingWebhookConfigurationLister
|
lister admissionregistrationlisters.ValidatingWebhookConfigurationLister
|
||||||
hasSynced func() bool
|
hasSynced func() bool
|
||||||
// initialConfigurationSynced stores a boolean value, which tracks if
|
// initialConfigurationSynced tracks if
|
||||||
// the existing webhook configs have been synced (honored) by the
|
// the existing webhook configs have been synced (honored) by the
|
||||||
// manager at startup-- the informer has synced and either has no items
|
// manager at startup-- the informer has synced and either has no items
|
||||||
// or has finished executing updateConfiguration() once.
|
// or has finished executing updateConfiguration() once.
|
||||||
initialConfigurationSynced *atomic.Value
|
initialConfigurationSynced *atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ generic.Source = &validatingWebhookConfigurationManager{}
|
var _ generic.Source = &validatingWebhookConfigurationManager{}
|
||||||
@ -51,7 +51,7 @@ func NewValidatingWebhookConfigurationManager(f informers.SharedInformerFactory)
|
|||||||
configuration: &atomic.Value{},
|
configuration: &atomic.Value{},
|
||||||
lister: informer.Lister(),
|
lister: informer.Lister(),
|
||||||
hasSynced: informer.Informer().HasSynced,
|
hasSynced: informer.Informer().HasSynced,
|
||||||
initialConfigurationSynced: &atomic.Value{},
|
initialConfigurationSynced: &atomic.Bool{},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start with an empty list
|
// Start with an empty list
|
||||||
@ -80,7 +80,7 @@ func (v *validatingWebhookConfigurationManager) HasSynced() bool {
|
|||||||
if !v.hasSynced() {
|
if !v.hasSynced() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if v.initialConfigurationSynced.Load().(bool) {
|
if v.initialConfigurationSynced.Load() {
|
||||||
// the informer has synced and configuration has been updated
|
// the informer has synced and configuration has been updated
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -52,10 +52,10 @@ func ListerFuncForResourceFunc(f InformerForResourceFunc) quota.ListerForResourc
|
|||||||
|
|
||||||
// cachedHasSynced returns a function that calls hasSynced() until it returns true once, then returns true
|
// cachedHasSynced returns a function that calls hasSynced() until it returns true once, then returns true
|
||||||
func cachedHasSynced(hasSynced func() bool) func() bool {
|
func cachedHasSynced(hasSynced func() bool) func() bool {
|
||||||
cache := &atomic.Value{}
|
cache := &atomic.Bool{}
|
||||||
cache.Store(false)
|
cache.Store(false)
|
||||||
return func() bool {
|
return func() bool {
|
||||||
if cache.Load().(bool) {
|
if cache.Load() {
|
||||||
// short-circuit if already synced
|
// short-circuit if already synced
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ var _ Manager = &defaultManager{}
|
|||||||
|
|
||||||
// defaultManager indicates if an apiserver has completed reporting its storage versions.
|
// defaultManager indicates if an apiserver has completed reporting its storage versions.
|
||||||
type defaultManager struct {
|
type defaultManager struct {
|
||||||
completed atomic.Value
|
completed atomic.Bool
|
||||||
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
// managedResourceInfos records the ResourceInfos whose StorageVersions will get updated in the next
|
// managedResourceInfos records the ResourceInfos whose StorageVersions will get updated in the next
|
||||||
@ -268,7 +268,7 @@ func (s *defaultManager) setComplete() {
|
|||||||
|
|
||||||
// Completed returns if updating StorageVersions has completed.
|
// Completed returns if updating StorageVersions has completed.
|
||||||
func (s *defaultManager) Completed() bool {
|
func (s *defaultManager) Completed() bool {
|
||||||
return s.completed.Load().(bool)
|
return s.completed.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodableVersions(directlyDecodableVersions []schema.GroupVersion, e runtime.EquivalentResourceRegistry, gr schema.GroupResource) []string {
|
func decodableVersions(directlyDecodableVersions []schema.GroupVersion, e runtime.EquivalentResourceRegistry, gr schema.GroupResource) []string {
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
showHiddenOnce sync.Once
|
showHiddenOnce sync.Once
|
||||||
disabledMetricsLock sync.RWMutex
|
disabledMetricsLock sync.RWMutex
|
||||||
showHidden atomic.Value
|
showHidden atomic.Bool
|
||||||
registries []*kubeRegistry // stores all registries created by NewKubeRegistry()
|
registries []*kubeRegistry // stores all registries created by NewKubeRegistry()
|
||||||
registriesLock sync.RWMutex
|
registriesLock sync.RWMutex
|
||||||
disabledMetrics = map[string]struct{}{}
|
disabledMetrics = map[string]struct{}{}
|
||||||
@ -87,7 +87,7 @@ func SetShowHidden() {
|
|||||||
// is enabled. While the primary usecase for this is internal (to determine
|
// is enabled. While the primary usecase for this is internal (to determine
|
||||||
// registration behavior) this can also be used to introspect
|
// registration behavior) this can also be used to introspect
|
||||||
func ShouldShowHidden() bool {
|
func ShouldShowHidden() bool {
|
||||||
return showHidden.Load() != nil && showHidden.Load().(bool)
|
return showHidden.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registerable is an interface for a collector metric which we
|
// Registerable is an interface for a collector metric which we
|
||||||
|
Loading…
Reference in New Issue
Block a user