mirror of https://github.com/k3s-io/k3s
Add a new error when kine is with disable apiserver or disable etcd
Signed-off-by: Vitor Savian <vitor.savian@suse.com>pull/9572/head
parent
f099bfa508
commit
3f649e3bcb
|
@ -49,9 +49,7 @@ func RunWithControllers(app *cli.Context, leaderControllers server.CustomControl
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomControllers, controllers server.CustomControllers) error {
|
func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomControllers, controllers server.CustomControllers) error {
|
||||||
var (
|
var err error
|
||||||
err error
|
|
||||||
)
|
|
||||||
// Validate build env
|
// Validate build env
|
||||||
cmds.MustValidateGolang()
|
cmds.MustValidateGolang()
|
||||||
|
|
||||||
|
@ -214,6 +212,14 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
|
||||||
return errors.New("invalid flag use; --server is required with --disable-etcd")
|
return errors.New("invalid flag use; --server is required with --disable-etcd")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if serverConfig.ControlConfig.Datastore.Endpoint != "" && serverConfig.ControlConfig.DisableAPIServer {
|
||||||
|
return errors.New("invalid flag use; cannot use --disable-apiserver with --datastore-endpoint")
|
||||||
|
}
|
||||||
|
|
||||||
|
if serverConfig.ControlConfig.Datastore.Endpoint != "" && serverConfig.ControlConfig.DisableETCD {
|
||||||
|
return errors.New("invalid flag use; cannot use --disable-etcd with --datastore-endpoint")
|
||||||
|
}
|
||||||
|
|
||||||
if serverConfig.ControlConfig.DisableAPIServer {
|
if serverConfig.ControlConfig.DisableAPIServer {
|
||||||
// Servers without a local apiserver need to connect to the apiserver via the proxy load-balancer.
|
// Servers without a local apiserver need to connect to the apiserver via the proxy load-balancer.
|
||||||
serverConfig.ControlConfig.APIServerPort = cmds.AgentConfig.LBServerPort
|
serverConfig.ControlConfig.APIServerPort = cmds.AgentConfig.LBServerPort
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
|
|
||||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
. "github.com/onsi/gomega/gstruct"
|
. "github.com/onsi/gomega/gstruct"
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var startupServer *testutil.K3sServer
|
var (
|
||||||
var startupServerArgs = []string{}
|
startupServer *testutil.K3sServer
|
||||||
var testLock int
|
startupServerArgs = []string{}
|
||||||
|
testLock int
|
||||||
|
)
|
||||||
|
|
||||||
var _ = BeforeSuite(func() {
|
var _ = BeforeSuite(func() {
|
||||||
if testutil.IsExistingServer() {
|
if testutil.IsExistingServer() {
|
||||||
|
@ -27,7 +29,6 @@ var _ = BeforeSuite(func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("startup tests", Ordered, func() {
|
var _ = Describe("startup tests", Ordered, func() {
|
||||||
|
|
||||||
When("a default server is created", func() {
|
When("a default server is created", func() {
|
||||||
It("is created with no arguments", func() {
|
It("is created with no arguments", func() {
|
||||||
var err error
|
var err error
|
||||||
|
@ -263,7 +264,54 @@ var _ = Describe("startup tests", Ordered, func() {
|
||||||
Expect(testutil.K3sCleanup(-1, "")).To(Succeed())
|
Expect(testutil.K3sCleanup(-1, "")).To(Succeed())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
When("a server with datastore-endpoint and disable apiserver is created", func() {
|
||||||
|
It("is created with datastore-endpoint and disable apiserver flags", func() {
|
||||||
|
var err error
|
||||||
|
startupServerArgs = []string{"--datastore-endpoint", "test", "--disable-apiserver"}
|
||||||
|
startupServer, err = testutil.K3sStartServer(startupServerArgs...)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
})
|
||||||
|
It("search for the error log", func() {
|
||||||
|
Eventually(func() error {
|
||||||
|
match, err := testutil.SearchK3sLog(startupServer, "invalid flag use; cannot use --disable-apiserver with --datastore-endpoint")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if match {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errors.New("nor found error when --datastore-endpoint and --disable-apiserver are used together")
|
||||||
|
}, "30s", "2s").Should(Succeed())
|
||||||
|
})
|
||||||
|
It("cleans up", func() {
|
||||||
|
Expect(testutil.K3sKillServer(startupServer)).To(Succeed())
|
||||||
|
Expect(testutil.K3sCleanup(-1, "")).To(Succeed())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
When("a server with datastore-endpoint and disable etcd is created", func() {
|
||||||
|
It("is created with datastore-endpoint and disable etcd flags", func() {
|
||||||
|
var err error
|
||||||
|
startupServerArgs = []string{"--datastore-endpoint", "test", "--disable-etcd", "-s", "https://192.168.1.12:6443"}
|
||||||
|
startupServer, err = testutil.K3sStartServer(startupServerArgs...)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
})
|
||||||
|
It("search for the error log", func() {
|
||||||
|
Eventually(func() error {
|
||||||
|
match, err := testutil.SearchK3sLog(startupServer, "invalid flag use; cannot use --disable-etcd with --datastore-endpoint")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if match {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errors.New("not found error when --datastore-endpoint and --disable-etcd are used together")
|
||||||
|
}, "30s", "2s").Should(Succeed())
|
||||||
|
})
|
||||||
|
It("cleans up", func() {
|
||||||
|
Expect(testutil.K3sKillServer(startupServer)).To(Succeed())
|
||||||
|
Expect(testutil.K3sCleanup(-1, "")).To(Succeed())
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
var failed bool
|
var failed bool
|
||||||
|
|
Loading…
Reference in New Issue