Skip to content

Commit c9809df

Browse files
authored
fix(mc2mc): logview to use public host (#86)
fix: logview to use public host
1 parent 250ea6a commit c9809df

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

mc2mc/internal/client/odps.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
e "errors"
66
"fmt"
77
"log/slog"
8+
"net/url"
89
"strings"
910
"time"
1011

@@ -46,7 +47,7 @@ func (c *odpsClient) ExecSQL(ctx context.Context, query string, additionalHints
4647
}
4748

4849
// generate log view
49-
url, err := odps.NewLogView(c.client).GenerateLogView(taskIns, c.logViewRetentionInDays*24)
50+
url, err := c.generateLogView(taskIns)
5051
if err != nil {
5152
err = e.Join(err, taskIns.Terminate())
5253
return errors.WithStack(err)
@@ -109,6 +110,28 @@ func (c *odpsClient) GetOrderedColumns(tableID string) ([]string, error) {
109110
return columnNames, nil
110111
}
111112

113+
// generateLogView generates the log view for the given task instance
114+
func (c *odpsClient) generateLogView(taskIns *odps.Instance) (string, error) {
115+
u, err := c.client.LogView().GenerateLogView(taskIns, c.logViewRetentionInDays*24)
116+
if err != nil {
117+
return "", errors.WithStack(err)
118+
}
119+
120+
// change query parameter h to http://service.id-all.maxcompute.aliyun-inc.com
121+
parsedURL, err := url.Parse(u)
122+
if err != nil {
123+
return "", errors.WithStack(err)
124+
}
125+
q := parsedURL.Query()
126+
q.Set("h", "http://service.id-all.maxcompute.aliyun-inc.com/api")
127+
128+
// reconstruct the URL with the new query parameter
129+
parsedURL.RawQuery = q.Encode()
130+
u = parsedURL.String()
131+
132+
return u, nil
133+
}
134+
112135
// wait waits for the task instance to finish on a separate goroutine
113136
func (c *odpsClient) wait(taskIns *odps.Instance) <-chan error {
114137
errChan := make(chan error)

0 commit comments

Comments
 (0)