quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.83k stars 2.69k forks source link

Openshift manifest generator does not detect commit id in "detached HEAD" state #34749

Open fedinskiy opened 1 year ago

fedinskiy commented 1 year ago

Describe the bug

I have an application with quarkus-openshift extension, which I use to generate kubernetes and openshift manifests for OCP. Usually this manifests contain two annotations in Service->metadata: app.quarkus.io/build-timestamp and app.quarkus.io/commit-id. But when I switch to some particular commit (so-called "detached HEAD" state), the app.quarkus.io/commit-id is not generated anymore.

Expected behavior

Commit id should be detected and added to the manifest if it exists, kubernetest.yml should look like that:

apiVersion: v1
kind: Service
metadata:
  annotations:
    app.quarkus.io/quarkus-version: 3.14.3
    app.quarkus.io/commit-id: 2fd9ef7e137d074740cb2df3e0936b6a930a3d60
    app.quarkus.io/vcs-uri: https://github.com/fedinskiy/reproducer.git
    app.quarkus.io/build-timestamp: 2024-09-20 - 07:40:16 +0000
  labels:
    app.kubernetes.io/name: theapp
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
    app.kubernetes.io/managed-by: quarkus
  name: theapp

<...>

Actual behavior

apiVersion: v1
kind: Service
metadata:
  annotations:
    app.quarkus.io/quarkus-version: 3.14.3
    app.quarkus.io/vcs-uri: https://github.com/fedinskiy/reproducer.git
    app.quarkus.io/build-timestamp: 2024-09-20 - 07:37:12 +0000
  labels:
    app.kubernetes.io/name: theapp
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
    app.kubernetes.io/managed-by: quarkus
  name: theapp
<...>

How to Reproduce?

  1. Clone the reproducer: git@github.com:fedinskiy/reproducer.git -b manifest-generator
  2. Check status:

    
    $ git log -n1
    commit 2fd9ef7e137d074740cb2df3e0936b6a930a3d60 (HEAD -> manifest-generator, origin/manifest-generator)
    Author: Fedor Dudinsky <fdudinsk@redhat.com>
    Date:   Fri Sep 20 09:34:18 2024 +0200
    
    Manifest generator in detached HEAD state
    $ git status
    On branch manifest-generator
    Your branch is up to date with 'origin/manifest-generator'.

nothing to commit, working tree clean

3. Generate manifests: `mvn clean install -DskipTests`
4. Check manifests: `less target/kubernetes/kubernetes.yml` 
5. Detach HEAD: `git checkout 2fd9ef7e137d074740cb2df3e0936b6a930a3d60`
6. Check state:

commit 2fd9ef7e137d074740cb2df3e0936b6a930a3d60 (HEAD, origin/manifest-generator, manifest-generator) Author: Fedor Dudinsky fdudinsk@redhat.com Date: Fri Sep 20 09:34:18 2024 +0200

Manifest generator in detached HEAD stat

$ git status HEAD detached at 2fd9ef7 nothing to commit, working tree clean


7. Generate manifests: `mvn clean install -DskipTests`
8. Check new manifests: `less target/kubernetes/kubernetes.yml`

### Output of `uname -a` or `ver`

6.10.8-200.fc40.x86_64

### Output of `java -version`

21.0.1, vendor: Eclipse Adoptium

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

3.14.3 (was first found in 3.2.0.Final)

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)

### Additional information

git version  2.46.0 (was first detected on 2.41.0)
geoand commented 2 months ago

Is this still an issue?

fedinskiy commented 2 months ago

@geoand yes, I can reproduce it even for 3.14.3.

I created separate branch in reproducer for it, will update the description in a minute

UPD: updated the description

geoand commented 2 months ago

Thanks for the update!

geoand commented 2 months ago

cc @iocanel