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

implement new service start style #1024

Closed
wants to merge 3 commits into from
Closed

implement new service start style #1024

wants to merge 3 commits into from

Conversation

ilgooz
Copy link
Contributor

@ilgooz ilgooz commented Jun 4, 2019

while using new instance db.

depends on #1023.

@mesg-foundation/core please keep in mind that, since listenTask() only accepts service hashes, an instance created by instancesdk.Create() cannot start listening for tasks yet. I can make listenTask() to both accept service hash and instance hash if necessary but in another PR. Please request this feature if you think it's needed right now, otherwise i'll eventually do it after we merge everything related to new deployment/start style.

@ilgooz ilgooz requested a review from a team June 4, 2019 22:51
@ilgooz ilgooz changed the base branch from dev to fix/new-deploy June 4, 2019 22:52
@ilgooz ilgooz changed the base branch from fix/new-deploy to dev June 4, 2019 22:52
@ilgooz ilgooz force-pushed the feature/new-start branch 7 times, most recently from dc896a9 to 6881295 Compare June 5, 2019 00:08
@@ -6,9 +6,11 @@ import (

// Manager is responsible for managing Docker Containers of MESG services.
// it can be implemented for any container orchestration tool.
// TODO(ilgooz): discuss if these should accept service.Instance instead of service.Service.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mesg-foundation/core please provide feedbacks about this.

Copy link
Member

Choose a reason for hiding this comment

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

Yes it should accept instance and I think this function can be moved directly to the sdk under the instance sdk

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'll do this improvement in an another PR

Copy link
Member

Choose a reason for hiding this comment

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

Yes it should accept instance instead of service.
Agree also to move the manager package directly inside sdk/instance.

@@ -60,6 +60,16 @@ type Service struct {
DeployedAt time.Time `hash:"-"`
}

// Instance represents a running instance of service.
type Instance struct {
Sid string
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of this sid? is it to be able to run an instance based on the sid? If this is the case it should be removed and the api/sdk should do the resolution and Instance only have a service hash

Copy link
Contributor Author

@ilgooz ilgooz Jun 5, 2019

Choose a reason for hiding this comment

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

It's for extra doc that we can send to cli on an instance create or delete action. I can rm this and fetch it from service db. let's do it an another PR

Copy link
Member

Choose a reason for hiding this comment

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

Yes please remove Sid.

Copy link
Member

@NicolasMahe NicolasMahe Jun 6, 2019

Choose a reason for hiding this comment

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

Also move the struct instance in its own package instance or in the instanceDB package?

@@ -6,9 +6,11 @@ import (

// Manager is responsible for managing Docker Containers of MESG services.
// it can be implemented for any container orchestration tool.
// TODO(ilgooz): discuss if these should accept service.Instance instead of service.Service.
Copy link
Member

Choose a reason for hiding this comment

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

Yes it should accept instance and I think this function can be moved directly to the sdk under the instance sdk

sdk/instance/instance.go Show resolved Hide resolved
@ilgooz
Copy link
Contributor Author

ilgooz commented Jun 5, 2019

from @antho1404
I would move the logic from the manager directly in this package.

Any reason why? To me this should be handled by implementations of Manager. That way, the chosen Manager implementation can provide its own info easily. Otherwise we have to switch check to determine underlying orchestration tool used and maybe create different type of info for each (if in sdk/instance).

}

// Create creates a new service instance for service with id(sid/hash) and applies given env vars.
func (i *Instance) Create(id string, env []string) (*service.Instance, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (i *Instance) Create(id string, env []string) (*service.Instance, error) {
func (i *Instance) Create(serviceHash string, env []string) (*service.Instance, error) {

Not blocking but I would rename the id variable to something way more explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed with @antho1404, I'll change the name but still resolve the sid inside to service hash when sid is given in the argument.


srv.Hash = instanceHash
srv.Configuration.Image = imageHash
srv.Configuration.Env = xos.EnvMapToSlice(instanceEnv)
Copy link
Member

Choose a reason for hiding this comment

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

The above 3 lines have to me removed.
The service should not be modified when an instance is created.
The goal is actually to be able to create multiple instance for one service.
The instance have to directly contains those 3 info: instanceHash, imageHash and merge envs

Copy link
Member

@NicolasMahe NicolasMahe Jun 6, 2019

Choose a reason for hiding this comment

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

The instanceHash and imageHash are already saved in the instance struct.

The env could also be saved in the instance struct OR directly send to the function start of the container. Up to you.
Not saving the customs envs feel a bit saffer. It will be very hard to expose them on a public api if they are not saved in a db

@antho1404
Copy link
Member

Any reason why? To me this should be handled by implementations of Manager. That way, the chosen Manager implementation can provide its own info easily. Otherwise we have to switch check to determine underlying orchestration tool used and maybe create different type of info for each (if in sdk/instance).

The orchestration tool used should be managed by the container package directly and the manager should anyway not be aware of that.
The manager is actually doing some actions (kind of a controller) so it makes sense to me to put it in the package for all the actions (sdk).
Also, this manager does not manage services anymore but instances so it doesn't make sense to have it in the service package anyway.

Also, lint and test are failing

@antho1404
Copy link
Member

antho1404 commented Jun 7, 2019

@ilgooz ilgooz closed this Jun 7, 2019
@ilgooz ilgooz deleted the feature/new-start branch June 7, 2019 16:31
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.

3 participants