koji: fix excessive logging & monitoring

update koji init & finalize to use custom leveled logging
This is mainly affects logging, but it also changes functionality slightly
since init & finalize are now using the customCheckRetry, they are able
to retry the "TLS timeout" error.
This commit is contained in:
Diaa Sami 2022-03-30 13:34:07 +02:00 committed by Diaa Sami
parent 7c4d74481a
commit e773d4896b
2 changed files with 9 additions and 4 deletions

View file

@ -8,7 +8,6 @@ import (
"time"
"github.com/google/uuid"
"github.com/hashicorp/go-retryablehttp"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/upload/koji"
"github.com/sirupsen/logrus"
@ -42,7 +41,7 @@ func main() {
}
defer file.Close()
transport := &retryablehttp.RoundTripper{}
transport := koji.CreateRetryableTransport()
k, err := koji.NewFromPlain(server, "osbuild", "osbuildpass", transport)
if err != nil {
println(err.Error())

View file

@ -162,7 +162,7 @@ func NewFromPlain(server, user, password string, transport http.RoundTripper) (*
// The API doesn't require sessionID, sessionKey and callnum yet,
// so there's no need to use the custom Koji RoundTripper,
// let's just use the one that the called passed in.
rhTransport := &rh.RoundTripper{Client: rh.NewClient()}
rhTransport := CreateRetryableTransport()
loginClient, err := xmlrpc.NewClient(server, rhTransport)
if err != nil {
return nil, err
@ -443,7 +443,7 @@ func GSSAPICredentialsFromEnv() (*GSSAPICredentials, error) {
func CreateKojiTransport(relaxTimeout uint) http.RoundTripper {
// Koji for some reason needs TLS renegotiation enabled.
// Clone the default http rt and enable renegotiation.
rt := &rh.RoundTripper{Client: rh.NewClient()}
rt := CreateRetryableTransport()
transport := rt.Client.HTTPClient.Transport.(*http.Transport)
@ -487,3 +487,9 @@ func createCustomRetryableClient() *rh.Client {
client.CheckRetry = customCheckRetry
return client
}
func CreateRetryableTransport() *rh.RoundTripper {
rt := rh.RoundTripper{}
rt.Client = createCustomRetryableClient()
return &rt
}