Skip to content

Commit e1285a5

Browse files
committed
switch networking to external types
1 parent 66e4c13 commit e1285a5

39 files changed

+98
-259
lines changed

pkg/cmd/openshift-controller-manager/controller/interfaces.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313

1414
appsclient "github.com/openshift/client-go/apps/clientset/versioned"
1515
appsinformer "github.com/openshift/client-go/apps/informers/externalversions"
16+
networkclientinternal "github.com/openshift/client-go/network/clientset/versioned"
17+
networkinformer "github.com/openshift/client-go/network/informers/externalversions"
1618
routeinformer "github.com/openshift/client-go/route/informers/externalversions"
1719
securityv1client "github.com/openshift/client-go/security/clientset/versioned"
1820
authorizationinformer "github.com/openshift/origin/pkg/authorization/generated/informers/internalversion"
@@ -21,8 +23,6 @@ import (
2123
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
2224
imageinformer "github.com/openshift/origin/pkg/image/generated/informers/internalversion"
2325
imageclientinternal "github.com/openshift/origin/pkg/image/generated/internalclientset"
24-
networkinformer "github.com/openshift/origin/pkg/network/generated/informers/internalversion"
25-
networkclientinternal "github.com/openshift/origin/pkg/network/generated/internalclientset"
2626
quotainformer "github.com/openshift/origin/pkg/quota/generated/informers/internalversion"
2727
quotaclient "github.com/openshift/origin/pkg/quota/generated/internalclientset"
2828
securityinformer "github.com/openshift/origin/pkg/security/generated/informers/internalversion"
@@ -41,7 +41,7 @@ type ControllerContext struct {
4141

4242
InternalBuildInformers buildinformer.SharedInformerFactory
4343
InternalImageInformers imageinformer.SharedInformerFactory
44-
InternalNetworkInformers networkinformer.SharedInformerFactory
44+
NetworkInformers networkinformer.SharedInformerFactory
4545
InternalTemplateInformers templateinformer.SharedInformerFactory
4646
InternalQuotaInformers quotainformer.SharedInformerFactory
4747
InternalAuthorizationInformers authorizationinformer.SharedInformerFactory
@@ -90,8 +90,8 @@ type ControllerClientBuilder interface {
9090
OpenshiftInternalQuotaClient(name string) (quotaclient.Interface, error)
9191
OpenshiftInternalQuotaClientOrDie(name string) quotaclient.Interface
9292

93-
OpenshiftInternalNetworkClient(name string) (networkclientinternal.Interface, error)
94-
OpenshiftInternalNetworkClientOrDie(name string) networkclientinternal.Interface
93+
OpenshiftNetworkClient(name string) (networkclientinternal.Interface, error)
94+
OpenshiftNetworkClientOrDie(name string) networkclientinternal.Interface
9595

9696
OpenshiftInternalSecurityClient(name string) (securityclient.Interface, error)
9797
OpenshiftInternalSecurityClientOrDie(name string) securityclient.Interface
@@ -232,22 +232,22 @@ func (b OpenshiftControllerClientBuilder) OpenshiftInternalQuotaClientOrDie(name
232232
return client
233233
}
234234

235-
// OpenshiftInternalNetworkClient provides a REST client for the network API.
235+
// OpenshiftNetworkClient provides a REST client for the network API.
236236
// If the client cannot be created because of configuration error, this function
237237
// will error.
238-
func (b OpenshiftControllerClientBuilder) OpenshiftInternalNetworkClient(name string) (networkclientinternal.Interface, error) {
238+
func (b OpenshiftControllerClientBuilder) OpenshiftNetworkClient(name string) (networkclientinternal.Interface, error) {
239239
clientConfig, err := b.Config(name)
240240
if err != nil {
241241
return nil, err
242242
}
243243
return networkclientinternal.NewForConfig(clientConfig)
244244
}
245245

246-
// OpenshiftInternalNetworkClientOrDie provides a REST client for the network API.
246+
// OpenshiftNetworkClientOrDie provides a REST client for the network API.
247247
// If the client cannot be created because of configuration error, this function
248248
// will panic.
249-
func (b OpenshiftControllerClientBuilder) OpenshiftInternalNetworkClientOrDie(name string) networkclientinternal.Interface {
250-
client, err := b.OpenshiftInternalNetworkClient(name)
249+
func (b OpenshiftControllerClientBuilder) OpenshiftNetworkClientOrDie(name string) networkclientinternal.Interface {
250+
client, err := b.OpenshiftNetworkClient(name)
251251
if err != nil {
252252
glog.Fatal(err)
253253
}

pkg/cmd/openshift-controller-manager/controller/network_sdn.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ func RunSDNController(ctx ControllerContext) (bool, error) {
1515

1616
if err := sdnmaster.Start(
1717
ctx.OpenshiftControllerConfig.Network,
18-
ctx.ClientBuilder.OpenshiftInternalNetworkClientOrDie(bootstrappolicy.InfraSDNControllerServiceAccountName),
18+
ctx.ClientBuilder.OpenshiftNetworkClientOrDie(bootstrappolicy.InfraSDNControllerServiceAccountName),
1919
ctx.ClientBuilder.ClientOrDie(bootstrappolicy.InfraSDNControllerServiceAccountName),
2020
ctx.KubernetesInformers,
21-
ctx.InternalNetworkInformers,
21+
ctx.NetworkInformers,
2222
); err != nil {
2323
return false, fmt.Errorf("failed to start SDN plugin controller: %v", err)
2424
}

pkg/cmd/openshift-controller-manager/controller_manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func newControllerContext(
143143
InternalAuthorizationInformers: originInformers.GetInternalOpenshiftAuthorizationInformers(),
144144
InternalBuildInformers: originInformers.GetInternalOpenshiftBuildInformers(),
145145
InternalImageInformers: originInformers.GetInternalOpenshiftImageInformers(),
146-
InternalNetworkInformers: originInformers.GetInternalOpenshiftNetworkInformers(),
146+
NetworkInformers: originInformers.GetOpenshiftNetworkInformers(),
147147
InternalQuotaInformers: originInformers.GetInternalOpenshiftQuotaInformers(),
148148
InternalSecurityInformers: originInformers.GetInternalOpenshiftSecurityInformers(),
149149
InternalRouteInformers: originInformers.GetOpenshiftRouteInformers(),

pkg/cmd/server/kubernetes/network/network_config.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import (
1818
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig"
1919
proxyconfig "k8s.io/kubernetes/pkg/proxy/config"
2020

21+
networkclient "github.com/openshift/client-go/network/clientset/versioned"
22+
networkinformers "github.com/openshift/client-go/network/informers/externalversions"
2123
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
2224
"github.com/openshift/origin/pkg/cmd/server/kubernetes/network/transport"
2325
"github.com/openshift/origin/pkg/dns"
2426
"github.com/openshift/origin/pkg/network"
25-
networkinformers "github.com/openshift/origin/pkg/network/generated/informers/internalversion"
26-
networkclient "github.com/openshift/origin/pkg/network/generated/internalclientset"
2727
)
2828

2929
// NetworkConfig represents the required parameters to start OpenShift networking
@@ -35,8 +35,8 @@ type NetworkConfig struct {
3535
ExternalKubeClientset kclientsetexternal.Interface
3636
// Internal kubernetes shared informer factory.
3737
InternalKubeInformers kinternalinformers.SharedInformerFactory
38-
// Internal network shared informer factory.
39-
InternalNetworkInformers networkinformers.SharedInformerFactory
38+
// Network shared informer factory.
39+
NetworkInformers networkinformers.SharedInformerFactory
4040

4141
// ProxyConfig is the configuration for the kube-proxy, fully initialized
4242
ProxyConfig *kubeproxyconfig.KubeProxyConfiguration
@@ -118,9 +118,9 @@ func New(options configapi.NodeConfig, clusterDomain string, proxyConfig *kubepr
118118
}
119119

120120
if network.IsOpenShiftNetworkPlugin(options.NetworkConfig.NetworkPluginName) {
121-
config.InternalNetworkInformers = networkinformers.NewSharedInformerFactory(networkClient, network.DefaultInformerResyncPeriod)
121+
config.NetworkInformers = networkinformers.NewSharedInformerFactory(networkClient, network.DefaultInformerResyncPeriod)
122122

123-
config.SDNNode, config.SDNProxy, err = NewSDNInterfaces(options, networkClient, kubeClient, internalKubeClient, internalKubeInformers, config.InternalNetworkInformers, proxyConfig)
123+
config.SDNNode, config.SDNProxy, err = NewSDNInterfaces(options, networkClient, kubeClient, internalKubeClient, internalKubeInformers, config.NetworkInformers, proxyConfig)
124124
if err != nil {
125125
return nil, fmt.Errorf("SDN initialization failed: %v", err)
126126
}

pkg/cmd/server/kubernetes/network/sdn_linux.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
kinternalinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
1313
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig"
1414

15+
networkclient "github.com/openshift/client-go/network/clientset/versioned"
16+
networkinformers "github.com/openshift/client-go/network/informers/externalversions"
1517
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
16-
networkinformers "github.com/openshift/origin/pkg/network/generated/informers/internalversion"
17-
networkclient "github.com/openshift/origin/pkg/network/generated/internalclientset"
1818
sdnnode "github.com/openshift/origin/pkg/network/node"
1919
sdnproxy "github.com/openshift/origin/pkg/network/proxy"
2020
)

pkg/cmd/server/kubernetes/network/sdn_unsupported.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
kinternalinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
1111
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig"
1212

13+
networkclient "github.com/openshift/client-go/network/clientset/versioned"
14+
networkinformers "github.com/openshift/client-go/network/informers/externalversions"
1315
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
14-
networkinformers "github.com/openshift/origin/pkg/network/generated/informers/internalversion"
15-
networkclient "github.com/openshift/origin/pkg/network/generated/internalclientset"
1616
)
1717

1818
func NewSDNInterfaces(options configapi.NodeConfig, networkClient networkclient.Interface,

pkg/cmd/server/origin/informers.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"github.com/golang/glog"
1515
appsclient "github.com/openshift/client-go/apps/clientset/versioned"
1616
appsinformer "github.com/openshift/client-go/apps/informers/externalversions"
17+
networkclient "github.com/openshift/client-go/network/clientset/versioned"
18+
networkinformer "github.com/openshift/client-go/network/informers/externalversions"
1719
oauthclient "github.com/openshift/client-go/oauth/clientset/versioned"
1820
oauthinformer "github.com/openshift/client-go/oauth/informers/externalversions"
1921
routeclient "github.com/openshift/client-go/route/clientset/versioned"
@@ -26,8 +28,6 @@ import (
2628
buildclient "github.com/openshift/origin/pkg/build/generated/internalclientset"
2729
imageinformer "github.com/openshift/origin/pkg/image/generated/informers/internalversion"
2830
imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset"
29-
networkinformer "github.com/openshift/origin/pkg/network/generated/informers/internalversion"
30-
networkclient "github.com/openshift/origin/pkg/network/generated/internalclientset"
3131
quotainformer "github.com/openshift/origin/pkg/quota/generated/informers/internalversion"
3232
quotaclient "github.com/openshift/origin/pkg/quota/generated/internalclientset"
3333
securityinformer "github.com/openshift/origin/pkg/security/generated/informers/internalversion"
@@ -233,7 +233,7 @@ func (i *informerHolder) GetInternalOpenshiftBuildInformers() buildinformer.Shar
233233
func (i *informerHolder) GetInternalOpenshiftImageInformers() imageinformer.SharedInformerFactory {
234234
return i.imageInformers
235235
}
236-
func (i *informerHolder) GetInternalOpenshiftNetworkInformers() networkinformer.SharedInformerFactory {
236+
func (i *informerHolder) GetOpenshiftNetworkInformers() networkinformer.SharedInformerFactory {
237237
return i.networkInformers
238238
}
239239
func (i *informerHolder) GetOpenshiftOauthInformers() oauthinformer.SharedInformerFactory {
@@ -289,7 +289,7 @@ func (i *informerHolder) ToGenericInformer() GenericResourceInformer {
289289
return i.GetInternalOpenshiftImageInformers().ForResource(resource)
290290
}),
291291
genericResourceInformerFunc(func(resource schema.GroupVersionResource) (kexternalinformers.GenericInformer, error) {
292-
return i.GetInternalOpenshiftNetworkInformers().ForResource(resource)
292+
return i.GetOpenshiftNetworkInformers().ForResource(resource)
293293
}),
294294
genericInternalResourceInformerFunc(func(resource schema.GroupVersionResource) (kexternalinformers.GenericInformer, error) {
295295
return i.GetOpenshiftOauthInformers().ForResource(resource)

pkg/cmd/server/origin/master_config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
rbacauthorizer "k8s.io/kubernetes/plugin/pkg/auth/authorizer/rbac"
3232

3333
appsinformer "github.com/openshift/client-go/apps/informers/externalversions"
34+
networkinformer "github.com/openshift/client-go/network/informers/externalversions"
3435
oauthinformer "github.com/openshift/client-go/oauth/informers/externalversions"
3536
routeinformer "github.com/openshift/client-go/route/informers/externalversions"
3637
userinformer "github.com/openshift/client-go/user/informers/externalversions"
@@ -43,7 +44,6 @@ import (
4344
imageapi "github.com/openshift/origin/pkg/image/apis/image"
4445
imageadmission "github.com/openshift/origin/pkg/image/apiserver/admission/limitrange"
4546
imageinformer "github.com/openshift/origin/pkg/image/generated/informers/internalversion"
46-
networkinformer "github.com/openshift/origin/pkg/network/generated/informers/internalversion"
4747
_ "github.com/openshift/origin/pkg/printers/internalversion"
4848
projectauth "github.com/openshift/origin/pkg/project/auth"
4949
projectcache "github.com/openshift/origin/pkg/project/cache"
@@ -111,13 +111,13 @@ type InformerAccess interface {
111111

112112
GetOpenshiftAppInformers() appsinformer.SharedInformerFactory
113113
GetOpenshiftOauthInformers() oauthinformer.SharedInformerFactory
114+
GetOpenshiftNetworkInformers() networkinformer.SharedInformerFactory
114115
GetOpenshiftRouteInformers() routeinformer.SharedInformerFactory
115116
GetOpenshiftUserInformers() userinformer.SharedInformerFactory
116117

117118
GetInternalOpenshiftAuthorizationInformers() authorizationinformer.SharedInformerFactory
118119
GetInternalOpenshiftBuildInformers() buildinformer.SharedInformerFactory
119120
GetInternalOpenshiftImageInformers() imageinformer.SharedInformerFactory
120-
GetInternalOpenshiftNetworkInformers() networkinformer.SharedInformerFactory
121121
GetInternalOpenshiftQuotaInformers() quotainformer.SharedInformerFactory
122122
GetInternalOpenshiftSecurityInformers() securityinformer.SharedInformerFactory
123123
GetInternalOpenshiftTemplateInformers() templateinformer.SharedInformerFactory

pkg/cmd/server/start/start_node.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ func StartNode(nodeConfig configapi.NodeConfig, components *utilflags.ComponentF
493493
}
494494

495495
networkConfig.InternalKubeInformers.Start(stopCh)
496-
if networkConfig.InternalNetworkInformers != nil {
497-
networkConfig.InternalNetworkInformers.Start(stopCh)
496+
if networkConfig.NetworkInformers != nil {
497+
networkConfig.NetworkInformers.Start(stopCh)
498498
}
499499

500500
return nil

pkg/network/apis/network/annotations.go

-5
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,3 @@ func SetChangePodNetworkAnnotation(netns *NetNamespace, action PodNetworkAction,
5858
}
5959
netns.Annotations[ChangePodNetworkAnnotation] = value
6060
}
61-
62-
// DeleteChangePodNetworkAnnotation removes network change intent from NetNamespace
63-
func DeleteChangePodNetworkAnnotation(netns *NetNamespace) {
64-
delete(netns.Annotations, ChangePodNetworkAnnotation)
65-
}

pkg/network/apis/network/plugin.go

-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
package network
22

33
const (
4-
// Pod annotations
5-
IngressBandwidthAnnotation = "kubernetes.io/ingress-bandwidth"
6-
EgressBandwidthAnnotation = "kubernetes.io/egress-bandwidth"
7-
AssignMacvlanAnnotation = "pod.network.openshift.io/assign-macvlan"
84

95
// HostSubnet annotations. (Note: should be "hostsubnet.network.openshift.io/", but the incorrect name is now part of the API.)
106
AssignHostSubnetAnnotation = "pod.network.openshift.io/assign-subnet"
11-
FixedVNIDHostAnnotation = "pod.network.openshift.io/fixed-vnid-host"
12-
NodeUIDAnnotation = "pod.network.openshift.io/node-uid"
13-
14-
// NetNamespace annotations
15-
MulticastEnabledAnnotation = "netnamespace.network.openshift.io/multicast-enabled"
167
)

pkg/network/apis/network/validation/validation.go

-33
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package validation
33
import (
44
"fmt"
55
"net"
6-
"reflect"
76

87
"k8s.io/apimachinery/pkg/api/validation/path"
98
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
@@ -37,13 +36,6 @@ func validateIPv4(ip string) (net.IP, error) {
3736
return bytes, nil
3837
}
3938

40-
var defaultClusterNetwork *networkapi.ClusterNetwork
41-
42-
// SetDefaultClusterNetwork sets the expected value of the default ClusterNetwork record
43-
func SetDefaultClusterNetwork(cn networkapi.ClusterNetwork) {
44-
defaultClusterNetwork = &cn
45-
}
46-
4739
// ValidateClusterNetwork tests if required fields in the ClusterNetwork are set, and ensures that the "default" ClusterNetwork can only be set to the correct values
4840
func ValidateClusterNetwork(clusterNet *networkapi.ClusterNetwork) field.ErrorList {
4941
allErrs := validation.ValidateObjectMeta(&clusterNet.ObjectMeta, false, path.ValidatePathSegmentName, field.NewPath("metadata"))
@@ -123,31 +115,6 @@ func ValidateClusterNetwork(clusterNet *networkapi.ClusterNetwork) field.ErrorLi
123115
}
124116
}
125117

126-
if clusterNet.Name == networkapi.ClusterNetworkDefault && defaultClusterNetwork != nil {
127-
if clusterNet.Network != defaultClusterNetwork.Network {
128-
allErrs = append(allErrs, field.Invalid(field.NewPath("network"), clusterNet.Network, "cannot change the default ClusterNetwork record via API."))
129-
}
130-
if clusterNet.HostSubnetLength != defaultClusterNetwork.HostSubnetLength {
131-
allErrs = append(allErrs, field.Invalid(field.NewPath("hostsubnetlength"), clusterNet.HostSubnetLength, "cannot change the default ClusterNetwork record via API."))
132-
}
133-
if !reflect.DeepEqual(clusterNet.ClusterNetworks, defaultClusterNetwork.ClusterNetworks) {
134-
allErrs = append(allErrs, field.Invalid(field.NewPath("ClusterNetworks"), clusterNet.ClusterNetworks, "cannot change the default ClusterNetwork record via API"))
135-
}
136-
if clusterNet.ServiceNetwork != defaultClusterNetwork.ServiceNetwork {
137-
allErrs = append(allErrs, field.Invalid(field.NewPath("serviceNetwork"), clusterNet.ServiceNetwork, "cannot change the default ClusterNetwork record via API."))
138-
}
139-
if clusterNet.PluginName != defaultClusterNetwork.PluginName {
140-
allErrs = append(allErrs, field.Invalid(field.NewPath("pluginName"), clusterNet.PluginName, "cannot change the default ClusterNetwork record via API."))
141-
}
142-
if (clusterNet.VXLANPort == nil) != (defaultClusterNetwork.VXLANPort == nil) {
143-
allErrs = append(allErrs, field.Invalid(field.NewPath("vxlanPort"), clusterNet.VXLANPort, "cannot change the default ClusterNetwork record via API."))
144-
} else if (clusterNet.VXLANPort != nil) && (defaultClusterNetwork.VXLANPort != nil) {
145-
if *clusterNet.VXLANPort != *defaultClusterNetwork.VXLANPort {
146-
allErrs = append(allErrs, field.Invalid(field.NewPath("vxlanPort"), clusterNet.VXLANPort, "cannot change the default ClusterNetwork record via API."))
147-
}
148-
}
149-
}
150-
151118
return allErrs
152119
}
153120

0 commit comments

Comments
 (0)