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

Resolve index out of range when running locally #668

Closed
pjbgf opened this issue Apr 12, 2022 · 5 comments
Closed

Resolve index out of range when running locally #668

pjbgf opened this issue Apr 12, 2022 · 5 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@pjbgf
Copy link
Member

pjbgf commented Apr 12, 2022

The controller may panic depending on the HOSTNAME defined. This is not a problem when running as a pod with the default source-controller name, however, it fails when users try to run the controller on their local machines if RUNTIME_NAMESPACE is non empty and their machine names does not contain hyphens.

	if os.Getenv("RUNTIME_NAMESPACE") != "" {
		svcParts := strings.Split(os.Getenv("HOSTNAME"), "-")
		return fmt.Sprintf("%s.%s",
			strings.Join(svcParts[:len(svcParts)-2], "-"), os.Getenv("RUNTIME_NAMESPACE"))
	}

https://github.com/fluxcd/source-controller/blob/main/main.go#L317-L321

@pjbgf pjbgf added bug Something isn't working good first issue Good for newcomers labels Apr 12, 2022
@pjbgf pjbgf added this to the GA milestone Apr 12, 2022
@EdwinWalela
Copy link
Contributor

How about checking the length of svcParts where if it's equal to 1 (meaning there is no hyphen) we return just the environment variable as it is?

@pjbgf
Copy link
Member Author

pjbgf commented Apr 13, 2022

@EdwinWalela we should be able to remove that if block (and the two comments above it) completely and just rely on the storageAddr that is passed in. Are you keen on proposing a PR for this?

@EdwinWalela
Copy link
Contributor

@pjbgf That's even better. Sure, I can take this up

@pjbgf
Copy link
Member Author

pjbgf commented Apr 13, 2022

That's awesome, @EdwinWalela. I have assigned the issue to you.

@pjbgf
Copy link
Member Author

pjbgf commented Apr 14, 2022

Fixed by #672

@pjbgf pjbgf closed this as completed Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants