ceph: remove old network types
Those types are legacy, not really used anywhere and not needed anymore. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
1 parent
412b3eaf5e
commit
8fdb9fe2b9
8 files changed
+9
-232
No files matched your search
@@ -49,7 +49,6 @@ type config struct {
|
||||
location string
|
||||
cephConfigOverride string
|
||||
storeConfig osdconfig.StoreConfig
|
||||
networkInfo clusterd.NetworkInfo
|
||||
monEndpoints string
|
||||
nodeName string
|
||||
pvcBacked bool
|
||||
@@ -69,13 +68,10 @@ func createContext() *clusterd.Context {
|
||||
context := rook.NewContext()
|
||||
context.ConfigDir = cfg.dataDir
|
||||
context.ConfigFileOverride = cfg.cephConfigOverride
|
||||
context.NetworkInfo = cfg.NetworkInfo()
|
||||
return context
|
||||
}
|
||||
|
||||
func addCephFlags(command *cobra.Command) {
|
||||
command.Flags().StringVar(&cfg.networkInfo.PublicAddr, "public-ip", "", "public IP address for this machine")
|
||||
command.Flags().StringVar(&cfg.networkInfo.ClusterAddr, "private-ip", "", "private IP address for this machine")
|
||||
command.Flags().StringVar(&clusterInfo.FSID, "fsid", "", "the cluster uuid")
|
||||
command.Flags().StringVar(&clusterInfo.MonitorSecret, "mon-secret", "", "the cephx keyring for monitors")
|
||||
command.Flags().StringVar(&clusterInfo.CephCred.Username, "ceph-username", "", "ceph username")
|
||||
@@ -85,13 +81,4 @@ func addCephFlags(command *cobra.Command) {
|
||||
command.Flags().StringVar(&cfg.cephConfigOverride, "ceph-config-override", "", "optional path to a ceph config file that will be appended to the config files that rook generates")
|
||||
|
||||
clusterInfo.Namespace = os.Getenv(k8sutil.PodNamespaceEnvVar)
|
||||
|
||||
// deprecated ipv4 format address
|
||||
// TODO: remove these legacy flags in the future
|
||||
command.Flags().StringVar(&cfg.networkInfo.PublicAddrIPv4, "public-ipv4", "", "public IPv4 address for this machine")
|
||||
command.Flags().StringVar(&cfg.networkInfo.ClusterAddrIPv4, "private-ipv4", "", "private IPv4 address for this machine")
|
||||
}
|
||||
|
||||
func (c *config) NetworkInfo() clusterd.NetworkInfo {
|
||||
return c.networkInfo.Simplify()
|
||||
}
|
||||
@@ -19,7 +19,6 @@ package ceph
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/agent/flexvolume/attachment"
|
||||
operator "github.com/rook/rook/pkg/operator/ceph"
|
||||
cluster "github.com/rook/rook/pkg/operator/ceph/cluster"
|
||||
@@ -70,7 +69,6 @@ func startOperator(cmd *cobra.Command, args []string) error {
|
||||
|
||||
logger.Info("starting Rook-Ceph operator")
|
||||
context := createContext()
|
||||
context.NetworkInfo = clusterd.NetworkInfo{}
|
||||
context.ConfigDir = k8sutil.DataDir
|
||||
volumeAttachment, err := attachment.New(context)
|
||||
if err != nil {
|
||||
|
||||
@@ -102,10 +102,9 @@ func NewContext() *clusterd.Context {
|
||||
var err error
|
||||
|
||||
context := &clusterd.Context{
|
||||
Executor: &exec.CommandExecutor{},
|
||||
NetworkInfo: clusterd.NetworkInfo{},
|
||||
ConfigDir: k8sutil.DataDir,
|
||||
LogLevel: Cfg.LogLevel,
|
||||
Executor: &exec.CommandExecutor{},
|
||||
ConfigDir: k8sutil.DataDir,
|
||||
LogLevel: Cfg.LogLevel,
|
||||
}
|
||||
|
||||
// Try to read config from in-cluster env
|
||||
|
||||
@@ -66,9 +66,6 @@ type Context struct {
|
||||
// The full path to a config file that can be used to override generated settings
|
||||
ConfigFileOverride string
|
||||
|
||||
// Information about the network for this machine and its cluster
|
||||
NetworkInfo NetworkInfo
|
||||
|
||||
// NetworkClient is a connection to the CNI plugin API
|
||||
NetworkClient netclient.K8sCniCncfIoV1Interface
|
||||
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 The Rook Authors. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package clusterd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
type NetworkInfo struct {
|
||||
PublicAddr string
|
||||
ClusterAddr string
|
||||
PublicNetwork string // public network and subnet mask in CIDR notation
|
||||
ClusterNetwork string // cluster network and subnet mask in CIDR notation
|
||||
|
||||
// deprecated ipv4 format address
|
||||
// TODO: remove these legacy fields in the future
|
||||
PublicAddrIPv4 string
|
||||
ClusterAddrIPv4 string
|
||||
}
|
||||
|
||||
// Simplify adapts deprecated fields
|
||||
// TODO: remove this function in the future
|
||||
func (in NetworkInfo) Simplify() NetworkInfo {
|
||||
out := NetworkInfo{
|
||||
PublicNetwork: in.PublicNetwork,
|
||||
ClusterNetwork: in.ClusterNetwork,
|
||||
}
|
||||
if in.PublicAddr != "" {
|
||||
out.PublicAddr = in.PublicAddr
|
||||
} else {
|
||||
out.PublicAddr = in.PublicAddrIPv4
|
||||
}
|
||||
|
||||
if in.ClusterAddr != "" {
|
||||
out.ClusterAddr = in.ClusterAddr
|
||||
} else {
|
||||
out.ClusterAddr = in.ClusterAddrIPv4
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func VerifyNetworkInfo(networkInfo NetworkInfo) error {
|
||||
if err := verifyIPAddr(networkInfo.PublicAddr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := verifyIPAddr(networkInfo.ClusterAddr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := verifyIPNetwork(networkInfo.PublicNetwork); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := verifyIPNetwork(networkInfo.ClusterNetwork); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func verifyIPAddr(addr string) error {
|
||||
if addr == "" {
|
||||
// empty strings are OK
|
||||
return nil
|
||||
}
|
||||
|
||||
if net.ParseIP(addr) == nil {
|
||||
return fmt.Errorf("failed to parse IP address %s", addr)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func verifyIPNetwork(network string) error {
|
||||
if network == "" {
|
||||
// empty strings are OK
|
||||
return nil
|
||||
}
|
||||
|
||||
_, _, err := net.ParseCIDR(network)
|
||||
return err
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 The Rook Authors. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package clusterd
|
||||
|
||||
import "testing"
|
||||
import "github.com/stretchr/testify/assert"
|
||||
|
||||
func TestVerifyNetworkInfo(t *testing.T) {
|
||||
// empty network info is OK
|
||||
var networkInfo NetworkInfo
|
||||
err := VerifyNetworkInfo(networkInfo)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// well formed network info is OK
|
||||
networkInfo = NetworkInfo{
|
||||
PublicAddr: "10.1.1.1",
|
||||
PublicNetwork: "10.1.1.0/24",
|
||||
ClusterAddr: "10.1.2.2",
|
||||
ClusterNetwork: "10.1.2.0/24",
|
||||
}
|
||||
err = VerifyNetworkInfo(networkInfo)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// malformed IP address is not OK
|
||||
networkInfo = NetworkInfo{
|
||||
PublicAddr: "10.1.1.256",
|
||||
PublicNetwork: "10.1.1.0/24",
|
||||
ClusterAddr: "10.1.2.256",
|
||||
ClusterNetwork: "10.1.2.0/24",
|
||||
}
|
||||
err = VerifyNetworkInfo(networkInfo)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
// malformed network address is not OK
|
||||
networkInfo = NetworkInfo{
|
||||
PublicAddr: "10.1.1.1",
|
||||
PublicNetwork: "10.1.1.0/33",
|
||||
ClusterAddr: "10.1.2.2",
|
||||
ClusterNetwork: "10.1.2.0/33",
|
||||
}
|
||||
err = VerifyNetworkInfo(networkInfo)
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestNetworkInfoSimplify(t *testing.T) {
|
||||
|
||||
out := NetworkInfo{
|
||||
PublicAddr: "10.1.1.1",
|
||||
PublicNetwork: "10.1.1.0/24",
|
||||
ClusterAddr: "10.1.2.2",
|
||||
ClusterNetwork: "10.1.2.0/24",
|
||||
}
|
||||
|
||||
// only has old fields
|
||||
in := NetworkInfo{
|
||||
PublicAddrIPv4: "10.1.1.1",
|
||||
PublicNetwork: "10.1.1.0/24",
|
||||
ClusterAddrIPv4: "10.1.2.2",
|
||||
ClusterNetwork: "10.1.2.0/24",
|
||||
}
|
||||
assert.Equal(t, out, in.Simplify())
|
||||
|
||||
// has both new and old fields
|
||||
in = NetworkInfo{
|
||||
PublicAddr: "10.1.1.1",
|
||||
PublicAddrIPv4: "10.9.1.1",
|
||||
PublicNetwork: "10.1.1.0/24",
|
||||
ClusterAddr: "10.1.2.2",
|
||||
ClusterAddrIPv4: "10.9.2.2",
|
||||
ClusterNetwork: "10.1.2.0/24",
|
||||
}
|
||||
assert.Equal(t, out, in.Simplify())
|
||||
|
||||
}
|
||||
@@ -61,13 +61,9 @@ var (
|
||||
|
||||
// GlobalConfig represents the [global] sections of Ceph's config file.
|
||||
type GlobalConfig struct {
|
||||
FSID string `ini:"fsid,omitempty"`
|
||||
MonMembers string `ini:"mon initial members,omitempty"`
|
||||
MonHost string `ini:"mon host"`
|
||||
PublicAddr string `ini:"public addr,omitempty"`
|
||||
PublicNetwork string `ini:"public network,omitempty"`
|
||||
ClusterAddr string `ini:"cluster addr,omitempty"`
|
||||
ClusterNetwork string `ini:"cluster network,omitempty"`
|
||||
FSID string `ini:"fsid,omitempty"`
|
||||
MonMembers string `ini:"mon initial members,omitempty"`
|
||||
MonHost string `ini:"mon host"`
|
||||
}
|
||||
|
||||
// CephConfig represents an entire Ceph config including all sections.
|
||||
@@ -198,13 +194,9 @@ func CreateDefaultCephConfig(context *clusterd.Context, clusterInfo *ClusterInfo
|
||||
|
||||
conf := &CephConfig{
|
||||
GlobalConfig: &GlobalConfig{
|
||||
FSID: clusterInfo.FSID,
|
||||
MonMembers: strings.Join(monMembers, " "),
|
||||
MonHost: strings.Join(monHosts, ","),
|
||||
PublicAddr: context.NetworkInfo.PublicAddr,
|
||||
PublicNetwork: context.NetworkInfo.PublicNetwork,
|
||||
ClusterAddr: context.NetworkInfo.ClusterAddr,
|
||||
ClusterNetwork: context.NetworkInfo.ClusterNetwork,
|
||||
FSID: clusterInfo.FSID,
|
||||
MonMembers: strings.Join(monMembers, " "),
|
||||
MonHost: strings.Join(monHosts, ","),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -51,12 +51,6 @@ func TestCreateDefaultCephConfig(t *testing.T) {
|
||||
// start with INFO level logging
|
||||
context := &clusterd.Context{
|
||||
LogLevel: capnslog.INFO,
|
||||
NetworkInfo: clusterd.NetworkInfo{
|
||||
PublicAddr: "10.1.1.1",
|
||||
PublicNetwork: "10.1.1.0/24",
|
||||
ClusterAddr: "10.1.2.2",
|
||||
ClusterNetwork: "10.1.2.0/24",
|
||||
},
|
||||
}
|
||||
|
||||
cephConfig, err := CreateDefaultCephConfig(context, clusterInfo)
|
||||
@@ -73,12 +67,6 @@ func TestCreateDefaultCephConfig(t *testing.T) {
|
||||
t.Fatalf("failed to create default ceph config. %+v", err)
|
||||
}
|
||||
verifyConfig(t, cephConfig, clusterInfo, 10)
|
||||
|
||||
// verify the network info config
|
||||
assert.Equal(t, "10.1.1.1", cephConfig.PublicAddr)
|
||||
assert.Equal(t, "10.1.1.0/24", cephConfig.PublicNetwork)
|
||||
assert.Equal(t, "10.1.2.2", cephConfig.ClusterAddr)
|
||||
assert.Equal(t, "10.1.2.0/24", cephConfig.ClusterNetwork)
|
||||
}
|
||||
|
||||
func TestGenerateConfigFile(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user