@@ -67,14 +67,15 @@ func (h *Handler) SpecValidation(cfg *v1.Config) error {
67
67
// second boolean: does the config change require a samples upsert; for example, simply adding
68
68
// to a skip list does not require a samples upsert
69
69
// third boolean: even if an upsert is not needed, update the config instance to clear out image import errors
70
- func (h * Handler ) VariableConfigChanged (cfg * v1.Config ) (bool , bool , bool ) {
70
+ // map: imagestreams that were unskipped (imagestream updates can be expensive, so an optimizatino)
71
+ func (h * Handler ) VariableConfigChanged (cfg * v1.Config ) (bool , bool , bool , map [string ]bool ) {
72
+ unskippedStreams := map [string ]bool {}
71
73
if cfg .Spec .SamplesRegistry != cfg .Status .SamplesRegistry {
72
74
logrus .Printf ("SamplesRegistry changed from %s to %s" , cfg .Status .SamplesRegistry , cfg .Spec .SamplesRegistry )
73
- return true , true , false
75
+ return true , true , false , unskippedStreams
74
76
}
75
77
76
78
logrus .Debugf ("cfg skipped streams %#v" , cfg .Spec .SkippedImagestreams )
77
- unskippedStreams := map [string ]bool {}
78
79
streamsThatWereSkipped := map [string ]bool {}
79
80
for _ , stream := range cfg .Status .SkippedImagestreams {
80
81
streamsThatWereSkipped [stream ] = true
@@ -88,12 +89,12 @@ func (h *Handler) VariableConfigChanged(cfg *v1.Config) (bool, bool, bool) {
88
89
logrus .Printf ("SkippedImagestreams changed in size from %#v to %#v" , cfg .Status .SkippedImagestreams , cfg .Spec .SkippedImagestreams )
89
90
if len (cfg .Spec .SkippedImagestreams ) < len (cfg .Status .SkippedImagestreams ) {
90
91
// skip list reduced, meaning we need to upsert some samples we were ignoring
91
- return true , true , false
92
+ return true , true , false , unskippedStreams
92
93
}
93
94
// even if the skipped list has been increased, if a stream we were skipping
94
95
// has been removed, we need to upsert; assumes buildSkipFilters called beforehand
95
96
if len (unskippedStreams ) > 0 {
96
- return true , true , true
97
+ return true , true , true , unskippedStreams
97
98
}
98
99
99
100
// otherwise, we've only added to the skip list, so don't upsert,but also see if we
@@ -110,7 +111,7 @@ func (h *Handler) VariableConfigChanged(cfg *v1.Config) (bool, bool, bool) {
110
111
// we do not break here cause we want to clear out all possible streams
111
112
}
112
113
}
113
- return true , false , clearImageImportErrors
114
+ return true , false , clearImageImportErrors , unskippedStreams
114
115
}
115
116
116
117
clearImageImportErrors := false
@@ -129,33 +130,33 @@ func (h *Handler) VariableConfigChanged(cfg *v1.Config) (bool, bool, bool) {
129
130
}
130
131
}
131
132
if changeInContent {
132
- return changeInContent , changeInContent , clearImageImportErrors
133
+ return changeInContent , changeInContent , clearImageImportErrors , unskippedStreams
133
134
}
134
135
135
136
if len (cfg .Spec .SkippedTemplates ) != len (cfg .Status .SkippedTemplates ) {
136
137
logrus .Printf ("SkippedTemplates changed from %#v to %#v" , cfg .Status .SkippedTemplates , cfg .Spec .SkippedTemplates )
137
138
if len (cfg .Spec .SkippedTemplates ) < len (cfg .Status .SkippedTemplates ) {
138
- return true , true , false
139
+ return true , true , false , unskippedStreams
139
140
}
140
141
for _ , tpl := range cfg .Status .SkippedTemplates {
141
142
// even if the skipped list has been increased, if a tpl we were skipping
142
143
// has been removed, we need to upsert; assumes buildSkipFilters called beforehand
143
144
if _ , ok := h .skippedTemplates [tpl ]; ! ok {
144
- return true , true , false
145
+ return true , true , false , unskippedStreams
145
146
}
146
147
}
147
- return true , false , false
148
+ return true , false , false , unskippedStreams
148
149
}
149
150
150
151
for _ , skip := range cfg .Status .SkippedTemplates {
151
152
if _ , ok := h .skippedTemplates [skip ]; ! ok {
152
153
logrus .Printf ("SkippedTemplates changed in content ... minimally %s has been removed" , skip )
153
- return true , true , false
154
+ return true , true , false , unskippedStreams
154
155
}
155
156
}
156
157
157
158
logrus .Debugf ("Incoming Config unchanged from last processed version" )
158
- return false , false , false
159
+ return false , false , false , unskippedStreams
159
160
}
160
161
161
162
func (h * Handler ) buildSkipFilters (opcfg * v1.Config ) {
0 commit comments