Skip to content
Open
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
19 changes: 3 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,15 @@ COPY ./Makefile ./Makefile
COPY ./version ./version
COPY ./cmd/main.go ./cmd/main.go
COPY ./internal ./internal
COPY ./must-gather ./must-gather

USER 0
RUN make build

FROM quay.io/openshift/origin-cli-artifacts:latest AS origincli

RUN case $(uname -m) in \
x86_64) cp /usr/share/openshift/linux_amd64/oc.rhel9 /tmp/oc ;; \
aarch64) cp /usr/share/openshift/linux_arm64/oc.rhel9 /tmp/oc ;; \
ppc64le) cp /usr/share/openshift/linux_ppc64le/oc.rhel9 /tmp/oc ;; \
s390x) cp /usr/share/openshift/linux_s390x/oc /tmp/oc ;; \
*) echo "Unsupported architecture"; exit 1 ;; \
esac

FROM registry.access.redhat.com/ubi9/ubi-minimal

RUN INSTALL_PKGS=" \
openssl \
rsync \
file \
xz \
" && \
microdnf install -y ${INSTALL_PKGS} && \
rpm -V ${INSTALL_PKGS} && \
Expand All @@ -41,10 +29,9 @@ RUN INSTALL_PKGS=" \
chmod og+w /tmp/ocp-clo

COPY --from=builder /opt/app-root/src/bin/cluster-logging-operator /usr/bin/
COPY --from=builder /opt/app-root/src/bin/must-gather /usr/bin/

COPY --from=origincli /tmp/oc /usr/bin/oc

COPY ./must-gather/collection-scripts/* /usr/bin/
RUN ln -s /usr/bin/must-gather /usr/bin/gather

USER 1000
WORKDIR /usr/bin
Expand Down
21 changes: 3 additions & 18 deletions Dockerfile.art
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,10 @@ WORKDIR /opt/app-root/src

RUN make build BUILD_OPTS="-tags strictfipsruntime"


FROM quay.io/openshift/origin-cli-artifacts:4.21 AS origincli

RUN case $(uname -m) in \
x86_64) cp /usr/share/openshift/linux_amd64/oc.rhel9 /tmp/oc ;; \
aarch64) cp /usr/share/openshift/linux_arm64/oc.rhel9 /tmp/oc ;; \
ppc64le) cp /usr/share/openshift/linux_ppc64le/oc.rhel9 /tmp/oc ;; \
s390x) cp /usr/share/openshift/linux_s390x/oc /tmp/oc ;; \
*) echo "Unsupported architecture"; exit 1 ;; \
esac

FROM registry.redhat.io/ubi9/ubi-minimal:9.7

RUN INSTALL_PKGS=" \
cpio \
rsync \
file \
xz \
openssl \
" && \
microdnf install -y $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
Expand All @@ -34,10 +20,9 @@ RUN INSTALL_PKGS=" \
chmod og+w /tmp/ocp-clo

COPY --from=builder /opt/app-root/src/bin/cluster-logging-operator /usr/bin/
COPY --from=builder /opt/app-root/src/bin/must-gather /usr/bin/

COPY --from=builder /opt/app-root/src/must-gather/collection-scripts/* /usr/bin/

COPY --from=origincli /tmp/oc /usr/bin/oc
RUN ln -s /usr/bin/must-gather /usr/bin/gather

USER 1000

Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ bin/forwarder-generator:
bin/cluster-logging-operator:
go build $(BUILD_OPTS) -o $@ ./cmd

bin/must-gather:
go build $(BUILD_OPTS) -o $@ ./must-gather/cmd

.PHONY: must-gather
must-gather: bin/must-gather

.PHONY: openshift-client
openshift-client:
@type -p oc > /dev/null || bash hack/get-openshift-client.sh

.PHONY: build
build: bin/cluster-logging-operator
build: bin/cluster-logging-operator bin/must-gather

.PHONY: build-debug
build-debug:
Expand Down
62 changes: 62 additions & 0 deletions must-gather/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package main

import (
"context"
"flag"
"fmt"
"io"
"os"
"path/filepath"

"github.com/openshift/cluster-logging-operator/must-gather"
)

func main() {
var (
destDir string
loggingNamespace string
logFileName string
)

flag.StringVar(&destDir, "dest-dir", "/must-gather", "Destination directory for collecting must-gather data")
flag.StringVar(&loggingNamespace, "logging-namespace", "openshift-logging", "Namespace where cluster logging operator is deployed")
flag.StringVar(&logFileName, "log-file", "gather-debug.log", "Name of the debug log file")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
flag.Parse()

// Ensure destination directory exists
if err := os.MkdirAll(destDir, 0755); err != nil {
fmt.Fprintf(os.Stderr, "Failed to create destination directory: %v\n", err)
os.Exit(1)
}

// Set up logging
logFilePath := filepath.Join(destDir, logFileName)
logFile, err := os.Create(logFilePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create log file: %v\n", err)
os.Exit(1)
}
defer func() {
if err := logFile.Close(); err != nil {
fmt.Fprintf(os.Stderr, "Failed to close log file: %v\n", err)
}
}()

// Use multi-writer to write to both file and stdout
multiWriter := io.MultiWriter(os.Stdout, logFile)

// Create and run the gather
gather, err := mustgather.NewGather(destDir, loggingNamespace, logFileName, multiWriter)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create gather: %v\n", err)
os.Exit(1)
}

ctx := context.Background()
if err := gather.Run(ctx); err != nil {
fmt.Fprintf(os.Stderr, "Must-gather failed: %v\n", err)
os.Exit(1)
}

fmt.Println("Must-gather completed successfully")
}
35 changes: 0 additions & 35 deletions must-gather/collection-scripts/common

This file was deleted.

145 changes: 0 additions & 145 deletions must-gather/collection-scripts/gather

This file was deleted.

This file was deleted.

Loading
Loading