mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Remove HostRecord annotation (beta feature)
The annotation has made it to GA so this code should be deleted.
This commit is contained in:
		@@ -28,18 +28,6 @@ import (
 | 
			
		||||
	hashutil "k8s.io/kubernetes/pkg/util/hash"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	// TODO: to be deleted after v1.3 is released
 | 
			
		||||
	// Its value is the json representation of map[string(IP)][HostRecord]
 | 
			
		||||
	// example: '{"10.245.1.6":{"HostName":"my-webserver"}}'
 | 
			
		||||
	PodHostnamesAnnotation = "endpoints.beta.kubernetes.io/hostnames-map"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// TODO: to be deleted after v1.3 is released
 | 
			
		||||
type HostRecord struct {
 | 
			
		||||
	HostName string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RepackSubsets takes a slice of EndpointSubset objects, expands it to the full
 | 
			
		||||
// representation, and then repacks that into the canonical layout.  This
 | 
			
		||||
// ensures that code which operates on these objects can rely on the common
 | 
			
		||||
 
 | 
			
		||||
@@ -28,18 +28,6 @@ import (
 | 
			
		||||
	hashutil "k8s.io/kubernetes/pkg/util/hash"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	// TODO: to be deleted after v1.3 is released
 | 
			
		||||
	// Its value is the json representation of map[string(IP)][HostRecord]
 | 
			
		||||
	// example: '{"10.245.1.6":{"HostName":"my-webserver"}}'
 | 
			
		||||
	PodHostnamesAnnotation = "endpoints.beta.kubernetes.io/hostnames-map"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// TODO: to be deleted after v1.3 is released
 | 
			
		||||
type HostRecord struct {
 | 
			
		||||
	HostName string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RepackSubsets takes a slice of EndpointSubset objects, expands it to the full
 | 
			
		||||
// representation, and then repacks that into the canonical layout.  This
 | 
			
		||||
// ensures that code which operates on these objects can rely on the common
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@ go_library(
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//pkg/api:go_default_library",
 | 
			
		||||
        "//pkg/api/endpoints:go_default_library",
 | 
			
		||||
        "//pkg/api/meta:go_default_library",
 | 
			
		||||
        "//pkg/api/pod:go_default_library",
 | 
			
		||||
        "//pkg/api/resource:go_default_library",
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,6 @@ import (
 | 
			
		||||
 | 
			
		||||
	"github.com/golang/glog"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/endpoints"
 | 
			
		||||
	utilpod "k8s.io/kubernetes/pkg/api/pod"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/resource"
 | 
			
		||||
	apiservice "k8s.io/kubernetes/pkg/api/service"
 | 
			
		||||
@@ -183,13 +182,6 @@ func ValidatePodSpecificAnnotationUpdates(newPod, oldPod *api.Pod, fldPath *fiel
 | 
			
		||||
 | 
			
		||||
func ValidateEndpointsSpecificAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList {
 | 
			
		||||
	allErrs := field.ErrorList{}
 | 
			
		||||
	// TODO: remove this after we EOL the annotation.
 | 
			
		||||
	hostnamesMap, exists := annotations[endpoints.PodHostnamesAnnotation]
 | 
			
		||||
	if exists && !isValidHostnamesMap(hostnamesMap) {
 | 
			
		||||
		allErrs = append(allErrs, field.Invalid(fldPath, endpoints.PodHostnamesAnnotation,
 | 
			
		||||
			`must be a valid json representation of map[string(IP)][HostRecord] e.g. "{"10.245.1.6":{"HostName":"my-webserver"}}"`))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return allErrs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -3725,28 +3717,6 @@ func ValidateLoadBalancerStatus(status *api.LoadBalancerStatus, fldPath *field.P
 | 
			
		||||
	return allErrs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO: remove this after we EOL the annotation that carries it.
 | 
			
		||||
func isValidHostnamesMap(serializedPodHostNames string) bool {
 | 
			
		||||
	if len(serializedPodHostNames) == 0 {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	podHostNames := map[string]endpoints.HostRecord{}
 | 
			
		||||
	err := json.Unmarshal([]byte(serializedPodHostNames), &podHostNames)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for ip, hostRecord := range podHostNames {
 | 
			
		||||
		if len(validation.IsDNS1123Label(hostRecord.HostName)) != 0 {
 | 
			
		||||
			return false
 | 
			
		||||
		}
 | 
			
		||||
		if net.ParseIP(ip) == nil {
 | 
			
		||||
			return false
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func sysctlIntersection(a []api.Sysctl, b []api.Sysctl) []string {
 | 
			
		||||
	lookup := make(map[string]struct{}, len(a))
 | 
			
		||||
	result := []string{}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,8 +22,6 @@ import (
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/v1"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/v1/endpoints"
 | 
			
		||||
@@ -371,7 +369,6 @@ func (e *EndpointController) syncService(key string) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	subsets := []v1.EndpointSubset{}
 | 
			
		||||
	podHostNames := map[string]endpoints.HostRecord{}
 | 
			
		||||
 | 
			
		||||
	var tolerateUnreadyEndpoints bool
 | 
			
		||||
	if v, ok := service.Annotations[TolerateUnreadyEndpointsAnnotation]; ok {
 | 
			
		||||
@@ -424,11 +421,6 @@ func (e *EndpointController) syncService(key string) error {
 | 
			
		||||
			if len(hostname) > 0 &&
 | 
			
		||||
				getSubdomain(pod) == service.Name &&
 | 
			
		||||
				service.Namespace == pod.Namespace {
 | 
			
		||||
				hostRecord := endpoints.HostRecord{
 | 
			
		||||
					HostName: hostname,
 | 
			
		||||
				}
 | 
			
		||||
				// TODO: stop populating podHostNames annotation in 1.4
 | 
			
		||||
				podHostNames[string(pod.Status.PodIP)] = hostRecord
 | 
			
		||||
				epa.Hostname = hostname
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@@ -465,17 +457,6 @@ func (e *EndpointController) syncService(key string) error {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	serializedPodHostNames := ""
 | 
			
		||||
	if len(podHostNames) > 0 {
 | 
			
		||||
		b, err := json.Marshal(podHostNames)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		serializedPodHostNames = string(b)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	newAnnotations := make(map[string]string)
 | 
			
		||||
	newAnnotations[endpoints.PodHostnamesAnnotation] = serializedPodHostNames
 | 
			
		||||
	if reflect.DeepEqual(currentEndpoints.Subsets, subsets) &&
 | 
			
		||||
		reflect.DeepEqual(currentEndpoints.Labels, service.Labels) {
 | 
			
		||||
		glog.V(5).Infof("endpoints are equal for %s/%s, skipping update", service.Namespace, service.Name)
 | 
			
		||||
@@ -487,11 +468,6 @@ func (e *EndpointController) syncService(key string) error {
 | 
			
		||||
	if newEndpoints.Annotations == nil {
 | 
			
		||||
		newEndpoints.Annotations = make(map[string]string)
 | 
			
		||||
	}
 | 
			
		||||
	if len(serializedPodHostNames) == 0 {
 | 
			
		||||
		delete(newEndpoints.Annotations, endpoints.PodHostnamesAnnotation)
 | 
			
		||||
	} else {
 | 
			
		||||
		newEndpoints.Annotations[endpoints.PodHostnamesAnnotation] = serializedPodHostNames
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	glog.V(4).Infof("Update endpoints for %v/%v, ready: %d not ready: %d", service.Namespace, service.Name, readyEps, notReadyEps)
 | 
			
		||||
	createEndpoints := len(currentEndpoints.ResourceVersion) == 0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user