Skip to content

Fix Supervisor sending empty port names and descriptions #9797

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

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions components/gitpod-protocol/go/gitpod-config-types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions components/supervisor/pkg/ports/ports-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ func (configs *Configs) Get(port uint32) (*gitpod.PortConfig, ConfigKind, bool)
for _, rangeConfig := range configs.instanceRangeConfigs {
if rangeConfig.Start <= port && port <= rangeConfig.End {
return &gitpod.PortConfig{
Port: float64(port),
OnOpen: rangeConfig.OnOpen,
Visibility: rangeConfig.Visibility,
Port: float64(port),
OnOpen: rangeConfig.OnOpen,
Visibility: rangeConfig.Visibility,
Description: rangeConfig.Description,
Name: rangeConfig.Name,
}, RangeConfigKind, true
}
}
Expand Down Expand Up @@ -197,9 +199,11 @@ func parseInstanceConfigs(ports []*gitpod.PortsItems) (portConfigs map[uint32]*g
_, exists := portConfigs[port]
if !exists {
portConfigs[port] = &gitpod.PortConfig{
OnOpen: config.OnOpen,
Port: float64(Port),
Visibility: config.Visibility,
OnOpen: config.OnOpen,
Port: float64(Port),
Visibility: config.Visibility,
Description: config.Description,
Name: config.Name,
}
}
continue
Expand Down
48 changes: 30 additions & 18 deletions components/supervisor/pkg/ports/ports-config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ func TestPortsConfig(t *testing.T) {
Desc: "workspace port config",
WorkspacePorts: []*gitpod.PortConfig{
{
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
Expectation: &PortConfigTestExpectations{
WorkspaceConfigs: []*gitpod.PortConfig{
{
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
},
Expand All @@ -49,18 +53,22 @@ func TestPortsConfig(t *testing.T) {
GitpodConfig: &gitpod.GitpodConfig{
Ports: []*gitpod.PortsItems{
{
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
},
Expectation: &PortConfigTestExpectations{
InstancePortConfigs: []*gitpod.PortConfig{
{
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
},
Expand All @@ -70,19 +78,23 @@ func TestPortsConfig(t *testing.T) {
GitpodConfig: &gitpod.GitpodConfig{
Ports: []*gitpod.PortsItems{
{
Port: "9229-9339",
OnOpen: "ignore",
Visibility: "public",
Port: "9229-9339",
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
},
Expectation: &PortConfigTestExpectations{
InstanceRangeConfigs: []*RangeConfig{
{
PortsItems: &gitpod.PortsItems{
Port: "9229-9339",
OnOpen: "ignore",
Visibility: "public",
Port: "9229-9339",
OnOpen: "ignore",
Visibility: "public",
Description: "Nice Port Description",
Name: "Nice Port Name",
},
Start: 9229,
End: 9339,
Expand Down
6 changes: 6 additions & 0 deletions components/supervisor/pkg/ports/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ func (pm *Manager) nextState(ctx context.Context) map[uint32]*managedPort {

var public bool
config, kind, exists := pm.configs.Get(mp.LocalhostPort)
if exists {
Copy link
Member

@akosyakov akosyakov May 24, 2022

Choose a reason for hiding this comment

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

I wonder why it is necessary here, configurations should be handled above at step 2, this step about served state

Copy link
Member

Choose a reason for hiding this comment

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

ah, it is for ranges?

Copy link
Member

Choose a reason for hiding this comment

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

Do we miss here anything else like visibility handling or action on expose?

It can be another PR too.

Copy link
Contributor

Choose a reason for hiding this comment

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

visibility (port private and public) is handled here

mp.AutoExposure = pm.autoExpose(ctx, mp.LocalhostPort, public).state

Copy link
Member

@akosyakov akosyakov May 24, 2022

Choose a reason for hiding this comment

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

Do we need to call mp.OnExposed = getOnExposedAction(config, port)? or it is handled already somewhere too?

Copy link
Contributor

@mustard-mh mustard-mh May 24, 2022

Choose a reason for hiding this comment

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

Do we need to call mp.OnExposed = getOnExposedAction(config, port)? or it is handled already somewhere too?

added

I tested with onOpen: open-browser with ranges before and it works fine, but I don't know where is code. Add to confirm it

Copy link
Member

Choose a reason for hiding this comment

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

thank you, great 👍

Copy link
Member

Choose a reason for hiding this comment

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

maybe a commit in if will be nice, that we are handling configuration for port ranges here

mp.Name = config.Name
mp.Description = config.Description
mp.OnExposed = getOnExposedAction(config, mp.LocalhostPort)
}

configured := exists && kind == PortConfigKind
if mp.Exposed || configured {
public = mp.Visibility == api.PortVisibility_public
Expand Down