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

feat(otel-allocator): use type for AllocationStrategy #1220

Merged

Conversation

secustor
Copy link
Contributor

@secustor secustor commented Nov 3, 2022

Fixes #1101

This PR changes the AllocationStrategy from String to a new type.
Further it now the Allocator references now to the constants provided by the operator package.

Based on the changes of go.mod and go.sum, the footprint of this additionally dependency seems to be minimal.

@secustor secustor requested review from a team as code owners November 3, 2022 16:49
Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

Only one question here, otherwise thanks for this! Also, how was this tested?

"github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/diff"
"github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/target"
)

var _ Allocator = &consistentHashingAllocator{}

const consistentHashingStrategyName = "consistent-hashing"
const consistentHashingStrategyName = string(v1alpha1.OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing)
Copy link
Contributor

Choose a reason for hiding this comment

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

question: are we okay having the allocator import this from the operator? It means that the allocator now has a required dependency on the operator which i'm not sure we want. cc @pavolloffay

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is fine here, as mentioned in the description we are not adding any additional dependencies.
The benefit would be that we have source of truth regarding the available options.

@secustor
Copy link
Contributor Author

secustor commented Nov 3, 2022

I have deployed operator and allocator and tried all 3 different setting for AllocationStrategy and redeployed manually in between to be sure that the setting has been applied.
The TA logs showed no errors.

# Copy go mod and sum files
COPY go.mod go.sum ./
# copy operator and allocator code
COPY . .
Copy link
Member

Choose a reason for hiding this comment

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

Can this change be restructured/avoided? Doing this can cause code changes that do not change dependencies to invalidate the cached FS layer with dependencies already downloaded, which can make developing/testing with this Dockerfile annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

go mod download will fail we not copy the code first because of the new replacement directive

Alternatively we have to drop dependency to the operator here again.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should drop the dependency on the operator, I think it's going to add more complexity than it's worth.

@pavolloffay pavolloffay merged commit d53fb63 into open-telemetry:main Nov 21, 2022
@secustor secustor deleted the implement_allocation_strategy_as_type branch November 21, 2022 10:56
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
…#1220)

* feat(otel-allocator): use type for AllocationStrategy

* ci(otel-allocator): add operator to build context of allocator

* chore(otel-allocator): fix linting

* Revert "ci(otel-allocator): add operator to build context of allocator"

This reverts commit 6b9a54c.

* feat(otel-allocator): rollback dependency to operator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make target allocator's allocation strategy a type
4 participants