Azure-sdk-for-go: Probable Bug in the Redis SDK

Created on 25 Oct 2016  路  8Comments  路  Source: Azure/azure-sdk-for-go

Some context: I'm trying to implement Redis support within Terraform. I've been able to work back from the ARM templates to get Basic/Standard working _relatively_ smoothly - but I've encountered issues trying to support the Premium tier.

Within the Redis SDK - the field shardCount is defined as being an int32:

type ReadableProperties struct {
    RedisVersion       *string             `json:"redisVersion,omitempty"`
    Sku                *Sku                `json:"sku,omitempty"`
    RedisConfiguration *map[string]*string `json:"redisConfiguration,omitempty"`
    EnableNonSslPort   *bool               `json:"enableNonSslPort,omitempty"`
    TenantSettings     *map[string]*string `json:"tenantSettings,omitempty"`
    ShardCount         *int32              `json:"shardCount,omitempty"`
    SubnetID           *string             `json:"subnetId,omitempty"`
    StaticIP           *string             `json:"staticIP,omitempty"`
    ProvisioningState  *string             `json:"provisioningState,omitempty"`
    HostName           *string             `json:"hostName,omitempty"`
    Port               *int32              `json:"port,omitempty"`
    SslPort            *int32              `json:"sslPort,omitempty"`
}

However it's actually being returned by the API as a string - as shown below: (I've altered a few variables changes for obvious reasons)

{
    "id": "/subscriptions/XXXXXXXXXXXXXX/resourceGroups/tharvey-redevprem/providers/Microsoft.Cache/Redis/tom-wip-prem",
    "location": "West US",
    "name": "tom-wip-prem",
    "type": "Microsoft.Cache/Redis",
    "tags": {},
    "properties": {
        "provisioningState": "Creating",
        "redisVersion": "3.0",
        "sku": {
            "name": "Premium",
            "family": "P",
            "capacity": 1
        },
        "enableNonSslPort": true,
        "redisConfiguration": {
            "maxclients": "7500",
            "maxmemory-reserved": "200",
            "maxmemory-delta": "200"
        },
        "accessKeys": {
            "primaryKey": "XXXXXXXXXXXXXXXXXXXXX",
            "secondaryKey": "XXXXXXXXXXXXXXXXXXXXX"
        },
        "hostName": "tom-wip-prem.redis.cache.windows.net",
        "port": 6379,
        "sslPort": 6380,
        "shardCount": "1"
    }
}

This leads to the following exception when deserialising:

* azurerm_redis.test: redis.Client#CreateOrUpdate: Failure responding to request: StatusCode=201 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal string into Go value of type int32' JSON = '{"id":"/subscriptions/XXXXXXXXXXXXXXXXXXXXX/resourceGroups/tharvey-redevprem/providers/Microsoft.Cache/Redis/tom-wip-prem","location":"West US","name":"tom-wip-prem","type":"Microsoft.Cache/Redis","tags":{},"properties":{"provisioningState":"Creating","redisVersion":"3.0","sku":{"name":"Premium","family":"P","capacity":1},"enableNonSslPort":true,"redisConfiguration":{"maxclients":"7500","maxmemory-reserved":"200","maxmemory-delta":"200"},"accessKeys":{"primaryKey":"XXXXXXXXXXXXXXXXXXXXX","secondaryKey":"XXXXXXXXXXXXXXXXXXXXX"},"hostName":"tom-wip-prem.redis.cache.windows.net","port":6379,"sslPort":6380,"shardCount":"1"}}'

I'm assuming that one of the following needs to happen:

  • Update the Swagger & re-generate the SDK
  • Start returning Integer's from the API

Unfortunately there's no documentation available for the Redis SDK (which is already an issue being tracked in #283) - but this means that I've no idea what the intended behaviour is.. is it possible to guide me here?

Thanks!

bug

Most helpful comment

@marstr @tombuildsstuff Yes, it got fixed (server side fix).

All 8 comments

Another option is to extend the struct tag to tell Go that it will be a string-wrapped integer. Like so: http://stackoverflow.com/a/21152548/472873 But that would need to be communicated through Swagger...

This is actually a bug server-side - Azure _is_ intended to return an int, but it currently returns a numeric string.

@TimLovellSmith - Can you provide an ETA for this fix? Looks like it should be an easy fix on the service side.

@amarzavery Indeed. We'll roll it out in next week or two - PM me if you have any more specific need around ETA.
// @tombuildsstuff

@timlovellsmith @amarzavery

Great thanks. Any idea if that'll be an in place fix - or a new version?

@TimLovellSmith, @tombuildsstuff

Reading through this thread, it seems as though this has been resolved. Is that true?

@marstr @tombuildsstuff Yes, it got fixed (server side fix).

Thanks for the timely response. I'll close this issue.

Was this page helpful?
0 / 5 - 0 ratings