@@ -485,19 +485,30 @@ func processImagesConcurrently(ctx context.Context, images []vpcv1.Image, meta i
485485 isStockImage := strings .HasPrefix (strings .ToLower (* image .Name ), "ibm" )
486486 isRemoteImage := image .Remote != nil
487487
488- if ! isStockImage && ! isRemoteImage {
488+ if ! isStockImage {
489489 crnsForBulkFetch = append (crnsForBulkFetch , * image .CRN )
490+ log .Printf ("[DEBUG] UJJK Image %s (%s) needs tag fetch" , * image .Name , * image .CRN )
491+ } else {
492+ log .Printf ("[DEBUG] UJJK Image %s skipped - stock: %v, remote: %v" , * image .Name , isStockImage , isRemoteImage )
490493 }
491494 }
492495
496+ log .Printf ("[DEBUG] UJJK Total images needing tags: %d" , len (crnsForBulkFetch ))
497+
493498 // Bulk fetch all tags in one API call
494499 var bulkTags map [string ]* schema.Set
495500 if len (crnsForBulkFetch ) > 0 {
496501 var err error
497502 bulkTags , err = flex .GetGlobalTagsUsingCRNBulk (meta , crnsForBulkFetch , "" , isImageAccessTagType )
498503 if err != nil {
499- log .Printf ("[ERROR] Bulk tag fetch failed: %s" , err )
500- bulkTags = make (map [string ]* schema.Set ) // Initialize empty map to avoid nil checks
504+ log .Printf ("[ERROR] UJJK Bulk tag fetch failed: %s" , err )
505+ bulkTags = make (map [string ]* schema.Set )
506+ } else {
507+ log .Printf ("[DEBUG] UJJK Bulk tags fetched successfully. Got tags for %d images" , len (bulkTags ))
508+ // Log what we got
509+ for crn , tags := range bulkTags {
510+ log .Printf ("[DEBUG] UJJK CRN: %s has %d tags" , crn , tags .Len ())
511+ }
501512 }
502513 } else {
503514 bulkTags = make (map [string ]* schema.Set )
@@ -511,15 +522,15 @@ func processImagesConcurrently(ctx context.Context, images []vpcv1.Image, meta i
511522 }
512523
513524 results := make (chan result , len (images ))
514- sem := make (chan struct {}, 10 ) // Limit to 10 concurrent goroutines
525+ sem := make (chan struct {}, 10 )
515526 var wg sync.WaitGroup
516527
517528 for idx , image := range images {
518529 wg .Add (1 )
519530 go func (i int , img vpcv1.Image ) {
520531 defer wg .Done ()
521- sem <- struct {}{} // Acquire
522- defer func () { <- sem }() // Release
532+ sem <- struct {}{}
533+ defer func () { <- sem }()
523534
524535 data , err := processImageWithBulkTags (ctx , img , bulkTags )
525536 results <- result {index : i , data : data , err : err }
@@ -535,7 +546,7 @@ func processImagesConcurrently(ctx context.Context, images []vpcv1.Image, meta i
535546 orderedResults := make ([]map [string ]interface {}, len (images ))
536547 for res := range results {
537548 if res .err != nil {
538- log .Printf ("[WARN] Error processing image at index %d: %s" , res .index , res .err )
549+ log .Printf ("[WARN] UJJK Error processing image at index %d: %s" , res .index , res .err )
539550 continue
540551 }
541552 orderedResults [res .index ] = res .data
@@ -549,6 +560,8 @@ func processImagesConcurrently(ctx context.Context, images []vpcv1.Image, meta i
549560 }
550561 }
551562
563+ log .Printf ("[DEBUG] UJJK Final processed images: %d" , len (imagesInfo ))
564+
552565 return imagesInfo , nil
553566}
554567
@@ -623,13 +636,20 @@ func processImageWithBulkTags(ctx context.Context, image vpcv1.Image, bulkTags m
623636 l ["allowed_use" ] = []map [string ]interface {}{modelMap }
624637 }
625638
626- // Add access tags from bulk fetch (only for non-stock)
639+ // Add access tags from bulk fetch (only for non-stock, non-remote images )
627640 isStockImage := strings .HasPrefix (strings .ToLower (* image .Name ), "ibm" )
641+ isRemoteImage := image .Remote != nil
628642
629643 if ! isStockImage {
630644 if tags , exists := bulkTags [* image .CRN ]; exists {
645+ log .Printf ("[DEBUG] UJJK Setting tags for image %s: %d tags found" , * image .Name , tags .Len ())
631646 l [isImageAccessTags ] = tags
647+ } else {
648+ log .Printf ("[DEBUG] UJJK No tags found for image %s (CRN: %s) in bulkTags map" , * image .Name , * image .CRN )
649+ l [isImageAccessTags ] = flex .NewStringSet (flex .ResourceIBMVPCHash , []string {})
632650 }
651+ } else {
652+ log .Printf ("[DEBUG] UJJK Image %s - stock: %v, remote: %v - not setting tags" , * image .Name , isStockImage , isRemoteImage )
633653 }
634654
635655 return l , nil
0 commit comments