worker: clean up the RelaxTimeoutFactor

This commit moves the field to the koji struct where it actually belongs.
Also, it renames it to relax_timeout_factor for the sake of consistency.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-06-28 12:11:00 +02:00 committed by Tom Gundersen
parent 3b32480d45
commit e4a66b0373
5 changed files with 36 additions and 42 deletions

View file

@ -17,7 +17,6 @@ import (
type KojiFinalizeJobImpl struct {
KojiServers map[string]kojiServer
relaxTimeoutFactor uint
}
func (impl *KojiFinalizeJobImpl) kojiImport(
@ -26,7 +25,6 @@ func (impl *KojiFinalizeJobImpl) kojiImport(
buildRoots []koji.BuildRoot,
images []koji.Image,
directory, token string) error {
transport := koji.CreateKojiTransport(impl.relaxTimeoutFactor)
serverURL, err := url.Parse(server)
if err != nil {
@ -38,6 +36,7 @@ func (impl *KojiFinalizeJobImpl) kojiImport(
return fmt.Errorf("Koji server has not been configured: %s", serverURL.Hostname())
}
transport := koji.CreateKojiTransport(kojiServer.relaxTimeoutFactor)
k, err := koji.NewFromGSSAPI(server, &kojiServer.creds, transport)
if err != nil {
return err
@ -58,7 +57,6 @@ func (impl *KojiFinalizeJobImpl) kojiImport(
}
func (impl *KojiFinalizeJobImpl) kojiFail(server string, buildID int, token string) error {
transport := koji.CreateKojiTransport(impl.relaxTimeoutFactor)
serverURL, err := url.Parse(server)
if err != nil {
@ -70,6 +68,7 @@ func (impl *KojiFinalizeJobImpl) kojiFail(server string, buildID int, token stri
return fmt.Errorf("Koji server has not been configured: %s", serverURL.Hostname())
}
transport := koji.CreateKojiTransport(kojiServer.relaxTimeoutFactor)
k, err := koji.NewFromGSSAPI(server, &kojiServer.creds, transport)
if err != nil {
return err

View file

@ -13,11 +13,9 @@ import (
type KojiInitJobImpl struct {
KojiServers map[string]kojiServer
relaxTimeoutFactor uint
}
func (impl *KojiInitJobImpl) kojiInit(server, name, version, release string) (string, uint64, error) {
transport := koji.CreateKojiTransport(impl.relaxTimeoutFactor)
serverURL, err := url.Parse(server)
if err != nil {
@ -29,6 +27,7 @@ func (impl *KojiInitJobImpl) kojiInit(server, name, version, release string) (st
return "", 0, fmt.Errorf("Koji server has not been configured: %s", serverURL.Hostname())
}
transport := koji.CreateKojiTransport(kojiServer.relaxTimeoutFactor)
k, err := koji.NewFromGSSAPI(server, &kojiServer.creds, transport)
if err != nil {
return "", 0, err

View file

@ -19,11 +19,9 @@ type OSBuildKojiJobImpl struct {
Store string
Output string
KojiServers map[string]kojiServer
relaxTimeoutFactor uint
}
func (impl *OSBuildKojiJobImpl) kojiUpload(file *os.File, server, directory, filename string) (string, uint64, error) {
transport := koji.CreateKojiTransport(impl.relaxTimeoutFactor)
serverURL, err := url.Parse(server)
if err != nil {
@ -31,6 +29,7 @@ func (impl *OSBuildKojiJobImpl) kojiUpload(file *os.File, server, directory, fil
}
kojiServer, exists := impl.KojiServers[serverURL.Hostname()]
transport := koji.CreateKojiTransport(kojiServer.relaxTimeoutFactor)
if !exists {
return "", 0, fmt.Errorf("Koji server has not been configured: %s", serverURL.Hostname())
}

View file

@ -42,7 +42,6 @@ type OSBuildJobImpl struct {
Store string
Output string
KojiServers map[string]kojiServer
KojiRelaxTimeoutFactor uint
GCPCreds string
AzureCreds *azure.Credentials
AWSCreds string
@ -734,7 +733,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
return nil
}
kojiTransport := koji.CreateKojiTransport(impl.KojiRelaxTimeoutFactor)
kojiTransport := koji.CreateKojiTransport(kojiServer.relaxTimeoutFactor)
kojiAPI, err := koji.NewFromGSSAPI(options.Server, &kojiServer.creds, kojiTransport)
if err != nil {

View file

@ -39,6 +39,7 @@ type connectionConfig struct {
type kojiServer struct {
creds koji.GSSAPICredentials
relaxTimeoutFactor uint
}
// Represents the implementation of a job type as defined by the worker API.
@ -206,6 +207,7 @@ func main() {
Principal string `toml:"principal"`
KeyTab string `toml:"keytab"`
} `toml:"kerberos,omitempty"`
RelaxTimeoutFactor uint `toml:"relax_timeout_factor"`
} `toml:"koji"`
GCP *struct {
Credentials string `toml:"credentials"`
@ -231,7 +233,6 @@ func main() {
ClientId string `toml:"client_id"`
ClientSecretPath string `toml:"client_secret"`
} `toml:"authentication"`
RelaxTimeoutFactor uint `toml:"RelaxTimeoutFactor"` // Should be moved under 'koji' section
BasePath string `toml:"base_path"`
DNFJson string `toml:"dnf-json"`
}
@ -287,6 +288,7 @@ func main() {
Principal: kojiConfig.Kerberos.Principal,
KeyTab: kojiConfig.Kerberos.KeyTab,
},
relaxTimeoutFactor: kojiConfig.RelaxTimeoutFactor,
}
}
@ -458,7 +460,6 @@ func main() {
Store: store,
Output: output,
KojiServers: kojiServers,
KojiRelaxTimeoutFactor: config.RelaxTimeoutFactor,
GCPCreds: gcpCredentials,
AzureCreds: azureCredentials,
AWSCreds: awsCredentials,
@ -476,15 +477,12 @@ func main() {
Store: store,
Output: output,
KojiServers: kojiServers,
relaxTimeoutFactor: config.RelaxTimeoutFactor,
},
worker.JobTypeKojiInit: &KojiInitJobImpl{
KojiServers: kojiServers,
relaxTimeoutFactor: config.RelaxTimeoutFactor,
},
worker.JobTypeKojiFinalize: &KojiFinalizeJobImpl{
KojiServers: kojiServers,
relaxTimeoutFactor: config.RelaxTimeoutFactor,
},
}