-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Refactor sandbox creation function arguments #8289
Comments
@PannagaRao, are you working on this? I am up to take it. |
Hello @roman-kiselenko I'm planning to work on this in the next few days. |
A friendly reminder that this issue had no activity for 30 days. |
@kwilczynski @PannagaRao @saschagrunert I would like to work on this. |
@xw19, sounds good! You can also try to self-assign next time you want to take on something. 😄 |
@kwilczynski @saschagrunert @haircommander I believe we can break down the proposed changes into three separate tasks that can be implemented independently. Here's a breakdown of each task:
Do you agree with this breakdown of the tasks? If so, then each task can be tackled separately, which can potentially streamline development and testing. Please let me know your thoughts. |
I don't think we need that, the rest looks sane to me. |
I have verified that we have revive already enabled in .golangci.yml. |
@saschagrunert @kwilczynski @haircommander I need some clarification Current To instantiate a sandbox object we use sbox := sandboxFactory.New()
...
sbox.SetConfig(config)
...
sbox.SetNameAndID() Later we call the Refactor sbox := sandboxFactory.NewSandbox(config) The NewSandbox will actually call This also means we will refactor places where we are using current three lines with a single line of code. Is this correct assumption ? I want to deal first with how we create the sandbox. Later I will deal with converting spec to sandbox. |
I actually think we should take a different approach. we currently have The motivation for this approach is we shouldn't be setting the majority of the fields in a sandbox after it's created, those should be immutable. Having a group of functions that does the setting but isn't able to edit a running sandbox would better reflect what we expect. However, we don't need an intermediary structure, we can do everything inside of the |
@haircommander Yes it make sense thank you for the clarification. Let me try to summarize as Story Summary: Currently, sandbox creation involves a factory and translation object. This story proposes refactoring the sandbox creation process to make sandbox fields immutable and directly edit the Sandbox{} object. Acceptance Criteria:
Motivation:
I will later try to summarise the spec to sandbox creation. Please let me know if it need any change. |
yes! one more acceptance criteria is way more unit testing on the sandbox creation process. there are existing unit tests in |
@haircommander I have gone through the code and trying to ideate a solution. So this is in a way thinking out loud.
This is multi-step process. I feel what we can use Builder pattern instead of a Factory pattern. (https://refactoring.guru/design-patterns/builder) Here are is some of the code that I am thinking right now type SandboxBuilder interface {
//reset Resets the builder to create a new object
reset()
GetSandBox()
GetConfig()
GetName()
GetID()
SetConfig()
SetNameAndID()
SetInfraContainerID()
SetNameSpace()
SetCriSandBox()
SetDNSConfig()
...
} And now inside the sbuilder.SetConfig(req.Config)
sbuilder.SetNameAndID()
...
sboxName := sbuilder.Name()
sandbox = sbuilder.GetSandbox() Call to the sbuilder.GetSandbox resets the Sandbox. Please share your thought on this. |
looks good! one question: would there be multiple builder objects per cri-o server or just one? |
@haircommander If we use a singleton pattern for SandboxBuilder, we will only be able to create one Sandbox at a time. Therefore, this is not an ideal solution, and we should use multiple Builder objects. |
I think we don't need reset. The whole process will be similar to what we do now, but instead, we will have a single builder object responsible for all the work, eliminating the need for intermediary objects. |
A friendly reminder that this issue had no activity for 30 days. |
A friendly reminder that this issue had no activity for 30 days. |
This issue is created to perform the following
The modifications discussed in suggest a different approach. It is proposed to relocate internal/factory packages into oci and sandbox packages. Additionally, a new file named factory.go should be created in each package to define setters and translation functions. The objective is to establish a method for converting CRI specifications and server configurations into sandbox/container instances, and also to enable the restoration of these instances from a file.
A factory object, upon creation, should generate a sandbox object. Through the use of setters, its configurations are determined, and subsequently, the sandbox object is instantiated with the defined attributes. Once created, the sandbox object becomes immutable.
The text was updated successfully, but these errors were encountered: