diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 55cacb5..da71a6e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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 @@ -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: diff --git a/Dockerfile b/Dockerfile index 7a9b264..3391bf8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM gcr.io/distroless/static-debian11 +COPY assets/ /assets + USER nonroot:nonroot ENTRYPOINT ["/usr/bin/port-k8s-exporter"] diff --git a/pkg/defaults/init.go b/pkg/defaults/init.go index 8d7e685..e0f5521 100644 --- a/pkg/defaults/init.go +++ b/pkg/defaults/init.go @@ -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. @@ -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), } diff --git a/pkg/event_handler/event_handler.go b/pkg/event_handler/event_handler.go index b75e394..401887e 100644 --- a/pkg/event_handler/event_handler.go +++ b/pkg/event_handler/event_handler.go @@ -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 diff --git a/pkg/port/cli/integration.go b/pkg/port/cli/integration.go index e158f6b..250ec18 100644 --- a/pkg/port/cli/integration.go +++ b/pkg/port/cli/integration.go @@ -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