
The add-on code was copy-pasted from other addons and used the GPL v2 license, whereas by accident the LICENSE text file had the GNU "Affero" GPL license v3 (instead of regular GPL v3). This is now all streamlined, and all code is licensed as "GPL v3 or later". Furthermore, the code comments just show a SPDX License Identifier instead of an entire license block.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package worker
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"git.blender.org/flamenco/pkg/api"
|
|
)
|
|
|
|
// queryManagerForStateChange asks the Manager whether we should go to another state or not.
|
|
// Any error communicating with the Manager is logged but otherwise ignored.
|
|
// Returns nil when no state change is requested.
|
|
func (w *Worker) queryManagerForStateChange(ctx context.Context) *api.WorkerStatus {
|
|
resp, err := w.client.WorkerStateWithResponse(ctx)
|
|
if err != nil {
|
|
log.Warn().Err(err).Msg("error checking upstream state changes")
|
|
return nil
|
|
}
|
|
switch {
|
|
case resp.JSON200 != nil:
|
|
log.Info().
|
|
Str("requestedStatus", string(resp.JSON200.StatusRequested)).
|
|
Msg("Manager requests status change")
|
|
return &resp.JSON200.StatusRequested
|
|
case resp.StatusCode() == http.StatusNoContent:
|
|
log.Debug().Msg("we can stay in the current state")
|
|
default:
|
|
log.Warn().
|
|
Int("code", resp.StatusCode()).
|
|
Str("error", string(resp.Body)).
|
|
Msg("unable to obtain requested state for unknown reason")
|
|
}
|
|
|
|
return nil
|
|
}
|