feat(cli): force write to readonly cluster

. #1000172452

Signed-off-by: slasher <shenjie1@oppo.com>
This commit is contained in:
slasher 2025-06-16 10:45:40 +08:00
parent 2352cfd075
commit ab2bb21e70
2 changed files with 18 additions and 0 deletions

View File

@ -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}

View File

@ -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",