osbuild-worker: add CHANNEL to worker logs
aka "the deployment channel" like "staging" or "production"
This commit is contained in:
parent
2519e55ccd
commit
8d24dcfbde
4 changed files with 22 additions and 0 deletions
|
|
@ -103,6 +103,8 @@ type workerConfig struct {
|
||||||
// default value: &{ Type: host }
|
// default value: &{ Type: host }
|
||||||
OSBuildExecutor *executorConfig `toml:"osbuild_executor"`
|
OSBuildExecutor *executorConfig `toml:"osbuild_executor"`
|
||||||
RepositoryMTLSConfig *repositoryMTLSConfig `toml:"repository_mtls"`
|
RepositoryMTLSConfig *repositoryMTLSConfig `toml:"repository_mtls"`
|
||||||
|
// something like "production" or "staging" to be added to logging
|
||||||
|
DeploymentChannel string `toml:"deployment_channel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseConfig(file string) (*workerConfig, error) {
|
func parseConfig(file string) (*workerConfig, error) {
|
||||||
|
|
@ -112,6 +114,7 @@ func parseConfig(file string) (*workerConfig, error) {
|
||||||
OSBuildExecutor: &executorConfig{
|
OSBuildExecutor: &executorConfig{
|
||||||
Type: "host",
|
Type: "host",
|
||||||
},
|
},
|
||||||
|
DeploymentChannel: "local",
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := toml.DecodeFile(file, &config)
|
_, err := toml.DecodeFile(file, &config)
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ cloudwatch_group = "osbuild-worker"
|
||||||
Credentials: "/etc/osbuild-worker/pulp-creds",
|
Credentials: "/etc/osbuild-worker/pulp-creds",
|
||||||
ServerURL: "https://example.com/pulp",
|
ServerURL: "https://example.com/pulp",
|
||||||
},
|
},
|
||||||
|
DeploymentChannel: "local",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -146,6 +147,18 @@ cloudwatch_group = "osbuild-worker"
|
||||||
OSBuildExecutor: &executorConfig{
|
OSBuildExecutor: &executorConfig{
|
||||||
Type: "host",
|
Type: "host",
|
||||||
},
|
},
|
||||||
|
DeploymentChannel: "local",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "set_channel",
|
||||||
|
config: `deployment_channel = "staging"`,
|
||||||
|
want: &workerConfig{
|
||||||
|
BasePath: "/api/worker/v1",
|
||||||
|
OSBuildExecutor: &executorConfig{
|
||||||
|
Type: "host",
|
||||||
|
},
|
||||||
|
DeploymentChannel: "staging",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
slogger "github.com/osbuild/osbuild-composer/pkg/splunk_logger"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
@ -193,6 +194,10 @@ func main() {
|
||||||
logrus.Fatalf("Could not print config: %v", err)
|
logrus.Fatalf("Could not print config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.DeploymentChannel != "" {
|
||||||
|
logrus.AddHook(&slogger.EnvironmentHook{Channel: config.DeploymentChannel})
|
||||||
|
}
|
||||||
|
|
||||||
cacheDirectory, ok := os.LookupEnv("CACHE_DIRECTORY")
|
cacheDirectory, ok := os.LookupEnv("CACHE_DIRECTORY")
|
||||||
if !ok {
|
if !ok {
|
||||||
logrus.Fatal("CACHE_DIRECTORY is not set. Is the service file missing CacheDirectory=?")
|
logrus.Fatal("CACHE_DIRECTORY is not set. Is the service file missing CacheDirectory=?")
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ jq -r ".client_secret" /tmp/client-credentials.json > /etc/osbuild-worker/client
|
||||||
rm -f /tmp/client-credentials.json
|
rm -f /tmp/client-credentials.json
|
||||||
|
|
||||||
sudo tee -a /etc/osbuild-worker/osbuild-worker.toml > /dev/null << EOF
|
sudo tee -a /etc/osbuild-worker/osbuild-worker.toml > /dev/null << EOF
|
||||||
|
deployment_channel = "${CHANNEL:-local}"
|
||||||
[authentication]
|
[authentication]
|
||||||
oauth_url = "${TOKEN_URL:-https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token}"
|
oauth_url = "${TOKEN_URL:-https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token}"
|
||||||
client_id = "${CLIENT_ID}"
|
client_id = "${CLIENT_ID}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue