Skip to content

Commit

Permalink
logs back working
Browse files Browse the repository at this point in the history
  • Loading branch information
dciangot committed Nov 30, 2023
1 parent a886be2 commit 9870d13
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func main() {
//ILbindOld := false

for {
err, _ = commonIL.PingInterLink()
err, _ = commonIL.PingInterLink(ctx)

if err != nil {
log.G(ctx).Error(err)
Expand Down
9 changes: 5 additions & 4 deletions pkg/common/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,17 @@ func NewServiceAccount() error {
return nil
}

func PingInterLink() (error, bool) {
func PingInterLink(ctx context.Context) (error, bool) {
log.G(ctx).Info("Pinging: " + InterLinkConfigInst.Interlinkurl + ":" + InterLinkConfigInst.Interlinkport + "/ping")
req, err := http.NewRequest(http.MethodPost, InterLinkConfigInst.Interlinkurl+":"+InterLinkConfigInst.Interlinkport+"/ping", nil)

if err != nil {
log.G(context.Background()).Error(err)
log.G(ctx).Error(err)
}

token, err := os.ReadFile(InterLinkConfigInst.VKTokenFile) // just pass the file name
if err != nil {
log.G(context.Background()).Error(err)
log.G(ctx).Error(err)
return err, false
}
req.Header.Add("Authorization", "Bearer "+string(token))
Expand All @@ -258,7 +259,7 @@ func PingInterLink() (error, bool) {
if resp.StatusCode == http.StatusOK {
return nil, true
} else {
log.G(context.Background()).Error("Error " + err.Error() + " " + fmt.Sprint(resp.StatusCode))
log.G(ctx).Error("Error " + err.Error() + " " + fmt.Sprint(resp.StatusCode))
return nil, false
}
}
5 changes: 5 additions & 0 deletions pkg/interlink/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func GetLogsHandler(w http.ResponseWriter, r *http.Request) {
log.G(Ctx).Fatal(err)
}

log.G(Ctx).Info("InterLink: unmarshal GetLogs request")
var req2 commonIL.LogStruct //incoming request. To be used in interlink API. req is directly forwarded to sidecar
err = json.Unmarshal(bodyBytes, &req2)
if err != nil {
Expand All @@ -30,6 +31,7 @@ func GetLogsHandler(w http.ResponseWriter, r *http.Request) {
return
}

log.G(Ctx).Info("InterLink: get GetLogs podUID: now ", string(req2.PodUID))
pod, err := Clientset.CoreV1().Pods(req2.Namespace).Get(Ctx, req2.PodName, metav1.GetOptions{})
if err != nil {
statusCode = http.StatusInternalServerError
Expand All @@ -39,6 +41,7 @@ func GetLogsHandler(w http.ResponseWriter, r *http.Request) {
}
req2.PodUID = string(pod.UID)

log.G(Ctx).Info("InterLink: new GetLogs podUID: now ", string(req2.PodUID))
if (req2.Opts.Tail != 0 && req2.Opts.LimitBytes != 0) || (req2.Opts.SinceSeconds != 0 && !req2.Opts.SinceTime.IsZero()) {
statusCode = http.StatusInternalServerError
w.WriteHeader(statusCode)
Expand All @@ -51,6 +54,8 @@ func GetLogsHandler(w http.ResponseWriter, r *http.Request) {
return
}

log.G(Ctx).Info("InterLink: marshal GetLogs request ")

bodyBytes, err = json.Marshal(req2)
if err != nil {
statusCode = http.StatusInternalServerError
Expand Down
1 change: 1 addition & 0 deletions pkg/sidecars/slurm/Status.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func StatusHandler(w http.ResponseWriter, r *http.Request) {
execReturn, _ := shell.Execute()
timeNow = time.Now()

log.G(Ctx).Info("ERR: ", execReturn.Stderr)
if execReturn.Stderr != "" {
containerStatuses := []v1.ContainerStatus{}
for _, ct := range pod.Spec.Containers {
Expand Down

0 comments on commit 9870d13

Please sign in to comment.