Skip to content

Commit

Permalink
Add support for alternate default_decoration_configs format that allo…
Browse files Browse the repository at this point in the history
…ws defaulting by cluster.
  • Loading branch information
cjwagner committed Jan 29, 2021
1 parent 012ac6b commit 5be9725
Show file tree
Hide file tree
Showing 20 changed files with 760 additions and 740 deletions.
12 changes: 6 additions & 6 deletions config/tests/jobs/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,23 +700,23 @@ func TestValidPresets(t *testing.T) {
}

for _, presubmit := range c.AllStaticPresubmits(nil) {
if presubmit.Spec != nil && !cfg.ShouldDecorate(&c.JobConfig, presubmit.JobBase.UtilityConfig) {
if presubmit.Spec != nil && !*presubmit.Decorate {
if err := checkKubekinsPresets(presubmit.Name, presubmit.Spec, presubmit.Labels, validLabels); err != nil {
t.Errorf("Error in presubmit %q: %v", presubmit.Name, err)
}
}
}

for _, postsubmit := range c.AllStaticPostsubmits(nil) {
if postsubmit.Spec != nil && !cfg.ShouldDecorate(&c.JobConfig, postsubmit.JobBase.UtilityConfig) {
if postsubmit.Spec != nil && !*postsubmit.Decorate {
if err := checkKubekinsPresets(postsubmit.Name, postsubmit.Spec, postsubmit.Labels, validLabels); err != nil {
t.Errorf("Error in postsubmit %q: %v", postsubmit.Name, err)
}
}
}

for _, periodic := range c.AllPeriodics() {
if periodic.Spec != nil && !cfg.ShouldDecorate(&c.JobConfig, periodic.JobBase.UtilityConfig) {
if periodic.Spec != nil && !*periodic.Decorate {
if err := checkKubekinsPresets(periodic.Name, periodic.Spec, periodic.Labels, validLabels); err != nil {
t.Errorf("Error in periodic %q: %v", periodic.Name, err)
}
Expand Down Expand Up @@ -902,23 +902,23 @@ func checkScenarioArgs(jobName, imageName string, args []string) error {
// TestValidScenarioArgs makes sure all scenario args in job configs are valid
func TestValidScenarioArgs(t *testing.T) {
for _, job := range c.AllStaticPresubmits(nil) {
if job.Spec != nil && !cfg.ShouldDecorate(&c.JobConfig, job.JobBase.UtilityConfig) {
if job.Spec != nil && !*job.Decorate {
if err := checkScenarioArgs(job.Name, job.Spec.Containers[0].Image, job.Spec.Containers[0].Args); err != nil {
t.Errorf("Invalid Scenario Args : %s", err)
}
}
}

for _, job := range c.AllStaticPostsubmits(nil) {
if job.Spec != nil && !cfg.ShouldDecorate(&c.JobConfig, job.JobBase.UtilityConfig) {
if job.Spec != nil && !*job.Decorate {
if err := checkScenarioArgs(job.Name, job.Spec.Containers[0].Image, job.Spec.Containers[0].Args); err != nil {
t.Errorf("Invalid Scenario Args : %s", err)
}
}
}

for _, job := range c.AllPeriodics() {
if job.Spec != nil && !cfg.ShouldDecorate(&c.JobConfig, job.JobBase.UtilityConfig) {
if job.Spec != nil && !*job.Decorate {
if err := checkScenarioArgs(job.Name, job.Spec.Containers[0].Image, job.Spec.Containers[0].Args); err != nil {
t.Errorf("Invalid Scenario Args : %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions prow/cmd/checkconfig/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,19 +805,19 @@ func ensureValidConfiguration(plugin, label, verb string, tideSubSet, tideSuperS
func validateDecoratedJobs(cfg *config.Config) error {
var nonDecoratedJobs []string
for _, presubmit := range cfg.AllStaticPresubmits([]string{}) {
if presubmit.Agent == string(v1.KubernetesAgent) && !config.ShouldDecorate(&cfg.JobConfig, presubmit.JobBase.UtilityConfig) {
if presubmit.Agent == string(v1.KubernetesAgent) && !*presubmit.JobBase.UtilityConfig.Decorate {
nonDecoratedJobs = append(nonDecoratedJobs, presubmit.Name)
}
}

for _, postsubmit := range cfg.AllStaticPostsubmits([]string{}) {
if postsubmit.Agent == string(v1.KubernetesAgent) && !config.ShouldDecorate(&cfg.JobConfig, postsubmit.JobBase.UtilityConfig) {
if postsubmit.Agent == string(v1.KubernetesAgent) && !*postsubmit.JobBase.UtilityConfig.Decorate {
nonDecoratedJobs = append(nonDecoratedJobs, postsubmit.Name)
}
}

for _, periodic := range cfg.AllPeriodics() {
if periodic.Agent == string(v1.KubernetesAgent) && !config.ShouldDecorate(&cfg.JobConfig, periodic.JobBase.UtilityConfig) {
if periodic.Agent == string(v1.KubernetesAgent) && !*periodic.JobBase.UtilityConfig.Decorate {
nonDecoratedJobs = append(nonDecoratedJobs, periodic.Name)
}
}
Expand Down
6 changes: 5 additions & 1 deletion prow/cmd/deck/pr_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ func getStorageDirsForPR(c *config.Config, gitHubClient deckGitHubClient, gitCli
gcsConfig = presubmit.DecorationConfig.GCSConfiguration
} else {
// for undecorated jobs assume the default
gcsConfig = c.Plank.GetDefaultDecorationConfigs(fullRepo).GCSConfiguration
def := c.Plank.MergeDefaultDecorationConfig(fullRepo, presubmit.Cluster, nil)
if def == nil || def.GCSConfiguration == nil {
return toSearch, fmt.Errorf("failed to guess gcs config based on default decoration config: %w", err)
}
gcsConfig = def.GCSConfiguration
}

gcsPath, _, _ := gcsupload.PathsForJob(gcsConfig, &downwardapi.JobSpec{
Expand Down
36 changes: 19 additions & 17 deletions prow/cmd/deck/pr_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,17 @@ func TestGetGCSDirsForPR(t *testing.T) {
config: &config.Config{
ProwConfig: config.ProwConfig{
Plank: config.Plank{
DefaultDecorationConfigs: map[string]*prowapi.DecorationConfig{
"*": {
GCSConfiguration: &prowapi.GCSConfiguration{
Bucket: "krusty-krab",
PathStrategy: "legacy",
DefaultOrg: "kubernetes",
DefaultRepo: "kubernetes",
DefaultDecorationConfigs: config.DefaultDecorationMapToSliceTesting(
map[string]*prowapi.DecorationConfig{
"*": {
GCSConfiguration: &prowapi.GCSConfiguration{
Bucket: "krusty-krab",
PathStrategy: "legacy",
DefaultOrg: "kubernetes",
DefaultRepo: "kubernetes",
},
},
},
},
}),
},
},
JobConfig: config.JobConfig{
Expand Down Expand Up @@ -532,15 +533,16 @@ func Test_getPRHistory(t *testing.T) {
},
ProwConfig: config.ProwConfig{
Plank: config.Plank{
DefaultDecorationConfigs: map[string]*prowapi.DecorationConfig{
"*": {
GCSConfiguration: &prowapi.GCSConfiguration{
Bucket: "gs://kubernetes-jenkins",
PathStrategy: prowapi.PathStrategyLegacy,
DefaultOrg: "kubernetes",
DefaultDecorationConfigs: config.DefaultDecorationMapToSliceTesting(
map[string]*prowapi.DecorationConfig{
"*": {
GCSConfiguration: &prowapi.GCSConfiguration{
Bucket: "gs://kubernetes-jenkins",
PathStrategy: prowapi.PathStrategyLegacy,
DefaultOrg: "kubernetes",
},
},
},
},
}),
},
Deck: config.Deck{
AllKnownStorageBuckets: sets.NewString("kubernetes-jenkins"),
Expand Down
Loading

0 comments on commit 5be9725

Please sign in to comment.