diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8b5d6a43068..bc2bf5d469c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,5 +1,8 @@ trigger: -- azdo-pipelines + branches: + include: + - master + - pipeline-updates resources: - repo: self @@ -18,7 +21,8 @@ variables: #GOPATH: '$(System.DefaultWorkingDirectory)/gopath' # Go workspace path #GOBIN: '$(GOPATH)/bin' # Go binaries path MODULE_PATH: '$(System.DefaultWorkingDirectory)/src/$(Build.Repository.Name)' # Path to the module's code - IMAGE_NAME: 'candidate/k8s/azure-service-operator' + IMAGE_NAME: 'candidate/k8s/azureserviceoperator' + ASO_HELM_CHART_NAME: 'candidate/k8s/asohelmchart' KUBEBUILDER_ASSETS: $(go env GOPATH)/bin # CONTAINER_REGISTRY: - set this value in Azure Devops variables - Name of Release ACR Service Connection # AZURE_SUBSCRIPTION_ID - set this value in Azure Devops variables @@ -91,8 +95,11 @@ steps: export KUBECONFIG=$(kind get kubeconfig-path --name="kind") kubectl cluster-info make install + export TEST_APIM_RG=$(TEST_APIM_RG) + export TEST_APIM_NAME=$(TEST_APIM_NAME) make test-integration-controllers displayName: Run tests on a Kind Cluster + continueOnError: 'false' env: GO111MODULE: on AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID) @@ -131,8 +138,9 @@ steps: - task: AzureCLI@2 displayName: Test - Cleanup Azure Resources + condition: always() inputs: - azureSubscription: 'tpark-jananiv-azureserviceoperators(4ef44fef-c51d-4d7c-a6ff-8635c02848b1)' + azureSubscription: 'ASO Subscription' scriptType: 'bash' scriptLocation: 'inlineScript' inlineScript: 'make test-cleanup-azure-resources' @@ -182,7 +190,7 @@ steps: # Replace image repository in values.yaml to the official image in ACR img="$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION" echo $img - sed -i -e 's@azure-service-operator:latest@azure-service-operator:'${img}'@' charts/azure-service-operator/values.yaml + sed -i -e 's@azure-service-operator:latest@azureserviceoperator:'${img}'@' charts/azure-service-operator/values.yaml # create directory for generated files mkdir charts/azure-service-operator/templates/generated # generate files using kustomize @@ -203,7 +211,7 @@ steps: # update Chart.yaml for Helm Repository helm repo index ./charts # remove directory containing generated manifests for Helm Chart - rm -rf charts/azure-service-operator/templates/generated/ + #rm -rf charts/azure-service-operator/templates/generated/ displayName: Deploy to AKS - Helm generate and package charts # - task: KubernetesManifest@0 @@ -237,6 +245,7 @@ steps: kubectl delete namespace $(OPERATOR_NAMESPACE) imagename="$(PIPELINE_CONTAINER_REGISTRY_NAME)/$(IMAGE_NAME):$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)" echo $imagename + make install helm upgrade --install aso charts/azure-service-operator-0.1.0.tgz \ --set azureSubscriptionID=$(AZURE_SUBSCRIPTION_ID) \ --set azureTenantID=$(AZURE_TENANT_ID) \ @@ -251,6 +260,9 @@ steps: --set namespace=$(OPERATOR_NAMESPACE) kubectl get namespace kubectl get pods -n $(OPERATOR_NAMESPACE) + kubectl describe pods -n $(OPERATOR_NAMESPACE) + kubectl rollout status deployment/azureoperator-controller-manager -n $(OPERATOR_NAMESPACE) --timeout 120s + kubectl logs -n $(OPERATOR_NAMESPACE) deployment/azureoperator-controller-manager -c manager # - task: HelmDeploy@0 # inputs: @@ -284,6 +296,23 @@ steps: tags: | latest $(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION) + + - script: | + export HELM_EXPERIMENTAL_OCI=1 + cd charts/azure-service-operator + versiontag="$(CONTAINER_REGISTRY_NAME)/$(ASO_HELM_CHART_NAME):$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)" + latesttag="$(CONTAINER_REGISTRY_NAME)/$(ASO_HELM_CHART_NAME):latest" + echo $versiontag + echo $latesttag + echo $(AZURE_CLIENT_SECRET)|helm registry login $(CONTAINER_REGISTRY_NAME) --username $(AZURE_CLIENT_ID) --password-stdin + helm chart save . $versiontag + helm chart save . $latesttag + helm chart push $versiontag + helm chart push $latesttag + continueOnError: 'true' + displayName: Push Helm chart to MCR repo + workingDirectory: '$(System.DefaultWorkingDirectory)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - script: | echo "updating kustomize image patch file for manager resource" diff --git a/charts/azure-service-operator-0.1.0.tgz b/charts/azure-service-operator-0.1.0.tgz index a054aac8e41..1d4cf361965 100644 Binary files a/charts/azure-service-operator-0.1.0.tgz and b/charts/azure-service-operator-0.1.0.tgz differ diff --git a/charts/index.yaml b/charts/index.yaml index e7a7bfe917c..acd592bfa5f 100644 --- a/charts/index.yaml +++ b/charts/index.yaml @@ -3,14 +3,14 @@ entries: azure-service-operator: - apiVersion: v2 appVersion: 0.1.0 - created: "2020-04-23T11:50:42.794582-07:00" + created: "2020-05-18T22:30:28.349199-06:00" dependencies: - condition: azureUseMI name: aad-pod-identity repository: https://raw.githubusercontent.com/Azure/aad-pod-identity/master/charts version: 1.5.5 description: Deploy components and dependencies of azure-service-operator - digest: 6aaf972ecdc1aad3c0e9b4c414d8b39cc33c40f17ef8b8985b3c8acfac80bc72 + digest: e5aaaa1c15802982f7a943e737b2ae39a2404d395fec299376fb19e15fc9e6f2 home: https://github.com/Azure/azure-service-operator name: azure-service-operator sources: @@ -18,4 +18,4 @@ entries: urls: - azure-service-operator-0.1.0.tgz version: 0.1.0 -generated: "2020-04-23T11:50:42.791883-07:00" +generated: "2020-05-18T22:30:28.343398-06:00" diff --git a/controllers/apimgmt_controller_test.go b/controllers/apimgmt_controller_test.go index 21d9410b2f6..af1e3c8be7b 100644 --- a/controllers/apimgmt_controller_test.go +++ b/controllers/apimgmt_controller_test.go @@ -7,6 +7,7 @@ package controllers import ( "context" + "os" "testing" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" @@ -22,6 +23,18 @@ func TestAPIMgmtController(t *testing.T) { // rgName := tc.resourceGroupName rgLocation := "southcentralus" apiMgmtName := "t-apimgmt-test" + helpers.RandomString(10) + rgName := "AzureOperatorsTest" + apimServiceName := "AzureOperatorsTestAPIM" + + // Read the pre-created APIM service name and RG name from Environment variable if it exists + rgFromEnv := os.Getenv("TEST_APIM_RG") + if len(rgFromEnv) != 0 { + rgName = rgFromEnv + } + nameFromEnv := os.Getenv("TEST_APIM_NAME") + if len(nameFromEnv) != 0 { + apimServiceName = nameFromEnv + } // Create an instance of Azure APIMgmnt apiMgmtInstance := &azurev1alpha1.APIMgmtAPI{ @@ -31,8 +44,8 @@ func TestAPIMgmtController(t *testing.T) { }, Spec: azurev1alpha1.APIMgmtSpec{ Location: rgLocation, - ResourceGroup: "AzureOperatorsTest", - APIService: "AzureOperatorsTestAPIM", + ResourceGroup: rgName, + APIService: apimServiceName, APIId: "apiId0", Properties: azurev1alpha1.APIProperties{ IsCurrent: true, diff --git a/pkg/resourcemanager/vnet/reconcile.go b/pkg/resourcemanager/vnet/reconcile.go index d1d9c3bd255..3df128fe98d 100644 --- a/pkg/resourcemanager/vnet/reconcile.go +++ b/pkg/resourcemanager/vnet/reconcile.go @@ -9,6 +9,7 @@ import ( "net/http" "strings" + "github.com/Azure/azure-sdk-for-go/profiles/latest/network/mgmt/network" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/helpers" @@ -35,13 +36,15 @@ func (g *AzureVNetManager) Ensure(ctx context.Context, obj runtime.Object, opts // consider the reconcilliation successful vNet, err := g.GetVNet(ctx, resourceGroup, resourceName) if err == nil { - // succeeded! end reconcilliation successfully - instance.Status.Provisioning = false - instance.Status.Provisioned = true - instance.Status.FailedProvisioning = false - instance.Status.Message = resourcemanager.SuccessMsg - instance.Status.ResourceId = *vNet.ID - return true, nil + if vNet.ProvisioningState == network.Succeeded { + // succeeded! end reconcilliation successfully + instance.Status.Provisioning = false + instance.Status.Provisioned = true + instance.Status.FailedProvisioning = false + instance.Status.Message = resourcemanager.SuccessMsg + instance.Status.ResourceId = *vNet.ID + return true, nil + } } instance.Status.Provisioning = true