@@ -218,7 +218,7 @@ func (p *DefaultProvider) get(ctx context.Context, nodeClass NodeClass, name ec2
218218
219219func (p * DefaultProvider ) cacheKey (nodeClass NodeClass ) string {
220220 // Compute fully initialized instance types hash key
221- subnetZonesHash , _ := hashstructure . Hash (nodeClass .ZoneInfo (), hashstructure . FormatV2 , & hashstructure. HashOptions { SlicesAsSets : true } )
221+ subnetZonesHash := hashZoneInfo (nodeClass .ZoneInfo ())
222222 // Compute hash key against node class AMIs (used to force cache rebuild when AMIs change)
223223 amiHash , _ := hashstructure .Hash (nodeClass .AMIs (), hashstructure .FormatV2 , & hashstructure.HashOptions {SlicesAsSets : true })
224224 return fmt .Sprintf ("%016x-%016x-%s" ,
@@ -361,3 +361,13 @@ func discoveredCapacityCacheKey(instanceType string, nodeClass NodeClass) string
361361 amiHash , _ := hashstructure .Hash (nodeClass .AMIs (), hashstructure .FormatV2 , & hashstructure.HashOptions {SlicesAsSets : true })
362362 return fmt .Sprintf ("%s-%016x" , instanceType , amiHash )
363363}
364+
365+ // hashZoneInfo hashes each ZoneInfo element individually and collects the hashes
366+ // into a set, avoiding the hashstructure SlicesAsSets bug from https://github.com/mitchellh/hashstructure/issues/36
367+ func hashZoneInfo (zoneInfo []v1.ZoneInfo ) uint64 {
368+ zoneInfoHashes := sets .New [uint64 ]()
369+ for i := range zoneInfo {
370+ zoneInfoHashes .Insert (lo .Must (hashstructure .Hash (zoneInfo [i ], hashstructure .FormatV2 , nil )))
371+ }
372+ return lo .Must (hashstructure .Hash (zoneInfoHashes , hashstructure .FormatV2 , nil ))
373+ }
0 commit comments