forked from LaconicNetwork/kompose
Upgrade OpenShift and its dependencies.
OpenShift version 1.4.0-alpha.0
This commit is contained in:
-190
@@ -1,190 +0,0 @@
|
||||
// +build !ignore_autogenerated_openshift
|
||||
|
||||
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
api "k8s.io/kubernetes/pkg/api"
|
||||
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
|
||||
conversion "k8s.io/kubernetes/pkg/conversion"
|
||||
intstr "k8s.io/kubernetes/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if err := api.Scheme.AddGeneratedDeepCopyFuncs(
|
||||
DeepCopy_api_Route,
|
||||
DeepCopy_api_RouteIngress,
|
||||
DeepCopy_api_RouteIngressCondition,
|
||||
DeepCopy_api_RouteList,
|
||||
DeepCopy_api_RoutePort,
|
||||
DeepCopy_api_RouteSpec,
|
||||
DeepCopy_api_RouteStatus,
|
||||
DeepCopy_api_RouteTargetReference,
|
||||
DeepCopy_api_RouterShard,
|
||||
DeepCopy_api_TLSConfig,
|
||||
); err != nil {
|
||||
// if one of the deep copy functions is malformed, detect it immediately.
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_Route(in Route, out *Route, c *conversion.Cloner) error {
|
||||
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := api.DeepCopy_api_ObjectMeta(in.ObjectMeta, &out.ObjectMeta, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := DeepCopy_api_RouteSpec(in.Spec, &out.Spec, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := DeepCopy_api_RouteStatus(in.Status, &out.Status, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteIngress(in RouteIngress, out *RouteIngress, c *conversion.Cloner) error {
|
||||
out.Host = in.Host
|
||||
out.RouterName = in.RouterName
|
||||
if in.Conditions != nil {
|
||||
in, out := in.Conditions, &out.Conditions
|
||||
*out = make([]RouteIngressCondition, len(in))
|
||||
for i := range in {
|
||||
if err := DeepCopy_api_RouteIngressCondition(in[i], &(*out)[i], c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Conditions = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteIngressCondition(in RouteIngressCondition, out *RouteIngressCondition, c *conversion.Cloner) error {
|
||||
out.Type = in.Type
|
||||
out.Status = in.Status
|
||||
out.Reason = in.Reason
|
||||
out.Message = in.Message
|
||||
if in.LastTransitionTime != nil {
|
||||
in, out := in.LastTransitionTime, &out.LastTransitionTime
|
||||
*out = new(unversioned.Time)
|
||||
if err := unversioned.DeepCopy_unversioned_Time(*in, *out, c); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.LastTransitionTime = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteList(in RouteList, out *RouteList, c *conversion.Cloner) error {
|
||||
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := unversioned.DeepCopy_unversioned_ListMeta(in.ListMeta, &out.ListMeta, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.Items != nil {
|
||||
in, out := in.Items, &out.Items
|
||||
*out = make([]Route, len(in))
|
||||
for i := range in {
|
||||
if err := DeepCopy_api_Route(in[i], &(*out)[i], c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_RoutePort(in RoutePort, out *RoutePort, c *conversion.Cloner) error {
|
||||
if err := intstr.DeepCopy_intstr_IntOrString(in.TargetPort, &out.TargetPort, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteSpec(in RouteSpec, out *RouteSpec, c *conversion.Cloner) error {
|
||||
out.Host = in.Host
|
||||
out.Path = in.Path
|
||||
if err := DeepCopy_api_RouteTargetReference(in.To, &out.To, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.AlternateBackends != nil {
|
||||
in, out := in.AlternateBackends, &out.AlternateBackends
|
||||
*out = make([]RouteTargetReference, len(in))
|
||||
for i := range in {
|
||||
if err := DeepCopy_api_RouteTargetReference(in[i], &(*out)[i], c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.AlternateBackends = nil
|
||||
}
|
||||
if in.Port != nil {
|
||||
in, out := in.Port, &out.Port
|
||||
*out = new(RoutePort)
|
||||
if err := DeepCopy_api_RoutePort(*in, *out, c); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Port = nil
|
||||
}
|
||||
if in.TLS != nil {
|
||||
in, out := in.TLS, &out.TLS
|
||||
*out = new(TLSConfig)
|
||||
if err := DeepCopy_api_TLSConfig(*in, *out, c); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.TLS = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteStatus(in RouteStatus, out *RouteStatus, c *conversion.Cloner) error {
|
||||
if in.Ingress != nil {
|
||||
in, out := in.Ingress, &out.Ingress
|
||||
*out = make([]RouteIngress, len(in))
|
||||
for i := range in {
|
||||
if err := DeepCopy_api_RouteIngress(in[i], &(*out)[i], c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Ingress = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteTargetReference(in RouteTargetReference, out *RouteTargetReference, c *conversion.Cloner) error {
|
||||
out.Kind = in.Kind
|
||||
out.Name = in.Name
|
||||
if in.Weight != nil {
|
||||
in, out := in.Weight, &out.Weight
|
||||
*out = new(int32)
|
||||
**out = *in
|
||||
} else {
|
||||
out.Weight = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouterShard(in RouterShard, out *RouterShard, c *conversion.Cloner) error {
|
||||
out.ShardName = in.ShardName
|
||||
out.DNSSuffix = in.DNSSuffix
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepCopy_api_TLSConfig(in TLSConfig, out *TLSConfig, c *conversion.Cloner) error {
|
||||
out.Termination = in.Termination
|
||||
out.Certificate = in.Certificate
|
||||
out.Key = in.Key
|
||||
out.CACertificate = in.CACertificate
|
||||
out.DestinationCACertificate = in.DestinationCACertificate
|
||||
out.InsecureEdgeTerminationPolicy = in.InsecureEdgeTerminationPolicy
|
||||
return nil
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
|
||||
// Package api is the internal version of the API.
|
||||
package api
|
||||
+7
-5
@@ -6,6 +6,7 @@ import (
|
||||
)
|
||||
|
||||
const GroupName = ""
|
||||
const FutureGroupName = "route.openshift.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
||||
@@ -20,17 +21,18 @@ func Resource(resource string) unversioned.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
func AddToScheme(scheme *runtime.Scheme) {
|
||||
// Add the API to Scheme.
|
||||
addKnownTypes(scheme)
|
||||
}
|
||||
var (
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to api.Scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) {
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&Route{},
|
||||
&RouteList{},
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (obj *Route) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
// +build !ignore_autogenerated_openshift
|
||||
|
||||
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
pkg_api "k8s.io/kubernetes/pkg/api"
|
||||
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
|
||||
conversion "k8s.io/kubernetes/pkg/conversion"
|
||||
runtime "k8s.io/kubernetes/pkg/runtime"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(RegisterDeepCopies)
|
||||
}
|
||||
|
||||
// RegisterDeepCopies adds deep-copy functions to the given scheme. Public
|
||||
// to allow building arbitrary schemes.
|
||||
func RegisterDeepCopies(scheme *runtime.Scheme) error {
|
||||
return scheme.AddGeneratedDeepCopyFuncs(
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_Route, InType: reflect.TypeOf(&Route{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_RouteIngress, InType: reflect.TypeOf(&RouteIngress{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_RouteIngressCondition, InType: reflect.TypeOf(&RouteIngressCondition{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_RouteList, InType: reflect.TypeOf(&RouteList{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_RoutePort, InType: reflect.TypeOf(&RoutePort{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_RouteSpec, InType: reflect.TypeOf(&RouteSpec{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_RouteStatus, InType: reflect.TypeOf(&RouteStatus{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_RouteTargetReference, InType: reflect.TypeOf(&RouteTargetReference{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_RouterShard, InType: reflect.TypeOf(&RouterShard{})},
|
||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_TLSConfig, InType: reflect.TypeOf(&TLSConfig{})},
|
||||
)
|
||||
}
|
||||
|
||||
func DeepCopy_api_Route(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*Route)
|
||||
out := out.(*Route)
|
||||
out.TypeMeta = in.TypeMeta
|
||||
if err := pkg_api.DeepCopy_api_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := DeepCopy_api_RouteSpec(&in.Spec, &out.Spec, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := DeepCopy_api_RouteStatus(&in.Status, &out.Status, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteIngress(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*RouteIngress)
|
||||
out := out.(*RouteIngress)
|
||||
out.Host = in.Host
|
||||
out.RouterName = in.RouterName
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]RouteIngressCondition, len(*in))
|
||||
for i := range *in {
|
||||
if err := DeepCopy_api_RouteIngressCondition(&(*in)[i], &(*out)[i], c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Conditions = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteIngressCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*RouteIngressCondition)
|
||||
out := out.(*RouteIngressCondition)
|
||||
out.Type = in.Type
|
||||
out.Status = in.Status
|
||||
out.Reason = in.Reason
|
||||
out.Message = in.Message
|
||||
if in.LastTransitionTime != nil {
|
||||
in, out := &in.LastTransitionTime, &out.LastTransitionTime
|
||||
*out = new(unversioned.Time)
|
||||
**out = (*in).DeepCopy()
|
||||
} else {
|
||||
out.LastTransitionTime = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteList(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*RouteList)
|
||||
out := out.(*RouteList)
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Route, len(*in))
|
||||
for i := range *in {
|
||||
if err := DeepCopy_api_Route(&(*in)[i], &(*out)[i], c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_RoutePort(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*RoutePort)
|
||||
out := out.(*RoutePort)
|
||||
out.TargetPort = in.TargetPort
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*RouteSpec)
|
||||
out := out.(*RouteSpec)
|
||||
out.Host = in.Host
|
||||
out.Path = in.Path
|
||||
if err := DeepCopy_api_RouteTargetReference(&in.To, &out.To, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.AlternateBackends != nil {
|
||||
in, out := &in.AlternateBackends, &out.AlternateBackends
|
||||
*out = make([]RouteTargetReference, len(*in))
|
||||
for i := range *in {
|
||||
if err := DeepCopy_api_RouteTargetReference(&(*in)[i], &(*out)[i], c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.AlternateBackends = nil
|
||||
}
|
||||
if in.Port != nil {
|
||||
in, out := &in.Port, &out.Port
|
||||
*out = new(RoutePort)
|
||||
**out = **in
|
||||
} else {
|
||||
out.Port = nil
|
||||
}
|
||||
if in.TLS != nil {
|
||||
in, out := &in.TLS, &out.TLS
|
||||
*out = new(TLSConfig)
|
||||
**out = **in
|
||||
} else {
|
||||
out.TLS = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*RouteStatus)
|
||||
out := out.(*RouteStatus)
|
||||
if in.Ingress != nil {
|
||||
in, out := &in.Ingress, &out.Ingress
|
||||
*out = make([]RouteIngress, len(*in))
|
||||
for i := range *in {
|
||||
if err := DeepCopy_api_RouteIngress(&(*in)[i], &(*out)[i], c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Ingress = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouteTargetReference(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*RouteTargetReference)
|
||||
out := out.(*RouteTargetReference)
|
||||
out.Kind = in.Kind
|
||||
out.Name = in.Name
|
||||
if in.Weight != nil {
|
||||
in, out := &in.Weight, &out.Weight
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
} else {
|
||||
out.Weight = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_RouterShard(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*RouterShard)
|
||||
out := out.(*RouterShard)
|
||||
out.ShardName = in.ShardName
|
||||
out.DNSSuffix = in.DNSSuffix
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func DeepCopy_api_TLSConfig(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
{
|
||||
in := in.(*TLSConfig)
|
||||
out := out.(*TLSConfig)
|
||||
out.Termination = in.Termination
|
||||
out.Certificate = in.Certificate
|
||||
out.Key = in.Key
|
||||
out.CACertificate = in.CACertificate
|
||||
out.DestinationCACertificate = in.DestinationCACertificate
|
||||
out.InsecureEdgeTerminationPolicy = in.InsecureEdgeTerminationPolicy
|
||||
return nil
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// Package generator implements the Generator interface for routes
|
||||
package generator
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
kapi "k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util/intstr"
|
||||
|
||||
"github.com/openshift/origin/pkg/route/api"
|
||||
)
|
||||
|
||||
// RouteGenerator generates routes from a given set of parameters
|
||||
type RouteGenerator struct{}
|
||||
|
||||
// RouteGenerator implements the kubectl.Generator interface for routes
|
||||
var _ kubectl.Generator = RouteGenerator{}
|
||||
|
||||
// ParamNames returns the parameters required for generating a route
|
||||
func (RouteGenerator) ParamNames() []kubectl.GeneratorParam {
|
||||
return []kubectl.GeneratorParam{
|
||||
{Name: "labels", Required: false},
|
||||
{Name: "default-name", Required: true},
|
||||
{Name: "port", Required: false},
|
||||
{Name: "name", Required: false},
|
||||
{Name: "hostname", Required: false},
|
||||
{Name: "path", Required: false},
|
||||
}
|
||||
}
|
||||
|
||||
// Generate accepts a set of parameters and maps them into a new route
|
||||
func (RouteGenerator) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
|
||||
var (
|
||||
labels map[string]string
|
||||
err error
|
||||
)
|
||||
|
||||
params := map[string]string{}
|
||||
for key, value := range genericParams {
|
||||
strVal, isString := value.(string)
|
||||
if !isString {
|
||||
return nil, fmt.Errorf("expected string, saw %v for '%s'", value, key)
|
||||
}
|
||||
params[key] = strVal
|
||||
}
|
||||
|
||||
labelString, found := params["labels"]
|
||||
if found && len(labelString) > 0 {
|
||||
labels, err = kubectl.ParseLabels(labelString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
name, found := params["name"]
|
||||
if !found || len(name) == 0 {
|
||||
name, found = params["default-name"]
|
||||
if !found || len(name) == 0 {
|
||||
return nil, fmt.Errorf("'name' is a required parameter.")
|
||||
}
|
||||
}
|
||||
|
||||
route := &api.Route{
|
||||
ObjectMeta: kapi.ObjectMeta{
|
||||
Name: name,
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: api.RouteSpec{
|
||||
Host: params["hostname"],
|
||||
Path: params["path"],
|
||||
To: api.RouteTargetReference{
|
||||
Name: params["default-name"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
portString := params["port"]
|
||||
if len(portString) > 0 {
|
||||
var targetPort intstr.IntOrString
|
||||
if port, err := strconv.Atoi(portString); err == nil {
|
||||
targetPort = intstr.FromInt(port)
|
||||
} else {
|
||||
targetPort = intstr.FromString(portString)
|
||||
}
|
||||
route.Spec.Port = &api.RoutePort{
|
||||
TargetPort: targetPort,
|
||||
}
|
||||
}
|
||||
|
||||
return route, nil
|
||||
}
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
package analysis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/gonum/graph"
|
||||
|
||||
kapi "k8s.io/kubernetes/pkg/api"
|
||||
|
||||
osgraph "github.com/openshift/origin/pkg/api/graph"
|
||||
kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes"
|
||||
routeapi "github.com/openshift/origin/pkg/route/api"
|
||||
routeedges "github.com/openshift/origin/pkg/route/graph"
|
||||
routegraph "github.com/openshift/origin/pkg/route/graph/nodes"
|
||||
)
|
||||
|
||||
const (
|
||||
// MissingRoutePortWarning is returned when a route has no route port specified
|
||||
// and the service it routes to has multiple ports.
|
||||
MissingRoutePortWarning = "MissingRoutePort"
|
||||
// WrongRoutePortWarning is returned when a route has a route port specified
|
||||
// but the service it points to has no such port (either as a named port or as
|
||||
// a target port).
|
||||
WrongRoutePortWarning = "WrongRoutePort"
|
||||
// MissingServiceWarning is returned when there is no service for the specific route.
|
||||
MissingServiceWarning = "MissingService"
|
||||
// MissingTLSTerminationTypeErr is returned when a route with a tls config doesn't
|
||||
// specify a tls termination type.
|
||||
MissingTLSTerminationTypeErr = "MissingTLSTermination"
|
||||
// PathBasedPassthroughErr is returned when a path based route is passthrough
|
||||
// terminated.
|
||||
PathBasedPassthroughErr = "PathBasedPassthrough"
|
||||
// MissingTLSTerminationTypeErr is returned when a route with a tls config doesn't
|
||||
// specify a tls termination type.
|
||||
RouteNotAdmittedTypeErr = "RouteNotAdmitted"
|
||||
// MissingRequiredRouterErr is returned when no router has been setup.
|
||||
MissingRequiredRouterErr = "MissingRequiredRouter"
|
||||
)
|
||||
|
||||
// FindPortMappingIssues checks all routes and reports any issues related to their ports.
|
||||
// Also non-existent services for routes are reported here.
|
||||
func FindPortMappingIssues(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
|
||||
markers := []osgraph.Marker{}
|
||||
|
||||
for _, uncastRouteNode := range g.NodesByKind(routegraph.RouteNodeKind) {
|
||||
routeNode := uncastRouteNode.(*routegraph.RouteNode)
|
||||
marker := routePortMarker(g, f, routeNode)
|
||||
if marker != nil {
|
||||
markers = append(markers, *marker)
|
||||
}
|
||||
}
|
||||
|
||||
return markers
|
||||
}
|
||||
|
||||
func routePortMarker(g osgraph.Graph, f osgraph.Namer, routeNode *routegraph.RouteNode) *osgraph.Marker {
|
||||
for _, uncastServiceNode := range g.SuccessorNodesByEdgeKind(routeNode, routeedges.ExposedThroughRouteEdgeKind) {
|
||||
svcNode := uncastServiceNode.(*kubegraph.ServiceNode)
|
||||
|
||||
if !svcNode.Found() {
|
||||
return &osgraph.Marker{
|
||||
Node: routeNode,
|
||||
RelatedNodes: []graph.Node{svcNode},
|
||||
|
||||
Severity: osgraph.WarningSeverity,
|
||||
Key: MissingServiceWarning,
|
||||
Message: fmt.Sprintf("%s is supposed to route traffic to %s but %s doesn't exist.",
|
||||
f.ResourceName(routeNode), f.ResourceName(svcNode), f.ResourceName(svcNode)),
|
||||
// TODO: Suggest 'oc create service' once that's a thing.
|
||||
// See https://github.com/kubernetes/kubernetes/pull/19509
|
||||
}
|
||||
}
|
||||
|
||||
if len(svcNode.Spec.Ports) > 1 && (routeNode.Spec.Port == nil || len(routeNode.Spec.Port.TargetPort.String()) == 0) {
|
||||
return &osgraph.Marker{
|
||||
Node: routeNode,
|
||||
RelatedNodes: []graph.Node{svcNode},
|
||||
|
||||
Severity: osgraph.WarningSeverity,
|
||||
Key: MissingRoutePortWarning,
|
||||
Message: fmt.Sprintf("%s doesn't have a port specified and is routing traffic to %s which uses multiple ports.",
|
||||
f.ResourceName(routeNode), f.ResourceName(svcNode)),
|
||||
}
|
||||
}
|
||||
|
||||
if routeNode.Spec.Port == nil {
|
||||
// If no port is specified, we don't need to analyze any further.
|
||||
return nil
|
||||
}
|
||||
|
||||
routePortString := routeNode.Spec.Port.TargetPort.String()
|
||||
if routePort, err := strconv.Atoi(routePortString); err == nil {
|
||||
for _, port := range svcNode.Spec.Ports {
|
||||
if port.TargetPort.IntValue() == routePort {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// route has a numeric port, service has no port with that number as a targetPort.
|
||||
marker := &osgraph.Marker{
|
||||
Node: routeNode,
|
||||
RelatedNodes: []graph.Node{svcNode},
|
||||
|
||||
Severity: osgraph.WarningSeverity,
|
||||
Key: WrongRoutePortWarning,
|
||||
Message: fmt.Sprintf("%s has a port specified (%d) but %s has no such targetPort.",
|
||||
f.ResourceName(routeNode), routePort, f.ResourceName(svcNode)),
|
||||
}
|
||||
if len(svcNode.Spec.Ports) == 1 {
|
||||
marker.Suggestion = osgraph.Suggestion(fmt.Sprintf("oc patch %s -p '{\"spec\":{\"port\":{\"targetPort\": %d}}}'", f.ResourceName(routeNode), svcNode.Spec.Ports[0].TargetPort.IntValue()))
|
||||
}
|
||||
|
||||
return marker
|
||||
}
|
||||
|
||||
for _, port := range svcNode.Spec.Ports {
|
||||
if port.Name == routePortString {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// route has a named port, service has no port with that name.
|
||||
marker := &osgraph.Marker{
|
||||
Node: routeNode,
|
||||
RelatedNodes: []graph.Node{svcNode},
|
||||
|
||||
Severity: osgraph.WarningSeverity,
|
||||
Key: WrongRoutePortWarning,
|
||||
Message: fmt.Sprintf("%s has a named port specified (%q) but %s has no such named port.",
|
||||
f.ResourceName(routeNode), routePortString, f.ResourceName(svcNode)),
|
||||
}
|
||||
if len(svcNode.Spec.Ports) == 1 {
|
||||
marker.Suggestion = osgraph.Suggestion(fmt.Sprintf("oc patch %s -p '{\"spec\":{\"port\":{\"targetPort\": %d}}}'", f.ResourceName(routeNode), svcNode.Spec.Ports[0].TargetPort.IntValue()))
|
||||
}
|
||||
|
||||
return marker
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindMissingTLSTerminationType(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
|
||||
markers := []osgraph.Marker{}
|
||||
|
||||
for _, uncastRouteNode := range g.NodesByKind(routegraph.RouteNodeKind) {
|
||||
routeNode := uncastRouteNode.(*routegraph.RouteNode)
|
||||
|
||||
if routeNode.Spec.TLS != nil && len(routeNode.Spec.TLS.Termination) == 0 {
|
||||
markers = append(markers, osgraph.Marker{
|
||||
Node: routeNode,
|
||||
|
||||
Severity: osgraph.ErrorSeverity,
|
||||
Key: MissingTLSTerminationTypeErr,
|
||||
Message: fmt.Sprintf("%s has a TLS configuration but no termination type specified.", f.ResourceName(routeNode)),
|
||||
Suggestion: osgraph.Suggestion(fmt.Sprintf("oc patch %s -p '{\"spec\":{\"tls\":{\"termination\":\"<type>\"}}}' (replace <type> with a valid termination type: edge, passthrough, reencrypt)", f.ResourceName(routeNode)))})
|
||||
}
|
||||
}
|
||||
|
||||
return markers
|
||||
}
|
||||
|
||||
// FindRouteAdmissionFailures creates markers for any routes that were rejected by their routers
|
||||
func FindRouteAdmissionFailures(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
|
||||
markers := []osgraph.Marker{}
|
||||
|
||||
for _, uncastRouteNode := range g.NodesByKind(routegraph.RouteNodeKind) {
|
||||
routeNode := uncastRouteNode.(*routegraph.RouteNode)
|
||||
Route:
|
||||
for _, ingress := range routeNode.Status.Ingress {
|
||||
switch status, condition := routeapi.IngressConditionStatus(&ingress, routeapi.RouteAdmitted); status {
|
||||
case kapi.ConditionFalse:
|
||||
markers = append(markers, osgraph.Marker{
|
||||
Node: routeNode,
|
||||
|
||||
Severity: osgraph.ErrorSeverity,
|
||||
Key: RouteNotAdmittedTypeErr,
|
||||
Message: fmt.Sprintf("%s was not accepted by router %q: %s (%s)", f.ResourceName(routeNode), ingress.RouterName, condition.Message, condition.Reason),
|
||||
})
|
||||
break Route
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return markers
|
||||
}
|
||||
|
||||
// FindMissingRouter creates markers for all routes in case there is no running router.
|
||||
func FindMissingRouter(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
|
||||
markers := []osgraph.Marker{}
|
||||
|
||||
for _, uncastRouteNode := range g.NodesByKind(routegraph.RouteNodeKind) {
|
||||
routeNode := uncastRouteNode.(*routegraph.RouteNode)
|
||||
|
||||
if len(routeNode.Route.Status.Ingress) == 0 {
|
||||
markers = append(markers, osgraph.Marker{
|
||||
Node: routeNode,
|
||||
|
||||
Severity: osgraph.ErrorSeverity,
|
||||
Key: MissingRequiredRouterErr,
|
||||
Message: fmt.Sprintf("%s is routing traffic to svc/%s, but either the administrator has not installed a router or the router is not selecting this route.", f.ResourceName(routeNode), routeNode.Spec.To.Name),
|
||||
Suggestion: osgraph.Suggestion("oc adm router -h"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return markers
|
||||
}
|
||||
|
||||
func FindPathBasedPassthroughRoutes(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
|
||||
markers := []osgraph.Marker{}
|
||||
|
||||
for _, uncastRouteNode := range g.NodesByKind(routegraph.RouteNodeKind) {
|
||||
routeNode := uncastRouteNode.(*routegraph.RouteNode)
|
||||
|
||||
if len(routeNode.Spec.Path) > 0 && routeNode.Spec.TLS != nil && routeNode.Spec.TLS.Termination == routeapi.TLSTerminationPassthrough {
|
||||
markers = append(markers, osgraph.Marker{
|
||||
Node: routeNode,
|
||||
|
||||
Severity: osgraph.ErrorSeverity,
|
||||
Key: PathBasedPassthroughErr,
|
||||
Message: fmt.Sprintf("%s is path-based and uses passthrough termination, which is an invalid combination.", f.ResourceName(routeNode)),
|
||||
Suggestion: osgraph.Suggestion(fmt.Sprintf("1. use spec.tls.termination=edge or 2. use spec.tls.termination=reencrypt and specify spec.tls.destinationCACertificate or 3. remove spec.path")),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return markers
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Package analysis provides functions that analyse routes and setup markers
|
||||
// that will be reported by oc status
|
||||
package analysis
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// Package graph contains graph utilities for routes
|
||||
package graph
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package graph
|
||||
|
||||
import (
|
||||
"github.com/gonum/graph"
|
||||
|
||||
kapi "k8s.io/kubernetes/pkg/api"
|
||||
|
||||
osgraph "github.com/openshift/origin/pkg/api/graph"
|
||||
kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes"
|
||||
routegraph "github.com/openshift/origin/pkg/route/graph/nodes"
|
||||
)
|
||||
|
||||
const (
|
||||
// ExposedThroughRouteEdgeKind is an edge from a route to any object that
|
||||
// is exposed through routes
|
||||
ExposedThroughRouteEdgeKind = "ExposedThroughRoute"
|
||||
)
|
||||
|
||||
// AddRouteEdges adds an edge that connect a service to a route in the given graph
|
||||
func AddRouteEdges(g osgraph.MutableUniqueGraph, node *routegraph.RouteNode) {
|
||||
syntheticService := &kapi.Service{}
|
||||
syntheticService.Namespace = node.Namespace
|
||||
syntheticService.Name = node.Spec.To.Name
|
||||
|
||||
serviceNode := kubegraph.FindOrCreateSyntheticServiceNode(g, syntheticService)
|
||||
g.AddEdge(node, serviceNode, ExposedThroughRouteEdgeKind)
|
||||
|
||||
for _, svc := range node.Spec.AlternateBackends {
|
||||
syntheticService := &kapi.Service{}
|
||||
syntheticService.Namespace = node.Namespace
|
||||
syntheticService.Name = svc.Name
|
||||
|
||||
serviceNode := kubegraph.FindOrCreateSyntheticServiceNode(g, syntheticService)
|
||||
g.AddEdge(node, serviceNode, ExposedThroughRouteEdgeKind)
|
||||
}
|
||||
}
|
||||
|
||||
// AddAllRouteEdges adds service edges to all route nodes in the given graph
|
||||
func AddAllRouteEdges(g osgraph.MutableUniqueGraph) {
|
||||
for _, node := range g.(graph.Graph).Nodes() {
|
||||
if routeNode, ok := node.(*routegraph.RouteNode); ok {
|
||||
AddRouteEdges(g, routeNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// Package nodes contains graph functions and types for routes
|
||||
package nodes
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package nodes
|
||||
|
||||
import (
|
||||
"github.com/gonum/graph"
|
||||
|
||||
osgraph "github.com/openshift/origin/pkg/api/graph"
|
||||
routeapi "github.com/openshift/origin/pkg/route/api"
|
||||
)
|
||||
|
||||
// EnsureRouteNode adds a graph node for the specific route if it does not exist
|
||||
func EnsureRouteNode(g osgraph.MutableUniqueGraph, route *routeapi.Route) *RouteNode {
|
||||
return osgraph.EnsureUnique(
|
||||
g,
|
||||
RouteNodeName(route),
|
||||
func(node osgraph.Node) graph.Node {
|
||||
return &RouteNode{
|
||||
Node: node,
|
||||
Route: route,
|
||||
}
|
||||
},
|
||||
).(*RouteNode)
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package nodes
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
osgraph "github.com/openshift/origin/pkg/api/graph"
|
||||
routeapi "github.com/openshift/origin/pkg/route/api"
|
||||
)
|
||||
|
||||
var (
|
||||
RouteNodeKind = reflect.TypeOf(routeapi.Route{}).Name()
|
||||
)
|
||||
|
||||
func RouteNodeName(o *routeapi.Route) osgraph.UniqueName {
|
||||
return osgraph.GetUniqueRuntimeObjectNodeName(RouteNodeKind, o)
|
||||
}
|
||||
|
||||
type RouteNode struct {
|
||||
osgraph.Node
|
||||
*routeapi.Route
|
||||
}
|
||||
|
||||
func (n RouteNode) Object() interface{} {
|
||||
return n.Route
|
||||
}
|
||||
|
||||
func (n RouteNode) String() string {
|
||||
return string(RouteNodeName(n.Route))
|
||||
}
|
||||
|
||||
func (*RouteNode) Kind() string {
|
||||
return RouteNodeKind
|
||||
}
|
||||
Reference in New Issue
Block a user