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

fix(agent): warn instead of error the policy removal error when polic… #2986

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions agent/backend/pktvisor/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"fmt"
"net/http"
"strings"

"github.com/orb-community/orb/agent/policies"
"go.uber.org/zap"
Expand Down Expand Up @@ -60,8 +61,11 @@ func (p *pktvisorBackend) RemovePolicy(data policies.PolicyData) error {
} else {
name = data.Name
}
err := p.request(fmt.Sprintf("policies/%s", name), &resp, http.MethodDelete, http.NoBody, "application/json", RemovePolicyTimeout)
if err != nil {
if err := p.request(fmt.Sprintf("policies/%s", name), &resp, http.MethodDelete, http.NoBody, "application/json", RemovePolicyTimeout); err != nil {
if strings.Contains(err.Error(), "404") {
p.logger.Warn("ignoring error from removing a policy which was not found", zap.String("policy_id", data.ID), zap.String("policy_name", name))
lpegoraro marked this conversation as resolved.
Show resolved Hide resolved
return nil
}
return err
}
return nil
Expand Down
Loading