Skip to content

Commit

Permalink
adding GH rate limits logs
Browse files Browse the repository at this point in the history
  • Loading branch information
leoporoli committed Jan 2, 2024
1 parent ba554c0 commit 0bd1e99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rules

import (
"context"
"errors"
"fmt"
"github.com/google/go-github/v54/github"
"github.com/kurtosis-tech/kurtosis-package-indexer/server/catalog"
Expand Down Expand Up @@ -120,7 +121,12 @@ func (validPackageIconRule *validPackageIconRule) getPackageIconImageConfig(ctx
// having the icon is not mandatory
return nil, nil
}
return nil, stacktrace.Propagate(err, "an error occurred reading content of Kurtosis Package '%s' - file '%s'", packageName, packageIconFilepath)
errMsj := fmt.Sprintf("an error occurred reading content of Kurtosis Package '%s' - file '%s'", packageName, packageIconFilepath)
if errors.Is(err, &github.RateLimitError{}) {
errMsj = "GitHub API rate limit exceeded."
logrus.Errorf("%s Error is:\n%v", errMsj, err.Error())
}
return nil, stacktrace.Propagate(err, errMsj)
}

rawPackageIconContentStr, err := packageIconFileContentResult.GetContent()
Expand Down
8 changes: 7 additions & 1 deletion catalog-validator/validation/rules/valid_package_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rules

import (
"context"
"errors"
"fmt"
"github.com/google/go-github/v54/github"
"github.com/kurtosis-tech/kurtosis-package-indexer/server/catalog"
Expand Down Expand Up @@ -87,7 +88,12 @@ func (validPackageRule *validPackageRule) getPackageNameFromKurtosisYmlFile(ctx
if err != nil && resp != nil && resp.StatusCode == http.StatusNotFound {
return "", stacktrace.NewError("No '%s' file for package '%s'", kurtosisYamlFilepath, packageName)
} else if err != nil {
return "", stacktrace.Propagate(err, "An error occurred reading content of Kurtosis Package '%s' - file '%s'", packageName, kurtosisYamlFilepath)
errMsj := fmt.Sprintf("An error occurred reading content of Kurtosis Package '%s' - file '%s'", packageName, kurtosisYamlFilepath)
if errors.Is(err, &github.RateLimitError{}) {
errMsj = "GitHub API rate limit exceeded."
logrus.Errorf("%s Error is:\n%v", errMsj, err.Error())
}
return "", stacktrace.Propagate(err, "%s", errMsj)
}

kurtosisYaml, err := parseKurtosisYaml(kurtosisYamlFileContentResult)
Expand Down

0 comments on commit 0bd1e99

Please sign in to comment.