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:
parent
3b32480d45
commit
e4a66b0373
5 changed files with 36 additions and 42 deletions
|
|
@ -16,8 +16,7 @@ import (
|
|||
)
|
||||
|
||||
type KojiFinalizeJobImpl struct {
|
||||
KojiServers map[string]kojiServer
|
||||
relaxTimeoutFactor uint
|
||||
KojiServers map[string]kojiServer
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -12,12 +12,10 @@ import (
|
|||
)
|
||||
|
||||
type KojiInitJobImpl struct {
|
||||
KojiServers map[string]kojiServer
|
||||
relaxTimeoutFactor uint
|
||||
KojiServers map[string]kojiServer
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@ import (
|
|||
)
|
||||
|
||||
type OSBuildKojiJobImpl struct {
|
||||
Store string
|
||||
Output string
|
||||
KojiServers map[string]kojiServer
|
||||
relaxTimeoutFactor uint
|
||||
Store string
|
||||
Output string
|
||||
KojiServers map[string]kojiServer
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,15 +39,14 @@ type S3Configuration struct {
|
|||
}
|
||||
|
||||
type OSBuildJobImpl struct {
|
||||
Store string
|
||||
Output string
|
||||
KojiServers map[string]kojiServer
|
||||
KojiRelaxTimeoutFactor uint
|
||||
GCPCreds string
|
||||
AzureCreds *azure.Credentials
|
||||
AWSCreds string
|
||||
AWSBucket string
|
||||
S3Config S3Configuration
|
||||
Store string
|
||||
Output string
|
||||
KojiServers map[string]kojiServer
|
||||
GCPCreds string
|
||||
AzureCreds *azure.Credentials
|
||||
AWSCreds string
|
||||
AWSBucket string
|
||||
S3Config S3Configuration
|
||||
}
|
||||
|
||||
// Returns an *awscloud.AWS object with the credentials of the request. If they
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ type connectionConfig struct {
|
|||
}
|
||||
|
||||
type kojiServer struct {
|
||||
creds koji.GSSAPICredentials
|
||||
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,9 +233,8 @@ 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"`
|
||||
BasePath string `toml:"base_path"`
|
||||
DNFJson string `toml:"dnf-json"`
|
||||
}
|
||||
var unix bool
|
||||
flag.BoolVar(&unix, "unix", false, "Interpret 'address' as a path to a unix domain socket instead of a network address")
|
||||
|
|
@ -287,6 +288,7 @@ func main() {
|
|||
Principal: kojiConfig.Kerberos.Principal,
|
||||
KeyTab: kojiConfig.Kerberos.KeyTab,
|
||||
},
|
||||
relaxTimeoutFactor: kojiConfig.RelaxTimeoutFactor,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -455,14 +457,13 @@ func main() {
|
|||
// non-depsolve job
|
||||
jobImpls := map[string]JobImplementation{
|
||||
worker.JobTypeOSBuild: &OSBuildJobImpl{
|
||||
Store: store,
|
||||
Output: output,
|
||||
KojiServers: kojiServers,
|
||||
KojiRelaxTimeoutFactor: config.RelaxTimeoutFactor,
|
||||
GCPCreds: gcpCredentials,
|
||||
AzureCreds: azureCredentials,
|
||||
AWSCreds: awsCredentials,
|
||||
AWSBucket: awsBucket,
|
||||
Store: store,
|
||||
Output: output,
|
||||
KojiServers: kojiServers,
|
||||
GCPCreds: gcpCredentials,
|
||||
AzureCreds: azureCredentials,
|
||||
AWSCreds: awsCredentials,
|
||||
AWSBucket: awsBucket,
|
||||
S3Config: S3Configuration{
|
||||
Creds: genericS3Credentials,
|
||||
Endpoint: genericS3Endpoint,
|
||||
|
|
@ -473,18 +474,15 @@ func main() {
|
|||
},
|
||||
},
|
||||
worker.JobTypeOSBuildKoji: &OSBuildKojiJobImpl{
|
||||
Store: store,
|
||||
Output: output,
|
||||
KojiServers: kojiServers,
|
||||
relaxTimeoutFactor: config.RelaxTimeoutFactor,
|
||||
Store: store,
|
||||
Output: output,
|
||||
KojiServers: kojiServers,
|
||||
},
|
||||
worker.JobTypeKojiInit: &KojiInitJobImpl{
|
||||
KojiServers: kojiServers,
|
||||
relaxTimeoutFactor: config.RelaxTimeoutFactor,
|
||||
KojiServers: kojiServers,
|
||||
},
|
||||
worker.JobTypeKojiFinalize: &KojiFinalizeJobImpl{
|
||||
KojiServers: kojiServers,
|
||||
relaxTimeoutFactor: config.RelaxTimeoutFactor,
|
||||
KojiServers: kojiServers,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue