Unable to update agent io.fabric8.patch.management.PatchException: Invalid ref name: baseline-ssh-fabric8-1.2.0.redhat-630424

Solution Verified - Updated -

Environment

  • Red Hat Fuse
    • 6.3

Issue

  • Unable to update agent io.fabric8.patch.management.PatchException: Invalid ref name: baseline-ssh-fabric8-1.2.0.redhat-630424
  • Unable to Upgrade Fuse 6.3 from R13 to R14 (630424)

Resolution

  • The problem was that d some old fabric versions including 1.0 got deleted
  • if version 1.0 doesn't exists then fabric containers are considered as EnvType.STANDALONE and the baselines are NOT created.
  • The workaround is to re-create fabric version 1.0
package io.fabric8.patch.management.impl;

public class DefaultEnvService

 @Override
    public EnvType determineEnvironmentType() throws IOException {
        if (Boolean.getBoolean("patching.disabled")) {
            return EnvType.UNKNOWN;
        }

        File localGitRepository = new File(systemContext.getProperty("karaf.data"), "git/local/fabric");
        // TODO: maybe check if .git/config contains remote "origin" ending with "/git/fabric/"?
        boolean isFabricGitInitialized = localGitRepository.isDirectory()
                && new File(localGitRepository, ".git").isDirectory()
                && hasBranch(localGitRepository, "master")
                && hasBranch(localGitRepository, "1.0");
        boolean hasZookeeperUrlAtStartup = System.getProperty("zookeeper.url") != null;
        boolean isChild = isChild(systemContext);

        if (isFabricGitInitialized || hasZookeeperUrlAtStartup) {
            if (isChild) {
                return EnvType.FABRIC_CHILD;
            } else {
                // is it enough?
                if (new File(karafHome, "bin/fuse").isFile()
                        || new File(karafHome, "bin/fuse.bat").isFile()) {
                    return EnvType.FABRIC_FUSE;
                } else if (new File(karafHome, "bin/amq").isFile()
                        || new File(karafHome, "bin/amq.bat").isFile()) {
                    return EnvType.FABRIC_AMQ;
                } else if (new File(karafHome, "bin/fabric8").isFile()
                        || new File(karafHome, "bin/fabric8.bat").isFile()) {
                    return EnvType.FABRIC_FABRIC8;
                }
            }
        }

        return isChild ? EnvType.STANDALONE_CHILD : EnvType.STANDALONE;
    }

/**
     * Checks if git repository (a dir containing <code>.git</code> subdir) has particular branch
     * @param localGitRepository
     * @param name
     * @return
     */
    private boolean hasBranch(File localGitRepository, String name) {
        boolean separateRef = new File(localGitRepository, ".git/refs/heads/" + name).isFile();
        boolean packedRef = false;
        try {
            String packedRefsFile = FileUtils.readFileToString(new File(localGitRepository, ".git/packed-refs"));
            packedRef = packedRefsFile != null && packedRefsFile.contains("refs/heads/" + name);
        } catch (IOException ignored) {
        }
        return separateRef || packedRef;
    }

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments