mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
feat(cli): force write to readonly cluster
. #1000172452 Signed-off-by: slasher <shenjie1@oppo.com>
This commit is contained in:
parent
2352cfd075
commit
ab2bb21e70
@ -38,6 +38,9 @@ import (
|
||||
"github.com/cubefs/cubefs/blobstore/util/log"
|
||||
)
|
||||
|
||||
// just for cli write to readonly initialised cluster.
|
||||
var ForceWriteReadonlyCluster = false
|
||||
|
||||
// AlgChoose algorithm of choose cluster
|
||||
type AlgChoose uint32
|
||||
|
||||
@ -265,6 +268,9 @@ func (c *clusterControllerImpl) loadWithConfig() error {
|
||||
clusterInfo.Available = stat.BlobNodeSpaceStat.WritableSpace
|
||||
clusterInfo.Nodes = cs.Hosts
|
||||
clusterInfo.Readonly = stat.ReadOnly
|
||||
if clusterInfo.Readonly && ForceWriteReadonlyCluster {
|
||||
clusterInfo.Readonly = false
|
||||
}
|
||||
|
||||
allClusters[cs.ClusterID] = &cluster{client: cmCli, clusterInfo: clusterInfo}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ import (
|
||||
"github.com/desertbit/grumble"
|
||||
"github.com/hashicorp/consul/api"
|
||||
|
||||
"github.com/cubefs/cubefs/blobstore/access/controller"
|
||||
"github.com/cubefs/cubefs/blobstore/access/stream"
|
||||
"github.com/cubefs/cubefs/blobstore/api/access"
|
||||
"github.com/cubefs/cubefs/blobstore/cli/common"
|
||||
@ -163,6 +164,17 @@ func Register(app *grumble.App) {
|
||||
}
|
||||
app.AddCommand(accessCommand)
|
||||
|
||||
accessCommand.AddCommand(&grumble.Command{
|
||||
Name: "writereadonly",
|
||||
Help: "force write to readonly cluster",
|
||||
Run: func(c *grumble.Context) error {
|
||||
controller.ForceWriteReadonlyCluster = c.Flags.Bool("forcewrite")
|
||||
return nil
|
||||
},
|
||||
Flags: func(f *grumble.Flags) {
|
||||
f.BoolL("forcewrite", false, "force write to readonly cluster")
|
||||
},
|
||||
})
|
||||
accessCommand.AddCommand(&grumble.Command{
|
||||
Name: "put",
|
||||
Help: "put file",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user