Skip to content

[feat] add http deployment method#365

Open
liuminjian wants to merge 1 commit into
opencurve:developfrom
liuminjian:feat/http
Open

[feat] add http deployment method#365
liuminjian wants to merge 1 commit into
opencurve:developfrom
liuminjian:feat/http

Conversation

@liuminjian

@liuminjian liuminjian commented Nov 24, 2023

Copy link
Copy Markdown

Issue Number: #328

1.增加http daemon的部署方式,host增加protocol和http port字段
image
image

2.在每个host节点上部署http daemon
image

3.部署http daemon后能正常部署curve集群
image

image image

遗留问题:目前enter指令不支持http方式

@liuminjian liuminjian force-pushed the feat/http branch 2 times, most recently from 6c5c13f to 9624e34 Compare November 24, 2023 02:04
@caoxianfei1

Copy link
Copy Markdown

@liuminjian BTW, we can provide command curveadm http start/stop is better? And the http service commit has already done.
So you can refer the commit.

@liuminjian

Copy link
Copy Markdown
Author

@liuminjian BTW, we can provide command curveadm http start/stop is better? And the http service commit has already done. So you can refer the commit.

ok

Comment thread internal/task/task/bs/add_target.go Outdated

subname := fmt.Sprintf("host=%s volume=%s", options.Host, volume)
t := task.NewTask("Add Target", subname, hc.GetSSHConfig())
t := task.NewTask("Add Target", subname, hc.GetSSHConfig(), hc.GetHttpConfig())

@Wine93 Wine93 Nov 29, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 GetSSHConfigGetHttpConfig 可以合并成一个函数,比如 GetConnectConfig,然后在 NewTask 里面再做处理,这样后续有其他的连接方式控制,扩展性也会好一些。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW:尽可能保持变量命名方式的一致性,比如用大写,那么可以用 SSHHTTP,或者都用 sshhttp

Comment thread internal/task/task/bs/balance_leader.go Outdated
subname := fmt.Sprintf("host=%s role=%s containerId=%s",
dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId))
t := task.NewTask("Balance Leader", subname, hc.GetSSHConfig())
t := task.NewTask("Balance Leader", subname, hc.GetSSHConfig(), hc.GetHttpConfig())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Comment thread cli/command/http/cmd.go
@@ -0,0 +1,44 @@
/*

@Wine93 Wine93 Nov 29, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个命令我认为叫 deamon 更好一些。
另外目前的做法是安装 pigeon 二进制,然后在 http start 时启动这个二进制,其实这是没必要的,我们可以把 pigeon 的 start 命令逻辑复制到 http start 这个命令中,详见:pigeon start

目前:

curveadm http start -> pigeon start 

期待:

curveadm deamon start

Comment thread http/core/core.go
@@ -0,0 +1,71 @@
/*

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 HTTP 的核心逻辑建议移动到 internal 目录下,建议叫 daemon

Comment thread scripts/install.sh Outdated


# generate http service config file
local httpConfpath="${g_curveadm_home}/conf/pigeon.yaml"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议在 curveadm 的主目录下新建一个 deamon 目录,配置文件 pigeon.yaml 以及一些 daemon 的日志都可以放到这个目录下

Comment thread cli/command/daemon/cmd.go Outdated
/*
* Project: Curveadm
* Created Date: 2023-03-31
* Author: wanghai (SeanHai)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的作者建议改一下~

Comment thread cli/command/daemon/cmd.go Outdated
func NewDaemonCommand(curveadm *cli.CurveAdm) *cobra.Command {
cmd := &cobra.Command{
Use: "daemon",
Short: "Manage http service",

@Wine93 Wine93 Dec 13, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manage deamon service

Comment thread cli/command/cmd.go Outdated
target.NewTargetCommand(curveadm), // curveadm target ...
pfs.NewPFSCommand(curveadm), // curveadm pfs ...
monitor.NewMonitorCommand(curveadm), // curveadm monitor ...
daemon.NewDaemonCommand(curveadm), // curveadm http

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curveadm deamon ...

Comment thread Makefile Outdated

# output
OUTPUT := bin/curveadm
SERVER_OUTPUT := bin/pigeon

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是不需要了?

@liuminjian liuminjian force-pushed the feat/http branch 2 times, most recently from d51ef71 to a7b3b84 Compare December 13, 2023 08:35
Comment thread cli/command/daemon/stop.go Outdated
/*
* Project: Curveadm
* Created Date: 2023-03-31
* Author: wanghai (SeanHai)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment thread cli/command/daemon/start.go Outdated
/*
* Project: Curveadm
* Created Date: 2023-03-31
* Author: wanghai (SeanHai)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment thread cli/command/daemon/stop.go Outdated

cmd := &cobra.Command{
Use: "stop",
Short: "Stop http service",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop deamon service

Comment thread cli/command/daemon/start.go Outdated

cmd := &cobra.Command{
Use: "start [OPTIONS]",
Short: "Start http service",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start deamon service

Comment thread cli/command/daemon/cmd.go Outdated
*/

/*
* Project: Curveadm

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CurveAdm

Comment thread cli/command/daemon/start.go Outdated
*/

/*
* Project: Curveadm

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Comment thread cli/command/daemon/stop.go Outdated
*/

/*
* Project: Curveadm

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Comment thread cli/command/daemon/stop.go Outdated

const (
STOP_EXAMPLR = `Examples:
$ curveadm daemon stop -c ~/.curveadm/daemon/config/pigeon.yaml # Stop an daemon http service`

@Wine93 Wine93 Dec 19, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ curveadm daemon stop  # Stop daemon service

Comment thread cli/command/daemon/start.go Outdated

const (
START_EXAMPLR = `Examples:
$ curveadm daemon start -c ~/.curveadm/daemon/config/pigeon.yaml # Start an daemon http service to receive requests`

@Wine93 Wine93 Dec 19, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ curveadm daemon start   # Start daemon service

Comment thread internal/configure/hosts/hc_get.go Outdated

func (hc *HostConfig) GetProtocol() string { return hc.getString(CONFIG_PROTOCOL) }
func (hc *HostConfig) GetSSHConfig() *module.SSHConfig {

@Wine93 Wine93 Dec 19, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多余的空格.

Comment thread internal/configure/hosts/hc_get.go Outdated
}

func (hc *HostConfig) GetHTTPConfig() *module.HTTPConfig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

}
}

func (hc *HostConfig) GetConnectConfig() *module.ConnectConfig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既然有了 GetConnectConfig 函数,GetSSHConfigGetHTTPConfig 这 2 个函数应该可以移除了.

* 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.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议加上 Author 等相关信息。

* See the License for the specific language governing permissions and
* limitations under the License.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

* See the License for the specific language governing permissions and
* limitations under the License.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Comment thread internal/daemon/server.go
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Comment thread pkg/module/http.go
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Comment thread pkg/module/http.go Outdated
@@ -0,0 +1,166 @@
/*
* Copyright (c) 2021 NetEase Inc.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2021 -> 2023.

Comment thread pkg/module/remote_client.go Outdated
return
}

if cfg.Protocol == SSH_PROTOCOL {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的逻辑可以简化一下:

if cfg.Protocol == HTTP_PROTOCOL {
    client, err = NewHTTPClient(*cfg.GetHTTPConfig())
} else {
    client, err = NewSSHClient(*cfg.GetSSHConfig())
}

if (err != nil) {
    ...
}
return client, err

Comment thread scripts/install.sh
url = "${g_db_path}"
__EOF__
fi

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多余的空格

Comment thread pkg/module/http.go Outdated
}

func (client *HttpClient) Upload(localPath string, remotePath string) (err error) {
bodyBuf := &bytes.Buffer{}

@Wine93 Wine93 Dec 19, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 uploaddownload 都太麻烦了,可以看下 resty 库,这个模块只要准备要命令就可以了,客户端这些逻辑可以交给 resty 去处理。

Comment thread pkg/module/http.go Outdated
}

func (client *HttpClient) RunCommand(ctx context.Context, command string) (out []byte, err error) {
data := make(map[string]interface{})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Comment thread scripts/install.sh


# generate http service config file
local httpConfpath="${g_curveadm_home}/daemon/conf/pigeon.yaml"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个逻辑可以单独拆成一个函数,包括上面的 curveadm.cfg 都可以单独拆一下。

@caoxianfei1

Copy link
Copy Markdown

@liuminjian please fix the conflict.

@liuminjian liuminjian force-pushed the feat/http branch 2 times, most recently from 07fda7a to 36353d1 Compare December 26, 2023 02:15
Signed-off-by: liuminjian <liuminjian@chinatelecom.cn>
@liuminjian

Copy link
Copy Markdown
Author

@caoxianfei1 fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants