Azure / draft-classic

A tool for developers to create cloud-native applications on Kubernetes.
https://draft.sh
MIT License
3.93k stars 397 forks source link

Using Draft ACR build feature fails - Invalid input: autorest/validation: validation failed: ... value length must be greater than or equal to 5 #712

Closed rhollins closed 6 years ago

rhollins commented 6 years ago

Hi,

I can use draft up with container-builder = "docker" the image is being succesfully built locally and then pushed to ACR repository however when I change it to container-builder = "acrbuild" I get error:

2018/04/28 18:47:20 error while building: Could not retrieve acr build's upload URL: containerregistry.RegistriesClient#GetBuildSourceUploadURL: Invalid input: autorest/validation: validation failed: parameter=registryName constraint=MinLength value="dev" details: value length must be greater than or equal to 5

Draft version: v0.14.1

draft.toml content:

[environments]
  [environments.development]
    name = "gs-spring-boot-docker"
    registry = "acr_name.azurecr.io"
    container-builder = "acrbuild"
    namespace = "default"
    wait = true
    watch = false
    watch-delay = 2
    auto-connect = false
    dockerfile = ""
    chart = ""
    resource-group-name = "resourceGroupName"

...\gs-spring-boot-docker\charts\java\values.yaml file contains valid registry name and repository

I was following instruction on these might have missed something: https://docs.microsoft.com/en-us/azure/aks/kubernetes-draft https://github.com/Azure/draft/blob/master/docs/reference/dep-006.md

squillace commented 6 years ago

the error indicates that you provided parameter=registryName constraint=MinLength value="dev", was dev the registry name? The first question is whether the registry name is greater than five chars. :-) I'm sure it was, but I have to ask.

rhollins commented 6 years ago

Yes the registry name has more than 7 characters, I tried to find all places there this registry name is provided:

C:\Users\user.name.draft\config.toml I have:

container-builder = "docker"
registry = "myregistryname.azurecr.io"

Then in project the draft.toml file:

[environments]
  [environments.development]
    name = "gs-spring-boot-docker"
    registry = "myrgistryname.azurecr.io"
    container-builder = "acrbuild"
    namespace = "default"
    wait = true
    watch = false
    watch-delay = 2
    auto-connect = false
    dockerfile = ""
    chart = ""
    resource-group-name = "resourcegroupname"

Is there any other place where this "dev" string may come from ?

bacongobbler commented 6 years ago

The only places the dev string would come from is draft config list and draft.toml. registryName would come from the registry field. I'm flying all day today and tomorrow but I can test this again on Wednesday.

bacongobbler commented 6 years ago

I was unable to reproduce this with the following configuration:

><> draft config list
KEY                     VALUE
registry                kubeconeu2018.azurecr.io
resource-group-name     kubeconeu2018
container-builder       acrbuild

After those are set I'm ready to use ACR Build with any app via draft create && draft up. Were you able to figure out the issue on your end?

rhollins commented 6 years ago

Unfortunately still wasn't able to get around this issue, when I run it manually az acr build --registry acrdevname --image gs-spring-boot-docker:1.1.3 --context . it is fine however when running through draft I get the same error every time. I also installed latest azure cli 2.0.31.

Still have no idea from where draft is taking this "dev" string.

draft.toml

[environments]
  [environments.development]
    name = "gs-spring-boot-docker"
    registry = "acrdevname.azurecr.io"
    container-builder = "acrbuild"
    set = ["image.repository=acrdevname.azurecr.io/gs-spring-boot-docker"]
    namespace = "development"
    wait = true
    watch = false
    watch-delay = 2
    auto-connect = false
    dockerfile = ""
    chart = "gs-spring-boot-docker"
    resource-group-name = "resourceGroupName-rg"

config.toml

container-builder = "acrbuild"
registry = "acrdevname.azurecr.io"
resource-group-name = "resourceGroupName-rg"

Error:

2018/05/03 11:30:15 error while building: Could not retrieve acr build's upload URL: containerregistry.RegistriesClient#GetBuildSourceUploadURL: Invalid input: autorest/validation: validation failed: parameter=registryName constraint=MinLength value="dev" details: value length must be greater than or equal to 5

birdayz commented 6 years ago

I think i found the issue and filed #718. The function getRegistryName should remove a substring with .azurecr.io, but its current implementation does something slightly different, leading to strange behaviors.