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

Docker Replacement Rules: Not working as expected #20128

Closed
setchy opened this issue Jan 31, 2023 · 5 comments · Fixed by #20317
Closed

Docker Replacement Rules: Not working as expected #20128

setchy opened this issue Jan 31, 2023 · 5 comments · Fixed by #20317
Labels
status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality

Comments

@setchy
Copy link
Collaborator

setchy commented Jan 31, 2023

How are you running Renovate?

Mend Renovate hosted app on github.com

If you're self-hosting Renovate, tell us what version of Renovate you run.

No response

If you're self-hosting Renovate, select which platform you are using.

None

If you're self-hosting Renovate, tell us what version of the platform you run.

No response

Was this something which used to work for you, and then stopped?

I never saw this working

Describe the bug

I have had this demonstration repository for a while in eager anticipation of the recently released support for Docker replacement rules

I have a single Dockerfile with two images and two replacement rules.

My expected behavior is

  • FROM java:8 replaced with FROM eclipse-temurin:8
  • FROM bitnami/redis:6.2 replaced with FROM mcr.microsoft.com/oss/bitnami/redis:6.0.8

However, observed behavior is

  • No replacement PR for java
  • bitnami/redis PR only updates version number, doesn't update dependency name - see PR

Logs excerpt

{
  "baseBranch": "main",
  "config": {
    "dockerfile": [
      {
        "deps": [
          {
            "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
            "currentValue": "8",
            "currentVersion": "8",
            "datasource": "docker",
            "depIndex": 0,
            "depName": "java",
            "depType": "stage",
            "fixedVersion": "8",
            "registryUrl": "https://index.docker.io",
            "replaceString": "java:8",
            "versioning": "regex:^(?<major>\\d+)?(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?([\\._+](?<build>\\d+))?(-(?<compatibility>.*))?$",
            "warnings": [],
            "updates": []
          },
          {
            "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
            "currentValue": "6.2",
            "currentVersion": "6.2",
            "datasource": "docker",
            "depIndex": 1,
            "depName": "bitnami/redis",
            "depType": "final",
            "fixedVersion": "6.2",
            "isSingleVersion": true,
            "registryUrl": "https://index.docker.io",
            "replaceString": "bitnami/redis:6.2",
            "sourceDirectory": "bitnami/redis",
            "sourceUrl": "https://github.com/bitnami/containers",
            "versioning": "docker",
            "warnings": [],
            "updates": [
              {
                "updateType": "replacement",
                "newName": "mcr.microsoft.com/oss/bitnami/redis",
                "newValue": "6.0.8",
                "branchName": "renovate/bitnami-redis-replacement"
              },
              {
                "bucket": "major-7",
                "newVersion": "7.0",
                "newValue": "7.0",
                "newMajor": 7,
                "newMinor": 0,
                "updateType": "major",
                "branchName": "renovate/bitnami-redis-7.x"
              }
            ]
          }
        ],
        "packageFile": "Dockerfile"
      }
    ]
  }
}

Relevant debug logs

Logs
Copy/paste the relevant log(s) here, between the starting and ending backticks

Have you created a minimal reproduction repository?

I have linked to a minimal reproduction repository in the bug description

@setchy setchy added priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality labels Jan 31, 2023
@HonkingGoose
Copy link
Collaborator

Workaround preset clashing with packageRules?

Stupid idea, but could it be that a workaround: preset is clashing with your custom preset?

config:base has:

{
  "extends": [
    ":dependencyDashboard",
    ":semanticPrefixFixDepsChoreOthers",
    ":ignoreModulesAndTests",
    ":autodetectRangeStrategy",
    ":prHourlyLimit2",
    ":prConcurrentLimit10",
    "group:monorepos",
    "group:recommended",
    "workarounds:all"
  ]
}

"workarounds:all" comes with a workarounds:javaLTSVersions preset:

{
  "packageRules": [
    {
      "allowedVersions": "/^(?:8|11|17)(?:\\.|-|$)/",
      "description": "Limit Java runtime versions to LTS releases. To receive all major releases add `workarounds:javaLTSVersions` to the `ignorePresets` array.",
      "matchDatasources": [
        "docker",
        "adoptium-java"
      ],
      "matchPackageNames": [
        "eclipse-temurin",
        "amazoncorretto",
        "adoptopenjdk",
        "openjdk",
        "java",
        "java-jre",
        "sapmachine"
      ],
      "versioning": "regex:^(?<major>\\d+)?(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?([\\._+](?<build>\\d+))?(-(?<compatibility>.*))?$"
    }
  ]
}

So maybe things are not working together in the way you expected?

Code snippet for Bitnami to try maybe?

Our docs mention a code snippet for Bitnami, maybe that can help you? 1

{
  "packageRules": [
    {
      "matchDatasources": ["docker"],
      "matchPackagePrefixes": ["bitnami/"],
      "versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)(:?-(?<compatibility>.*-r)(?<build>\\d+))?$"
    }
  ]
}

Footnotes

  1. https://docs.renovatebot.com/modules/versioning/#regular-expression-versioning

@HonkingGoose
Copy link
Collaborator

Forked the reproduction to our renovate-reproductions org: https://github.com/renovate-reproductions/20128.

@setchy
Copy link
Collaborator Author

setchy commented Jan 31, 2023

Interesting suggestion @HonkingGoose -

To test I've updated my demo repo to remove the config:base - similar behavior https://github.com/setchy/renovate-replacements-docker/pulls

@setchy
Copy link
Collaborator Author

setchy commented Feb 4, 2023

I deleted the previous branches Renovate had created and re-ran.

replacement PR for bitname/redis is now working as expected - https://github.com/setchy/renovate-replacements-docker/pull/7

However the replacement PR for java is not yet 😬

@setchy
Copy link
Collaborator Author

setchy commented Feb 4, 2023

I was interested to see what would happen if I ran a similar configuration on Bitbucket Cloud. Turns out that it does identify a replacement, but then later fails with a WARN when trying to push the branch

{
   "depName": "java",
   "currentValue": "8",
   "replaceString": "java:8",
   "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
   "datasource": "docker",
   "depType": "final",
   "depIndex": 0,
   "updates": [
     {
       "updateType": "replacement",
       "newName": "eclipse-temurin",
       "newValue": "8",
       "newDigest": "sha256:6c14effcddef1e8d0a4324d519431d66a75532aae79d509fe949407edd4e29e4",
       "branchName": "renovate/java-replacement"
     }
}
DEBUG: syncBranchState() (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: syncBranchState(): Branch cache not found, creating minimal branchState (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: getBranchPr(renovate/java-replacement) (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: findPr(renovate/java-replacement, undefined, open) (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: getPrList() (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: branchExists=false (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: dependencyDashboardCheck=undefined (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: recreateClosed is false (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: findPr(renovate/java-replacement, chore(deps): replace java docker tag with wfscorp.jfrog.io/docker/eclipse-temurin 8, !open) (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: getPrList() (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: prAlreadyExisted=false (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: Checking schedule(at any time, null) (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: No schedule defined (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: Branch needs creating (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: Using reuseExistingBranch: false (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: Setting current branch to main (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: latest commit (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
       "branchName": "main",
       "latestCommitDate": "2023-02-04T14:54:04-05:00"
DEBUG: manager.getUpdatedPackageFiles() reuseExistingBranch=false (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)
DEBUG: Starting search at index 5 (repository=bitbucket-org/renovate-docker-prefix, packageFile=Dockerfile, branch=renovate/java-replacement)
       "depName": "java"
DEBUG: Found match at index 5 (repository=bitbucket-org/renovate-docker-prefix, packageFile=Dockerfile, branch=renovate/java-replacement)
       "depName": "java"
 WARN: Error updating branch: update failure (repository=bitbucket-org/renovate-docker-prefix, branch=renovate/java-replacement)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants