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

detect ipv6 dest addr and pass with [] to rsync #405

Merged
merged 2 commits into from
Sep 8, 2022

Conversation

tesshuflower
Copy link
Contributor

Signed-off-by: Tesshu Flower [email protected]

Describe what this PR does
Rsync if provided with an IPv6 address needs to use the address in the format [ipv6addr]. This is a URL format.

In the mover script, attempt to detect if the destination address is an ipv6 address and wrap with [] only if it does not already contain []. This hopefully avoids issues with urls that are already formatted correctly.

Is there anything that requires special attention?

  • Crude ipv6 check - checking that there are enough stanzas with : (or :: is found)
  • Also avoids wrapping with [] if the address already contains [] - potentially could happen with a url address that embeds an ipv6 address?

Related issues:
#402

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 30, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tesshuflower

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

Merging #405 (26262aa) into main (066f018) will increase coverage by 0.1%.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #405     +/-   ##
=======================================
+ Coverage   64.1%   64.2%   +0.1%     
=======================================
  Files         44      45      +1     
  Lines       5171    5236     +65     
=======================================
+ Hits        3317    3364     +47     
- Misses      1657    1671     +14     
- Partials     197     201      +4     
Impacted Files Coverage Δ
controllers/utils/affinity.go 85.5% <0.0%> (-1.8%) ⬇️
controllers/platform/properties.go 67.4% <0.0%> (ø)

@tesshuflower tesshuflower changed the title WIP detect ipv6 dest addr and pass with [] to rsync detect ipv6 dest addr and pass with [] to rsync Sep 7, 2022
@tesshuflower
Copy link
Contributor Author

/cc @JohnStrunk

John, do you mind taking a look at this? I wasn't able to get an easily accessible ipv6 env so haven't re-tested, but have been using this patch in other non-ipv6 rsync tests.

Comment on lines 43 to 48
if [[ "$DESTINATION_ADDRESS" == *"::"* || "$DESTINATION_ADDRESS" == *":"*":"*":"*":"*":"*":"*":"* ]]; then
echo "Destination address $DESTINATION_ADDRESS is ipv6"
if [[ "$DESTINATION_ADDRESS" != *"["*"]"* ]]; then
URL_DESTINATION_ADDRESS="[$DESTINATION_ADDRESS]"
fi
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The matching makes me nervous. What about bash regular expressions:

# Looking for either:
# 1) 8 groups of hex digits separated by ":"
# 2) a "::" in the string
IPV6_REGEX='(([0-9a-fA-F]{0,4}:){7}[0-9a-fA-F]{0,4})|(::)'

if [[ "$DESTINATION_ADDRESS" =~ $IPV6_REGEX ]]; then
    echo "It's IPv6"
fi

if [[ ! "$DESTINATION_ADDRESS" =~ \[.*\] ]]; then
    echo "no brackets"
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's much nicer than what I had - I'm terrible with regex's so threw my version together fast before I lost that ipv6 env...I've done a bunch of different address checks and I think your suggestion looks good to me - will update...

@sonarcloud
Copy link

sonarcloud bot commented Sep 8, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@JohnStrunk
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Sep 8, 2022
@openshift-merge-robot openshift-merge-robot merged commit e232e6b into backube:main Sep 8, 2022
@tesshuflower tesshuflower deleted the 402_rsync_ipv6 branch September 8, 2022 19:58
@tesshuflower
Copy link
Contributor Author

/cherrypick release-0.5

@openshift-cherrypick-robot

@tesshuflower: new pull request created: #437

In response to this:

/cherrypick release-0.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants