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

Port 5858 integration already exists #29

Merged
merged 22 commits into from
Dec 31, 2023
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
4 changes: 4 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ dockers:
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--platform=linux/amd64"
extra_files:
- assets/
- image_templates:
- "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Version }}-arm64v8"
use: buildx
Expand All @@ -44,6 +46,8 @@ dockers:
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--platform=linux/arm64/v8"
extra_files:
- assets/
docker_manifests:
- name_template: "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Version }}"
image_templates:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM gcr.io/distroless/static-debian11

COPY assets/ /assets

USER nonroot:nonroot

ENTRYPOINT ["/usr/bin/port-k8s-exporter"]
Expand Down
5 changes: 3 additions & 2 deletions pkg/defaults/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func InitIntegration(portClient *cli.PortClient, applicationConfig *port.Config)
}

if err != nil {
klog.Infof("Integration does not exist, creating a new one")
klog.Infof("Could not get integration with state key %s, error: %s", applicationConfig.StateKey, err.Error())
klog.Infof("Creating integration")
// The exporter supports a deprecated case where resources are provided in config file and integration does not
// exist. If this is not the case, we support the new way of creating the integration with the default resources.
// Only one of the two cases can be true.
Expand All @@ -46,7 +47,7 @@ func InitIntegration(portClient *cli.PortClient, applicationConfig *port.Config)
// Handle a deprecated case where resources are provided in config file
return integration.CreateIntegration(portClient, applicationConfig.StateKey, applicationConfig.EventListenerType, defaultIntegrationConfig)
} else {
klog.Infof("Integration exists, patching it")
klog.Infof("Integration with state key %s already exists, patching it", applicationConfig.StateKey)
integrationPatch := &port.Integration{
EventListener: getEventListenerConfig(applicationConfig.EventListenerType),
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/event_handler/event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ type IStoppableRsync interface {
func Start(eventListener IListener, initControllerHandler func() (IStoppableRsync, error)) error {
controllerHandler, err := initControllerHandler()
if err != nil {
return err
utilruntime.HandleError(fmt.Errorf("error resyncing: %s", err.Error()))
}

return eventListener.Run(func() {
klog.Infof("Resync request received. Recreating controllers for the new port configuration")
if controllerHandler != nil {
controllerHandler.Stop()
}
controllerHandler.Stop()
newController, resyncErr := initControllerHandler()
controllerHandler = newController
Expand Down
1 change: 0 additions & 1 deletion pkg/port/cli/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func (c *PortClient) CreateIntegration(i *port.Integration) (*port.Integration,
resp, err := c.Client.R().
SetBody(parseIntegration(i)).
SetResult(&pb).
SetQueryParam("upsert", "true").
Post("v1/integration")
if err != nil {
return nil, err
Expand Down
Loading