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

chore(env): env show should show deployed jobs #3316

Merged
merged 3 commits into from
Mar 2, 2022

Conversation

paragbhingre
Copy link
Contributor

This PR adds functionality to show jobs on env show command

This PR addresses #3237

User interface -
Screen Shot 2022-03-01 at 11 47 20 AM

@paragbhingre paragbhingre requested a review from a team as a code owner March 1, 2022 19:47
@paragbhingre paragbhingre requested review from efekarakus and removed request for a team March 1, 2022 19:47
Copy link
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

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

Great job!

@@ -246,6 +253,27 @@ func (d *EnvDescriber) filterDeployedSvcs() ([]*config.Workload, error) {
return deployedSvcs, nil
}

// filterDeployedJobs lists the jobs that are deployed on the given app and environment
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it's nicee to have a description but function comment is not required if the function is not exported.

func (d *EnvDescriber) filterDeployedJobs() ([]*config.Workload, error) {
allJobs, err := d.configStore.ListJobs(d.app)
if err != nil {
return nil, fmt.Errorf("list services for app %s: %w", d.app, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("list services for app %s: %w", d.app, err)
return nil, fmt.Errorf("list jobs for app %s: %w", d.app, err)

for _, job := range allJobs {
jobs[job.Name] = job
}
deployedJobNames, err := d.deployStore.ListDeployedJobs(d.app, d.env.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm we don't necessarily address this in this particular PR but in the near future we should refactor this so that listDeployedWorkloads of deployStore returns []*config.Workload instead of []string. This will simplify the logic of filterDeployedSvcs and filterDeployedJobs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes totally agree, I guess then we don't need to make 2 separate calls to bring []*config.Workload and then []string and add custom logic to filter them.

@@ -274,6 +302,15 @@ func (e *EnvDescription) HumanString() string {
fmt.Fprintf(writer, " %s\t%s\n", svc.Name, svc.Type)
}
writer.Flush()
fmt.Fprint(writer, color.Bold.Sprint("\nJobs\n\n"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we want to only show the Jobs section only when there is/are job(s) deployed (btw I think what you have now is fine too)

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 guess it is okay for the awareness of the customers that Jobs are also being showed as a part of env show. And also it aligns with the current implementation for services.

@@ -35,12 +35,14 @@ type ConfigStoreSvc interface {
ListEnvironments(appName string) ([]*config.Environment, error)
ListServices(appName string) ([]*config.Workload, error)
GetWorkload(appName string, name string) (*config.Workload, error)
ListJobs(appName string) ([]*config.Workload, error)
}

// DeployedEnvServicesLister wraps methods of deploy store.
type DeployedEnvServicesLister interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of renaming this to DeployedEnvWorkloadsLister?

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 thought of doing so but there are a lot of places where we need to change if we change it to DeployedEnvWorkloadsLister. for example, impacted places are -

  1. env.go
  2. env_test.go
  3. lb_web_service.go
  4. lb_web_service_test.go
  5. mock_service.go
  6. rd_web_service.go
  7. rd_web_service_test.go
  8. service.go
  9. worker_service.go

If we really be touching so many files as a part of env show implementation?

@Lou1415926 Lou1415926 added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Mar 2, 2022
Copy link
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

🎊

@paragbhingre paragbhingre removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Mar 2, 2022
@Lou1415926 Lou1415926 changed the title chore(env): env show should show deployed jobs chore(env): env show should show deployed jobs Mar 2, 2022
@mergify mergify bot merged commit 4005822 into aws:mainline Mar 2, 2022
@paragbhingre paragbhingre deleted the envShow branch January 26, 2023 06:43
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