@@ -162,6 +162,62 @@ func FindCircularBuilds(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
162
162
return markers
163
163
}
164
164
165
+ // findPendingTags is the guts behind FindPendingTags .... break out some of the content and reduce some indentation
166
+ func findPendingTags (uncastIstNode graph.Node , g osgraph.Graph , f osgraph.Namer ) []osgraph.Marker {
167
+ markers := []osgraph.Marker {}
168
+ istNode := uncastIstNode .(* imagegraph.ImageStreamTagNode )
169
+ if istNode .Found () {
170
+ return markers
171
+ }
172
+ bcNodes := buildedges .BuildConfigsForTag (g , uncastIstNode )
173
+ for _ , bcNode := range bcNodes {
174
+ latestBuild := buildedges .GetLatestBuild (g , bcNode )
175
+
176
+ // A build config points to the non existent tag but no current build exists.
177
+ if latestBuild == nil {
178
+ markers = append (markers , osgraph.Marker {
179
+ Node : graph .Node (bcNode ),
180
+ RelatedNodes : []graph.Node {uncastIstNode },
181
+
182
+ Severity : osgraph .WarningSeverity ,
183
+ Key : TagNotAvailableWarning ,
184
+ Message : fmt .Sprintf ("%s needs to be imported or created by a build." , f .ResourceName (istNode )),
185
+ Suggestion : osgraph .Suggestion (fmt .Sprintf ("oc start-build %s" , f .ResourceName (bcNode ))),
186
+ })
187
+ continue
188
+ }
189
+
190
+ // A build config points to the non existent tag but something is going on with
191
+ // the latest build.
192
+ // TODO: Handle other build phases.
193
+ switch latestBuild .Build .Status .Phase {
194
+ case buildapi .BuildPhaseCancelled :
195
+ // TODO: Add a warning here.
196
+ case buildapi .BuildPhaseError :
197
+ // TODO: Add a warning here.
198
+ case buildapi .BuildPhaseComplete :
199
+ // We should never hit this. The output of our build is missing but the build is complete.
200
+ // Most probably the user has messed up?
201
+ case buildapi .BuildPhaseFailed :
202
+ // Since the tag hasn't been populated yet, we assume there hasn't been a successful
203
+ // build so far.
204
+ markers = append (markers , osgraph.Marker {
205
+ Node : graph .Node (latestBuild ),
206
+ RelatedNodes : []graph.Node {uncastIstNode , graph .Node (bcNode )},
207
+
208
+ Severity : osgraph .ErrorSeverity ,
209
+ Key : LatestBuildFailedErr ,
210
+ Message : fmt .Sprintf ("%s has failed." , f .ResourceName (latestBuild )),
211
+ Suggestion : osgraph .Suggestion (fmt .Sprintf ("Inspect the build failure with 'oc logs %s'" , f .ResourceName (latestBuild ))),
212
+ })
213
+ default :
214
+ // Do nothing when latest build is new, pending, or running.
215
+ }
216
+
217
+ }
218
+ return markers
219
+ }
220
+
165
221
// FindPendingTags inspects all imageStreamTags that serve as outputs to builds.
166
222
//
167
223
// Precedence of failures:
@@ -171,51 +227,7 @@ func FindPendingTags(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
171
227
markers := []osgraph.Marker {}
172
228
173
229
for _ , uncastIstNode := range g .NodesByKind (imagegraph .ImageStreamTagNodeKind ) {
174
- istNode := uncastIstNode .(* imagegraph.ImageStreamTagNode )
175
- if bcNode := buildedges .BuildConfigForTag (g , uncastIstNode ); bcNode != nil && ! istNode .Found () {
176
- latestBuild := buildedges .GetLatestBuild (g , bcNode )
177
-
178
- // A build config points to the non existent tag but no current build exists.
179
- if latestBuild == nil {
180
- markers = append (markers , osgraph.Marker {
181
- Node : graph .Node (bcNode ),
182
- RelatedNodes : []graph.Node {uncastIstNode },
183
-
184
- Severity : osgraph .WarningSeverity ,
185
- Key : TagNotAvailableWarning ,
186
- Message : fmt .Sprintf ("%s needs to be imported or created by a build." , f .ResourceName (istNode )),
187
- Suggestion : osgraph .Suggestion (fmt .Sprintf ("oc start-build %s" , f .ResourceName (bcNode ))),
188
- })
189
- continue
190
- }
191
-
192
- // A build config points to the non existent tag but something is going on with
193
- // the latest build.
194
- // TODO: Handle other build phases.
195
- switch latestBuild .Build .Status .Phase {
196
- case buildapi .BuildPhaseCancelled :
197
- // TODO: Add a warning here.
198
- case buildapi .BuildPhaseError :
199
- // TODO: Add a warning here.
200
- case buildapi .BuildPhaseComplete :
201
- // We should never hit this. The output of our build is missing but the build is complete.
202
- // Most probably the user has messed up?
203
- case buildapi .BuildPhaseFailed :
204
- // Since the tag hasn't been populated yet, we assume there hasn't been a successful
205
- // build so far.
206
- markers = append (markers , osgraph.Marker {
207
- Node : graph .Node (latestBuild ),
208
- RelatedNodes : []graph.Node {uncastIstNode , graph .Node (bcNode )},
209
-
210
- Severity : osgraph .ErrorSeverity ,
211
- Key : LatestBuildFailedErr ,
212
- Message : fmt .Sprintf ("%s has failed." , f .ResourceName (latestBuild )),
213
- Suggestion : osgraph .Suggestion (fmt .Sprintf ("Inspect the build failure with 'oc logs %s'" , f .ResourceName (latestBuild ))),
214
- })
215
- default :
216
- // Do nothing when latest build is new, pending, or running.
217
- }
218
- }
230
+ markers = append (markers , findPendingTags (uncastIstNode , g , f )... )
219
231
}
220
232
221
233
return markers
0 commit comments