Skip to content

Commit

Permalink
remove support for legacy endpoint
Browse files Browse the repository at this point in the history
as its been 2 years to support legacy
endpoint, lets remove the support for it.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 authored and mergify[bot] committed Nov 13, 2024
1 parent 67dbe71 commit e8fdbd4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
11 changes: 1 addition & 10 deletions internal/controller/csiaddons/csiaddonsnode_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ import (

var (
csiAddonsNodeFinalizer = csiaddonsv1alpha1.GroupVersion.Group + "/csiaddonsnode"

errLegacyEndpoint = errors.New("legacy formatted endpoint")
)

// CSIAddonsNodeReconciler reconciles a CSIAddonsNode object
Expand Down Expand Up @@ -207,9 +205,7 @@ func (r *CSIAddonsNodeReconciler) removeFinalizer(
// by GRPC to connect to the sidecar.
func (r *CSIAddonsNodeReconciler) resolveEndpoint(ctx context.Context, rawURL string) (string, error) {
namespace, podname, port, err := parseEndpoint(rawURL)
if err != nil && errors.Is(err, errLegacyEndpoint) {
return rawURL, nil
} else if err != nil {
if err != nil {
return "", err
}

Expand All @@ -231,11 +227,6 @@ func (r *CSIAddonsNodeReconciler) resolveEndpoint(ctx context.Context, rawURL st
// format. When the recommended format is used, it returns the Namespace,
// PodName, Port and error instead.
func parseEndpoint(rawURL string) (string, string, string, error) {
// assume old formatted endpoint, don't parse it
if !strings.Contains(rawURL, "://") {
return "", "", "", errLegacyEndpoint
}

endpoint, err := url.Parse(rawURL)
if err != nil {
return "", "", "", fmt.Errorf("failed to parse endpoint %q: %w", rawURL, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package controller

import (
"errors"
"testing"

"github.com/csi-addons/spec/lib/go/identity"
Expand All @@ -26,11 +25,8 @@ import (
)

func TestParseEndpoint(t *testing.T) {
_, _, _, err := parseEndpoint("1.2.3.4:5678")
assert.True(t, errors.Is(err, errLegacyEndpoint))

// test empty namespace
_, _, _, err = parseEndpoint("pod://pod-name:5678")
_, _, _, err := parseEndpoint("pod://pod-name:5678")
assert.Error(t, err)

// test empty namespace
Expand Down

0 comments on commit e8fdbd4

Please sign in to comment.