Skip to content

Commit

Permalink
Merge pull request #1211 from equinor/master
Browse files Browse the repository at this point in the history
Fixed sync radix environment error (#1210)
  • Loading branch information
satr authored Oct 14, 2024
2 parents fabb9e7 + 9b2db23 commit 3f84f9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions charts/radix-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: radix-operator
version: 1.43.0
appVersion: 1.63.0
version: 1.43.1
appVersion: 1.63.1
kubeVersion: ">=1.24.0"
description: Radix Operator
keywords:
Expand Down
21 changes: 12 additions & 9 deletions pkg/apis/environment/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ import (
)

func (env *Environment) syncStatus(ctx context.Context, radixEnvironment *radixv1.RadixEnvironment, time metav1.Time) error {
if err := updateRadixEnvironmentStatus(ctx, env.radixclient, env.appConfig, radixEnvironment, time); err != nil {
if err := env.updateRadixEnvironmentStatus(ctx, env.radixclient, env.appConfig, radixEnvironment, time); err != nil {
return fmt.Errorf("failed to update status on environment %s: %w", radixEnvironment.Spec.EnvName, err)
}
currentEnv, err := env.radixclient.RadixV1().RadixEnvironments().Get(ctx, radixEnvironment.Spec.EnvName, metav1.GetOptions{})
if err != nil {
return err
}
env.config = currentEnv
env.logger.Debug().Msgf("updated status of RadixEnvironment (revision %s)", currentEnv.GetResourceVersion())
return nil
}

func updateRadixEnvironmentStatus(ctx context.Context, radixClient versioned.Interface, radixApplication *radixv1.RadixApplication, radixEnvironment *radixv1.RadixEnvironment, time metav1.Time) error {
func (env *Environment) updateRadixEnvironmentStatus(ctx context.Context, radixClient versioned.Interface, radixApplication *radixv1.RadixApplication, radixEnvironment *radixv1.RadixEnvironment, time metav1.Time) error {
radixEnvironmentInterface := radixClient.RadixV1().RadixEnvironments()
return retry.RetryOnConflict(retry.DefaultRetry, func() error {
name := radixEnvironment.GetName()
Expand All @@ -33,7 +27,16 @@ func updateRadixEnvironmentStatus(ctx context.Context, radixClient versioned.Int
return err
}
changeStatus(radixApplication, radixEnvironment.Spec.EnvName, &currentEnv.Status, time)
_, err = radixEnvironmentInterface.UpdateStatus(ctx, currentEnv, metav1.UpdateOptions{})
updated, err := radixEnvironmentInterface.UpdateStatus(ctx, currentEnv, metav1.UpdateOptions{})
if err == nil && env.config.GetName() == name {
currentEnv, err = radixEnvironmentInterface.Get(ctx, name, metav1.GetOptions{})
if err != nil {
return err
}
env.config = currentEnv
env.logger.Debug().Msgf("updated status of RadixEnvironment (revision %s)", updated.GetResourceVersion())
return nil
}
return err
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/environment/testdata/re.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: radix.equinor.com/v1
kind: RadixEnvironment
metadata:
name: testenv
name: testapp-testenv
uid: af1d2960-5eb7-40e8-9ca2-12fc1fd9916e
finalizers:
- radix.equinor.com/environment-finalizer
Expand Down

0 comments on commit 3f84f9d

Please sign in to comment.