Skip to content

Commit

Permalink
couple of bug fixes for controller. (istio#338)
Browse files Browse the repository at this point in the history
* batch of bug fixes for controller.

* update resources gvk list.
  • Loading branch information
Morven Cao authored and istio-testing committed Oct 9, 2019
1 parent fa5ddb7 commit 1f83240
Show file tree
Hide file tree
Showing 9 changed files with 365 additions and 300 deletions.
369 changes: 194 additions & 175 deletions pkg/apis/istio/v1alpha2/istiocontrolplane_types.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pkg/apis/istio/v1alpha2/istiocontrolplane_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ message IstioControlPlane {
IstioControlPlaneSpec spec = 3;
// Status reports the status of the Istio control plane.
InstallStatus status = 4;
string kind = 5;
string apiVersion = 6;
}

// IstioControlPlaneSpec defines the desired state of IstioControlPlane.
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/istio/v1alpha2/v1alpha2.pb.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pkg/controller/istiocontrolplane/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ func (i *IstioRenderingInput) GetChartPath() string {
}

func (i *IstioRenderingInput) GetInputConfig() interface{} {
// Not used in this renderer,
return nil
return i.instance
}

func (i *IstioRenderingInput) GetTargetNamespace() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ func (r *ReconcileIstioControlPlane) Reconcile(request reconcile.Request) (recon
finalizers = append(finalizers, finalizer)
instance.SetFinalizers(finalizers)
err = r.client.Update(context.TODO(), instance)
return reconcile.Result{}, err
if err != nil {
log.Errorf("Failed to update IstioControlPlane with finalizer, %v", err)
return reconcile.Result{}, err
}
}

log.Info("Updating IstioControlPlane")
Expand Down
27 changes: 19 additions & 8 deletions pkg/controller/istiocontrolplane/pruningdetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
{Group: "apps", Version: "v1beta1", Kind: "Deployment"},
{Group: "apps", Version: "v1beta1", Kind: "StatefulSet"},
{Group: "apps", Version: "v1", Kind: "Deployment"},
{Group: "apps", Version: "v1", Kind: "DaemonSet"},
{Group: "batch", Version: "v1", Kind: "Job"},
{Group: "extensions", Version: "v1beta1", Kind: "DaemonSet"},
{Group: "extensions", Version: "v1beta1", Kind: "Deployment"},
Expand All @@ -62,29 +63,39 @@ var (
{Group: "rbac.authorization.k8s.io", Version: "v1beta1", Kind: "Role"},
{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "Role"},
{Group: "authentication.istio.io", Version: "v1alpha1", Kind: "Policy"},
{Group: "certmanager.k8s.io", Version: "v1alpha1", Kind: "Certificate"},
{Group: "certmanager.k8s.io", Version: "v1alpha1", Kind: "Challenge"},
{Group: "certmanager.k8s.io", Version: "v1alpha1", Kind: "Issuer"},
{Group: "certmanager.k8s.io", Version: "v1alpha1", Kind: "Order"},
{Group: "certmanager.k8s.io", Version: "v1beta1", Kind: "Certificate"},
{Group: "certmanager.k8s.io", Version: "v1beta1", Kind: "Challenge"},
{Group: "certmanager.k8s.io", Version: "v1beta1", Kind: "Issuer"},
{Group: "certmanager.k8s.io", Version: "v1beta1", Kind: "Order"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "adapter"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "attributemanifest"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "handler"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "kubernetes"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "logentry"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "metric"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "instance"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "HTTPAPISpec"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "HTTPAPISpecBinding"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "QuotaSpec"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "QuotaSpecBinding"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "rule"},
{Group: "config.istio.io", Version: "v1alpha2", Kind: "template"},
{Group: "networking.istio.io", Version: "v1alpha3", Kind: "DestinationRule"},
{Group: "networking.istio.io", Version: "v1alpha3", Kind: "EnvoyFilter"},
{Group: "networking.istio.io", Version: "v1alpha3", Kind: "Gateway"},
{Group: "networking.istio.io", Version: "v1alpha3", Kind: "ServiceEntry"},
{Group: "networking.istio.io", Version: "v1alpha3", Kind: "Sidecar"},
{Group: "networking.istio.io", Version: "v1alpha3", Kind: "VirtualService"},
{Group: "rbac.istio.io", Version: "v1alpha1", Kind: "AuthorizationPolicy"},
{Group: "rbac.istio.io", Version: "v1alpha1", Kind: "ClusterRbacConfig"},
{Group: "rbac.istio.io", Version: "v1alpha1", Kind: "RbacConfig"},
{Group: "rbac.istio.io", Version: "v1alpha1", Kind: "ServiceRole"},
{Group: "rbac.istio.io", Version: "v1alpha1", Kind: "ServiceRoleBinding"},
{Group: "security.istio.io", Version: "v1beta1", Kind: "AuthorizationPolicy"},
}

// ordered by which types should be deleted, first to last
nonNamespacedResources = []schema.GroupVersionKind{
{Group: "admissionregistration.k8s.io", Version: "v1beta1", Kind: "MutatingWebhookConfiguration"},
{Group: "admissionregistration.k8s.io", Version: "v1beta1", Kind: "ValidatingWebhookConfiguration"},
{Group: "certmanager.k8s.io", Version: "v1alpha1", Kind: "ClusterIssuer"},
{Group: "certmanager.k8s.io", Version: "v1beta1", Kind: "ClusterIssuer"},
{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRole"},
{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRoleBinding"},
{Group: "authentication.istio.io", Version: "v1alpha1", Kind: "MeshPolicy"},
Expand Down
5 changes: 4 additions & 1 deletion pkg/helmreconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (h *HelmReconciler) Reconcile() error {
// where a child must wait for the parent to complete before starting.
func (h *HelmReconciler) processRecursive(manifests ChartManifestsMap) *v1alpha2.InstallStatus {
deps, dch := h.customizer.Input().GetProcessingOrder(manifests)
out := &v1alpha2.InstallStatus{}
out := &v1alpha2.InstallStatus{Status: make(map[string]*v1alpha2.InstallStatus_VersionStatus)}

var wg sync.WaitGroup
for c, m := range manifests {
Expand All @@ -132,6 +132,9 @@ func (h *HelmReconciler) processRecursive(manifests ChartManifestsMap) *v1alpha2
log.Infof("Dependency for %s has completed, proceeding.", c)
}

if _, ok := out.Status[c]; !ok {
out.Status[c] = &v1alpha2.InstallStatus_VersionStatus{}
}
out.Status[c].Status = v1alpha2.InstallStatus_NONE
if len(m) != 0 {
out.Status[c].Status = v1alpha2.InstallStatus_HEALTHY
Expand Down
10 changes: 6 additions & 4 deletions pkg/helmreconciler/rendering.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ import (
)

func (h *HelmReconciler) renderCharts(in RenderingInput) (ChartManifestsMap, error) {
icp, ok := in.GetInputConfig().(*v1alpha2.IstioControlPlaneSpec)
icp, ok := in.GetInputConfig().(*v1alpha2.IstioControlPlane)
if !ok {
return nil, fmt.Errorf("unexpected type %T in renderCharts", in.GetInputConfig())
}
if err := validate.CheckIstioControlPlaneSpec(icp, false); err != nil {

icpSpec := icp.GetSpec()
if err := validate.CheckIstioControlPlaneSpec(icpSpec, false); err != nil {
return nil, err
}

mergedICPS, err := mergeICPSWithProfile(icp)
mergedICPS, err := mergeICPSWithProfile(icpSpec)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -209,7 +211,7 @@ func (h *HelmReconciler) ProcessObject(obj *unstructured.Unstructured) error {

receiver := &unstructured.Unstructured{}
receiver.SetGroupVersionKind(mutatedObj.GetObjectKind().GroupVersionKind())
objectKey, _ := client.ObjectKeyFromObject(receiver)
objectKey, _ := client.ObjectKeyFromObject(mutatedObj)

var patch Patch

Expand Down
232 changes: 123 additions & 109 deletions python/istio_api/pkg/apis/istio/v1alpha2/istiocontrolplane_types_pb2.py

Large diffs are not rendered by default.

0 comments on commit 1f83240

Please sign in to comment.