...

Source file src/k8s.io/kubernetes/pkg/kubelet/util/manager/manager.go

Documentation: k8s.io/kubernetes/pkg/kubelet/util/manager

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package manager
    18  
    19  import (
    20  	v1 "k8s.io/api/core/v1"
    21  	"k8s.io/apimachinery/pkg/runtime"
    22  	"k8s.io/apimachinery/pkg/types"
    23  )
    24  
    25  // Manager is the interface for registering and unregistering
    26  // objects referenced by pods in the underlying cache and
    27  // extracting those from that cache if needed.
    28  type Manager interface {
    29  	// Get object by its namespace and name.
    30  	GetObject(namespace, name string) (runtime.Object, error)
    31  
    32  	// WARNING: Register/UnregisterPod functions should be efficient,
    33  	// i.e. should not block on network operations.
    34  
    35  	// RegisterPod registers all objects referenced from a given pod.
    36  	//
    37  	// NOTE: All implementations of RegisterPod should be idempotent.
    38  	RegisterPod(pod *v1.Pod)
    39  
    40  	// UnregisterPod unregisters objects referenced from a given pod that are not
    41  	// used by any other registered pod.
    42  	//
    43  	// NOTE: All implementations of UnregisterPod should be idempotent.
    44  	UnregisterPod(pod *v1.Pod)
    45  }
    46  
    47  // Store is the interface for a object cache that
    48  // can be used by cacheBasedManager.
    49  type Store interface {
    50  	// AddReference adds a reference from referencedFrom to the object to the store.
    51  	// Note that multiple additions to the store has to be allowed
    52  	// in the implementations and effectively treated as refcounted.
    53  	AddReference(namespace, name string, referencedFrom types.UID)
    54  	// DeleteReference deletes a reference from referencedFrom to the object from the store.
    55  	// Note that object should be deleted only when there was a
    56  	// corresponding Delete call for each of Add calls (effectively
    57  	// when refcount of every referenceFrom was reduced to zero).
    58  	DeleteReference(namespace, name string, referencedFrom types.UID)
    59  	// Get an object from a store.
    60  	Get(namespace, name string) (runtime.Object, error)
    61  }
    62  

View as plain text