Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes operator pod restart on changing addon params #779

Merged
merged 3 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ export GO111MODULE=on
$(BIN):
@mkdir -p $@
$(BIN)/%: | $(BIN) ; $(info $(M) building $(PACKAGE)…)
$Q tmp=$$(mktemp -d); \
env GO111MODULE=off GOPATH=$$tmp GOBIN=$(BIN) $(GO) get $(PACKAGE) \
$Q tmp=$$(mktemp -d); cd $$tmp; \
env GO111MODULE=on GOPATH=$$tmp GOBIN=$(BIN) $(GO) get $(PACKAGE) \
|| ret=$$?; \
rm -rf $$tmp ; exit $$ret
env GO111MODULE=on GOPATH=$$tmp GOBIN=$(BIN) $(GO) clean -modcache \
|| ret=$$?; \
cd - ; \
rm -rf $$tmp ; exit $$ret

KO = $(or ${KO_BIN},${KO_BIN},$(BIN)/ko)

Expand All @@ -35,7 +38,9 @@ TRIGGERS ?= latest
DASHBOARD ?= latest
RESULTS ?= latest

$(BIN)/ko: PACKAGE=github.com/google/ko/cmd/ko
# TODO: after updating go version to 1.17 uncommnent the line below to install latest version of ko
# $(BIN)/ko: PACKAGE=github.com/google/ko
$(BIN)/ko: PACKAGE=github.com/google/[email protected]

KUSTOMIZE = $(or ${KUSTOMIZE_BIN},${KUSTOMIZE_BIN},$(BIN)/kustomize)
$(BIN)/kustomize: | $(BIN) ; $(info $(M) getting kustomize)
Expand Down
24 changes: 14 additions & 10 deletions pkg/reconciler/openshift/tektonaddon/tektonaddon.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,18 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ta *v1alpha1.TektonAddon
ta.Status.MarkInstallerSetNotReady(msg)
return r.ensureClusterTasks(ctx, ta)
}

if err := r.checkComponentStatus(ctx, clusterTaskLabelSelector); err != nil {
ta.Status.MarkInstallerSetNotReady(err.Error())
return nil
}
} else {
// if disabled then delete the installer Set if exist
if err := r.deleteInstallerSet(ctx, clusterTaskLabelSelector); err != nil {
return err
}
}

if err := r.checkComponentStatus(ctx, clusterTaskLabelSelector); err != nil {
ta.Status.MarkInstallerSetNotReady(err.Error())
return nil
}

// If clusterTasks are enabled then create an InstallerSet
// with the versioned clustertask manifest
versionedClusterTaskLS := metav1.LabelSelector{
Expand Down Expand Up @@ -282,18 +282,18 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ta *v1alpha1.TektonAddon
ta.Status.MarkInstallerSetNotReady(msg)
return r.ensurePipelineTemplates(ctx, ta)
}

if err := r.checkComponentStatus(ctx, pipelineTemplateLSLabelSelector); err != nil {
ta.Status.MarkInstallerSetNotReady(err.Error())
return nil
}
} else {
// if disabled then delete the installer Set if exist
if err := r.deleteInstallerSet(ctx, pipelineTemplateLSLabelSelector); err != nil {
return err
}
}

if err := r.checkComponentStatus(ctx, pipelineTemplateLSLabelSelector); err != nil {
ta.Status.MarkInstallerSetNotReady(err.Error())
return nil
}

// Ensure Triggers resources
triggerResourceLS := metav1.LabelSelector{
MatchLabels: map[string]string{
Expand Down Expand Up @@ -353,6 +353,10 @@ func (r *Reconciler) checkComponentStatus(ctx context.Context, labelSelector str
return err
}

if len(installerSets.Items) == 0 {
return fmt.Errorf("failed to find installerSet using label : %s", labelSelector)
}

ready := installerSets.Items[0].Status.GetCondition(apis.ConditionReady)
if ready == nil || ready.Status == corev1.ConditionUnknown {
return fmt.Errorf("InstallerSet %s: waiting for installation", installerSets.Items[0].Name)
Expand Down