Skip to content

Commit

Permalink
fix by comment
Browse files Browse the repository at this point in the history
Signed-off-by: LiZhenCheng9527 <[email protected]>
  • Loading branch information
LiZhenCheng9527 committed Jan 9, 2024
1 parent 4140636 commit 6ad5854
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pkg/fleet-manager/application/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (a *ApplicationManager) syncPolicyResource(ctx context.Context, app *applic
}

if result, err := a.syncRolloutPolicyForCluster(ctx, syncPolicy.Rollout, rolloutClusters, policyName); err != nil {
return result, errors.Wrapf(err, "failed to handleSyncPolicyByKind currentFleetCluster")
return result, errors.Wrapf(err, "failed to syncRolloutPolicy")
}
}

Expand Down
17 changes: 1 addition & 16 deletions pkg/fleet-manager/application/manifests/rollout_testloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import (
"bytes"
"text/template"

"github.com/Masterminds/sprig/v3"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/yaml"
)

type TestloaderConfig struct {
Expand Down Expand Up @@ -62,21 +60,8 @@ func renderTestloaderTemplateConfig(constTemplateName string, cfg TestloaderConf
return b.Bytes(), nil
}

// funMap returns a map of functions for use in the template.
func funMap() template.FuncMap {
m := sprig.TxtFuncMap()
m["toYaml"] = toYaml
return m
}

// toYaml converts a given value to its YAML representation.
func toYaml(value interface{}) string {
y, err := yaml.Marshal(value)
if err != nil {
return ""
}

return string(y)
return nil
}

const TestlaoderDeployment = `apiVersion: apps/v1
Expand Down
9 changes: 3 additions & 6 deletions pkg/fleet-manager/application/rollout_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ func installPrivateTestloader(ctx context.Context, namespacedName types.Namespac
func deleteResourceCreatedByKurator(ctx context.Context, namespaceName types.NamespacedName, kubeClient client.Client, obj client.Object) error {
if err := kubeClient.Get(ctx, namespaceName, obj); err != nil {
if !apierrors.IsNotFound(err) {
return errors.Wrapf(err, "get kubernetes resource error")
return errors.Wrapf(err, "falied to get resource %s in %s", namespaceName.Name, namespaceName.Namespace)
}
} else {
// verify if the deployment were created by kurator
annotations := obj.GetAnnotations()
if _, exist := annotations[RolloutIdentifier]; exist {
if deleteErr := kubeClient.Delete(ctx, obj); deleteErr != nil {
if deleteErr := kubeClient.Delete(ctx, obj); deleteErr != nil && !apierrors.IsNotFound(deleteErr) {
return errors.Wrapf(deleteErr, "failed to delete kubernetes resource")
}
}
Expand All @@ -238,9 +238,6 @@ func deleteResourceCreatedByKurator(ctx context.Context, namespaceName types.Nam

// create/update canary configuration
func renderCanary(rolloutPolicy applicationapi.RolloutConfig, canaryInCluster *flaggerv1b1.Canary) *flaggerv1b1.Canary {
value := int32(*rolloutPolicy.RolloutPolicy.RolloutTimeoutSeconds)
ptrValue := &value

canaryInCluster.ObjectMeta.Namespace = rolloutPolicy.Workload.Namespace
canaryInCluster.ObjectMeta.Name = rolloutPolicy.Workload.Name
canaryInCluster.TypeMeta.Kind = "Canary"
Expand All @@ -252,7 +249,7 @@ func renderCanary(rolloutPolicy applicationapi.RolloutConfig, canaryInCluster *f
Kind: rolloutPolicy.Workload.Kind,
Name: rolloutPolicy.Workload.Name,
},
ProgressDeadlineSeconds: ptrValue,
ProgressDeadlineSeconds: rolloutPolicy.RolloutPolicy.RolloutTimeoutSeconds,
SkipAnalysis: rolloutPolicy.RolloutPolicy.SkipTrafficAnalysis,
RevertOnDeletion: rolloutPolicy.RolloutPolicy.RevertOnDeletion,
Suspend: rolloutPolicy.RolloutPolicy.Suspend,
Expand Down
3 changes: 2 additions & 1 deletion pkg/fleet-manager/application/rollout_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

func generateRolloutPloicy(installPrivateTestloader *bool) applicationapi.RolloutConfig {
timeout := 50
RolloutTimeoutSeconds := int32(50)
min := 99.0
max := 500.0

Expand Down Expand Up @@ -128,7 +129,7 @@ func generateRolloutPloicy(installPrivateTestloader *bool) applicationapi.Rollou
MaxAge: 24,
},
},
RolloutTimeoutSeconds: &timeout,
RolloutTimeoutSeconds: &RolloutTimeoutSeconds,
SkipTrafficAnalysis: false,
RevertOnDeletion: false,
Suspend: false,
Expand Down

0 comments on commit 6ad5854

Please sign in to comment.