Skip to content

Commit

Permalink
Merge pull request #29 from port-labs/PORT-5858-integration-already-e…
Browse files Browse the repository at this point in the history
…xists

Port 5858 integration already exists
  • Loading branch information
yairsimantov20 authored Dec 31, 2023
2 parents e145cbb + c594918 commit af6615a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
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

0 comments on commit af6615a

Please sign in to comment.