Merge pull request #281 from fluxcd/meta-reconciler-improv
This commit is contained in:
5
.github/workflows/e2e.yaml
vendored
5
.github/workflows/e2e.yaml
vendored
@@ -63,7 +63,7 @@ jobs:
|
|||||||
--health-check="Deployment/frontend.dev" \
|
--health-check="Deployment/frontend.dev" \
|
||||||
--health-check="Deployment/backend.dev" \
|
--health-check="Deployment/backend.dev" \
|
||||||
--health-check-timeout=3m
|
--health-check-timeout=3m
|
||||||
- name: gotk sync kustomization --with-source
|
- name: gotk reconcile kustomization --with-source
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk reconcile kustomization podinfo --with-source
|
./bin/gotk reconcile kustomization podinfo --with-source
|
||||||
- name: gotk get kustomizations
|
- name: gotk get kustomizations
|
||||||
@@ -99,6 +99,9 @@ jobs:
|
|||||||
--target-namespace=default \
|
--target-namespace=default \
|
||||||
--source=GitRepository/podinfo \
|
--source=GitRepository/podinfo \
|
||||||
--chart=./charts/podinfo
|
--chart=./charts/podinfo
|
||||||
|
- name: gotk reconcile helmrelease --with-source
|
||||||
|
run: |
|
||||||
|
./bin/gotk reconcile helmrelease podinfo-git --with-source
|
||||||
- name: gotk get helmreleases
|
- name: gotk get helmreleases
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk get helmreleases
|
./bin/gotk get helmreleases
|
||||||
|
|||||||
@@ -275,13 +275,37 @@ func isHelmChartReady(ctx context.Context, kubeClient client.Client, name, names
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, condition := range helmChart.Status.Conditions {
|
if c := meta.GetCondition(helmChart.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status == corev1.ConditionTrue {
|
case corev1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
} else if condition.Status == corev1.ConditionFalse {
|
case corev1.ConditionFalse:
|
||||||
return false, fmt.Errorf(condition.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isHelmReleaseReady(ctx context.Context, kubeClient client.Client, name, namespace string) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
var helmRelease helmv2.HelmRelease
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if c := meta.GetCondition(helmRelease.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
|
switch c.Status {
|
||||||
|
case corev1.ConditionTrue:
|
||||||
|
return true, nil
|
||||||
|
case corev1.ConditionFalse:
|
||||||
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
@@ -306,13 +306,12 @@ func isKustomizationReady(ctx context.Context, kubeClient client.Client, name, n
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, condition := range kustomization.Status.Conditions {
|
if c := meta.GetCondition(kustomization.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status == corev1.ConditionTrue {
|
case corev1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
} else if condition.Status == corev1.ConditionFalse {
|
case corev1.ConditionFalse:
|
||||||
return false, fmt.Errorf(condition.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
@@ -373,13 +373,12 @@ func isGitRepositoryReady(ctx context.Context, kubeClient client.Client, name, n
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, condition := range gitRepository.Status.Conditions {
|
if c := meta.GetCondition(gitRepository.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status == corev1.ConditionTrue {
|
case corev1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
} else if condition.Status == corev1.ConditionFalse {
|
case corev1.ConditionFalse:
|
||||||
return false, fmt.Errorf(condition.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
@@ -68,20 +68,17 @@ func getHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
isInitialized := false
|
isInitialized := false
|
||||||
for _, condition := range helmRelease.Status.Conditions {
|
if c := meta.GetCondition(helmRelease.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status != corev1.ConditionFalse {
|
case corev1.ConditionTrue:
|
||||||
if helmRelease.Status.LastAppliedRevision != "" {
|
logger.Successf("%s last applied revision %s", helmRelease.GetName(), helmRelease.Status.LastAppliedRevision)
|
||||||
logger.Successf("%s last applied revision %s", helmRelease.GetName(), helmRelease.Status.LastAppliedRevision)
|
case corev1.ConditionUnknown:
|
||||||
} else {
|
logger.Successf("%s reconciling", helmRelease.GetName())
|
||||||
logger.Successf("%s reconciling", helmRelease.GetName())
|
default:
|
||||||
}
|
logger.Failuref("%s %s", helmRelease.GetName(), c.Message)
|
||||||
} else {
|
|
||||||
logger.Failuref("%s %s", helmRelease.GetName(), condition.Message)
|
|
||||||
}
|
|
||||||
isInitialized = true
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
isInitialized = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if !isInitialized {
|
if !isInitialized {
|
||||||
logger.Failuref("%s is not ready", helmRelease.GetName())
|
logger.Failuref("%s is not ready", helmRelease.GetName())
|
||||||
|
|||||||
@@ -67,20 +67,17 @@ func getKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
isInitialized := false
|
isInitialized := false
|
||||||
for _, condition := range kustomization.Status.Conditions {
|
if c := meta.GetCondition(kustomization.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status != corev1.ConditionFalse {
|
case corev1.ConditionTrue:
|
||||||
if kustomization.Status.LastAppliedRevision != "" {
|
logger.Successf("%s last applied revision %s", kustomization.GetName(), kustomization.Status.LastAppliedRevision)
|
||||||
logger.Successf("%s last applied revision %s", kustomization.GetName(), kustomization.Status.LastAppliedRevision)
|
case corev1.ConditionUnknown:
|
||||||
} else {
|
logger.Successf("%s reconciling", kustomization.GetName())
|
||||||
logger.Successf("%s reconciling", kustomization.GetName())
|
default:
|
||||||
}
|
logger.Failuref("%s %s", kustomization.GetName(), c.Message)
|
||||||
} else {
|
|
||||||
logger.Failuref("%s %s", kustomization.GetName(), condition.Message)
|
|
||||||
}
|
|
||||||
isInitialized = true
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
isInitialized = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if !isInitialized {
|
if !isInitialized {
|
||||||
logger.Failuref("%s is not ready", kustomization.GetName())
|
logger.Failuref("%s is not ready", kustomization.GetName())
|
||||||
|
|||||||
@@ -60,18 +60,22 @@ func getSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(hidde): this should print a table, and should produce better output
|
||||||
|
// for items that have an artifact attached while they are in a reconciling
|
||||||
|
// 'Unknown' state.
|
||||||
for _, source := range list.Items {
|
for _, source := range list.Items {
|
||||||
isInitialized := false
|
isInitialized := false
|
||||||
for _, condition := range source.Status.Conditions {
|
if c := meta.GetCondition(source.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status != corev1.ConditionFalse {
|
case corev1.ConditionTrue:
|
||||||
logger.Successf("%s last fetched revision: %s", source.GetName(), source.Status.Artifact.Revision)
|
logger.Successf("%s last fetched revision: %s", source.GetName(), source.GetArtifact().Revision)
|
||||||
} else {
|
case corev1.ConditionUnknown:
|
||||||
logger.Failuref("%s %s", source.GetName(), condition.Message)
|
logger.Successf("%s reconciling", source.GetName())
|
||||||
}
|
default:
|
||||||
isInitialized = true
|
logger.Failuref("%s %s", source.GetName(), c.Message)
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
isInitialized = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if !isInitialized {
|
if !isInitialized {
|
||||||
logger.Failuref("%s is not ready", source.GetName())
|
logger.Failuref("%s is not ready", source.GetName())
|
||||||
|
|||||||
@@ -60,18 +60,22 @@ func getSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(hidde): this should print a table, and should produce better output
|
||||||
|
// for items that have an artifact attached while they are in a reconciling
|
||||||
|
// 'Unknown' state.
|
||||||
for _, source := range list.Items {
|
for _, source := range list.Items {
|
||||||
isInitialized := false
|
isInitialized := false
|
||||||
for _, condition := range source.Status.Conditions {
|
if c := meta.GetCondition(source.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status != corev1.ConditionFalse {
|
case corev1.ConditionTrue:
|
||||||
logger.Successf("%s last fetched revision: %s", source.GetName(), source.Status.Artifact.Revision)
|
logger.Successf("%s last fetched revision: %s", source.GetName(), source.GetArtifact().Revision)
|
||||||
} else {
|
case corev1.ConditionUnknown:
|
||||||
logger.Failuref("%s %s", source.GetName(), condition.Message)
|
logger.Successf("%s reconciling", source.GetName())
|
||||||
}
|
default:
|
||||||
isInitialized = true
|
logger.Failuref("%s %s", source.GetName(), c.Message)
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
isInitialized = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if !isInitialized {
|
if !isInitialized {
|
||||||
logger.Failuref("%s is not ready", source.GetName())
|
logger.Failuref("%s is not ready", source.GetName())
|
||||||
|
|||||||
@@ -60,18 +60,22 @@ func getSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(hidde): this should print a table, and should produce better output
|
||||||
|
// for items that have an artifact attached while they are in a reconciling
|
||||||
|
// 'Unknown' state.
|
||||||
for _, source := range list.Items {
|
for _, source := range list.Items {
|
||||||
isInitialized := false
|
isInitialized := false
|
||||||
for _, condition := range source.Status.Conditions {
|
if c := meta.GetCondition(source.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status != corev1.ConditionFalse {
|
case corev1.ConditionTrue:
|
||||||
logger.Successf("%s last fetched revision: %s", source.GetName(), source.Status.Artifact.Revision)
|
logger.Successf("%s last fetched revision: %s", source.GetName(), source.GetArtifact().Revision)
|
||||||
} else {
|
case corev1.ConditionUnknown:
|
||||||
logger.Failuref("%s %s", source.GetName(), condition.Message)
|
logger.Successf("%s reconciling", source.GetName())
|
||||||
}
|
default:
|
||||||
isInitialized = true
|
logger.Failuref("%s %s", source.GetName(), c.Message)
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
isInitialized = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if !isInitialized {
|
if !isInitialized {
|
||||||
logger.Failuref("%s is not ready", source.GetName())
|
logger.Failuref("%s is not ready", source.GetName())
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fluxcd/pkg/apis/meta"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
@@ -94,24 +95,25 @@ func reconcileHrCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
logger.Actionf("annotating HelmRelease %s in %s namespace", name, namespace)
|
|
||||||
if helmRelease.Annotations == nil {
|
|
||||||
helmRelease.Annotations = map[string]string{
|
|
||||||
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
helmRelease.Annotations[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
|
||||||
}
|
|
||||||
if err := kubeClient.Update(ctx, &helmRelease); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
logger.Successf("HelmRelease annotated")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating HelmRelease %s in %s namespace", name, namespace)
|
||||||
|
if helmRelease.Annotations == nil {
|
||||||
|
helmRelease.Annotations = map[string]string{
|
||||||
|
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
helmRelease.Annotations[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
|
}
|
||||||
|
if err := kubeClient.Update(ctx, &helmRelease); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("HelmRelease annotated")
|
||||||
|
|
||||||
logger.Waitingf("waiting for HelmRelease reconciliation")
|
logger.Waitingf("waiting for HelmRelease reconciliation")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
isHelmReleaseReady(ctx, kubeClient, name, namespace)); err != nil {
|
helmReleaseReconciliationHandled(ctx, kubeClient, name, namespace, helmRelease.Status.LastHandledReconcileAt),
|
||||||
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,16 +123,19 @@ func reconcileHrCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if c := meta.GetCondition(helmRelease.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if helmRelease.Status.LastAppliedRevision != "" {
|
switch c.Status {
|
||||||
logger.Successf("reconciled revision %s", helmRelease.Status.LastAppliedRevision)
|
case corev1.ConditionFalse:
|
||||||
} else {
|
return fmt.Errorf("HelmRelease reconciliation failed")
|
||||||
return fmt.Errorf("HelmRelease reconciliation failed")
|
default:
|
||||||
|
logger.Successf("reconciled revision %s", helmRelease.Status.LastAppliedRevision)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isHelmReleaseReady(ctx context.Context, kubeClient client.Client, name, namespace string) wait.ConditionFunc {
|
func helmReleaseReconciliationHandled(ctx context.Context, kubeClient client.Client,
|
||||||
|
name, namespace, lastHandledReconcileAt string) wait.ConditionFunc {
|
||||||
return func() (bool, error) {
|
return func() (bool, error) {
|
||||||
var helmRelease helmv2.HelmRelease
|
var helmRelease helmv2.HelmRelease
|
||||||
namespacedName := types.NamespacedName{
|
namespacedName := types.NamespacedName{
|
||||||
@@ -143,15 +148,6 @@ func isHelmReleaseReady(ctx context.Context, kubeClient client.Client, name, nam
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, condition := range helmRelease.Status.Conditions {
|
return helmRelease.Status.LastHandledReconcileAt != lastHandledReconcileAt, nil
|
||||||
if condition.Type == meta.ReadyCondition {
|
|
||||||
if condition.Status == corev1.ConditionTrue {
|
|
||||||
return true, nil
|
|
||||||
} else if condition.Status == corev1.ConditionFalse && helmRelease.Status.LastAttemptedRevision != "" {
|
|
||||||
return false, fmt.Errorf(condition.Message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fluxcd/pkg/apis/meta"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@@ -90,24 +93,26 @@ func reconcileKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
logger.Actionf("annotating kustomization %s in %s namespace", name, namespace)
|
|
||||||
if kustomization.Annotations == nil {
|
|
||||||
kustomization.Annotations = map[string]string{
|
|
||||||
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
kustomization.Annotations[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
|
||||||
}
|
|
||||||
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
logger.Successf("kustomization annotated")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating kustomization %s in %s namespace", name, namespace)
|
||||||
|
if kustomization.Annotations == nil {
|
||||||
|
kustomization.Annotations = map[string]string{
|
||||||
|
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
kustomization.Annotations[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
|
}
|
||||||
|
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("kustomization annotated")
|
||||||
|
|
||||||
logger.Waitingf("waiting for kustomization reconciliation")
|
logger.Waitingf("waiting for kustomization reconciliation")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(
|
||||||
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
pollInterval, timeout,
|
||||||
|
kustomizeReconciliationHandled(ctx, kubeClient, name, namespace, kustomization.Status.LastHandledReconcileAt),
|
||||||
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,11 +122,31 @@ func reconcileKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if c := meta.GetCondition(kustomization.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if kustomization.Status.LastAppliedRevision != "" {
|
switch c.Status {
|
||||||
logger.Successf("reconciled revision %s", kustomization.Status.LastAppliedRevision)
|
case corev1.ConditionFalse:
|
||||||
} else {
|
return fmt.Errorf("kustomization reconciliation failed")
|
||||||
return fmt.Errorf("kustomization sync failed")
|
default:
|
||||||
|
logger.Successf("reconciled revision %s", kustomization.Status.LastAppliedRevision)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func kustomizeReconciliationHandled(ctx context.Context, kubeClient client.Client,
|
||||||
|
name, namespace, lastHandledReconcileAt string) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
var kustomize kustomizev1.Kustomization
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &kustomize)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return kustomize.Status.LastHandledReconcileAt != lastHandledReconcileAt, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -117,13 +117,12 @@ func isBucketReady(ctx context.Context, kubeClient client.Client, name, namespac
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, condition := range bucket.Status.Conditions {
|
if c := meta.GetCondition(bucket.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status == corev1.ConditionTrue {
|
case corev1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
} else if condition.Status == corev1.ConditionFalse {
|
case corev1.ConditionFalse:
|
||||||
return false, fmt.Errorf(condition.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
@@ -117,13 +117,12 @@ func isHelmRepositoryReady(ctx context.Context, kubeClient client.Client, name,
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, condition := range helmRepository.Status.Conditions {
|
if c := meta.GetCondition(helmRepository.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status == corev1.ConditionTrue {
|
case corev1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
} else if condition.Status == corev1.ConditionFalse {
|
case corev1.ConditionFalse:
|
||||||
return false, fmt.Errorf(condition.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
@@ -112,17 +112,15 @@ func isHelmReleaseResumed(ctx context.Context, kubeClient client.Client, name, n
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, condition := range helmRelease.Status.Conditions {
|
if c := meta.GetCondition(helmRelease.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status == corev1.ConditionTrue {
|
case corev1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
} else if condition.Status == corev1.ConditionFalse {
|
case corev1.ConditionFalse:
|
||||||
if condition.Reason == meta.SuspendedReason {
|
if c.Reason == meta.SuspendedReason {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
|
||||||
|
|
||||||
return false, fmt.Errorf(condition.Message)
|
|
||||||
}
|
}
|
||||||
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
@@ -111,17 +111,15 @@ func isKustomizationResumed(ctx context.Context, kubeClient client.Client, name,
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, condition := range kustomization.Status.Conditions {
|
if c := meta.GetCondition(kustomization.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
if condition.Type == meta.ReadyCondition {
|
switch c.Status {
|
||||||
if condition.Status == corev1.ConditionTrue {
|
case corev1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
} else if condition.Status == corev1.ConditionFalse {
|
case corev1.ConditionFalse:
|
||||||
if condition.Reason == meta.SuspendedReason {
|
if c.Reason == meta.SuspendedReason {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
|
||||||
|
|
||||||
return false, fmt.Errorf(condition.Message)
|
|
||||||
}
|
}
|
||||||
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user